summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/plugin/qpluginloader/machtest
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib/plugin/qpluginloader/machtest')
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt140
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl29
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri13
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro15
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro47
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro3
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro9
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro2
-rwxr-xr-xtests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl99
-rw-r--r--tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp2
10 files changed, 143 insertions, 216 deletions
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
index 05cd044aa3..daf922b42c 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/CMakeLists.txt
@@ -1,2 +1,140 @@
-# Generated from machtest.pro.
+# Copyright (C) 2024 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+set_directory_properties(PROPERTIES
+ _qt_good_targets ""
+ _qt_stub_targets ""
+)
+function(add_plugin_binary)
+ set(no_value_options "")
+ set(single_value_options NAME ARCH OUT_TARGET)
+ set(multi_value_options SOURCES)
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ set(output_name ${arg_NAME}.${arg_ARCH})
+ set(target tst_qpluginloader.${output_name})
+ set(${arg_OUT_TARGET} ${target} PARENT_SCOPE)
+ set_property(DIRECTORY APPEND PROPERTY _qt_${arg_NAME}_targets ${target})
+ add_library(${target} MODULE ${arg_SOURCES})
+ add_dependencies(tst_qpluginloader ${target})
+ set_target_properties(${target} PROPERTIES
+ OUTPUT_NAME ${output_name}
+ PREFIX ""
+ SUFFIX ".dylib"
+ DEBUG_POSTFIX ""
+ OSX_ARCHITECTURES ${arg_ARCH}
+ )
+endfunction()
+
+function(add_good_binary)
+ set(no_value_options "")
+ set(single_value_options ARCH)
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ add_plugin_binary(
+ NAME good
+ ARCH ${arg_ARCH}
+ SOURCES ../fakeplugin.cpp
+ OUT_TARGET target
+ )
+
+ # We cannot link against Qt6::Core, because the architecture might not match.
+ # Extract the include directories from Qt6::Core.
+ get_target_property(incdirs Qt6::Core INTERFACE_INCLUDE_DIRECTORIES)
+ target_include_directories(${target} PRIVATE ${incdirs})
+
+ # Extract the compile definitions from Qt6::Core and disable version tagging.
+ get_target_property(compdefs Qt6::Core INTERFACE_COMPILE_DEFINITIONS)
+ target_compile_definitions(${target} PRIVATE
+ ${compdefs}
+ QT_NO_VERSION_TAGGING
+ )
+endfunction()
+
+function(add_stub_binary)
+ set(no_value_options "")
+ set(single_value_options ARCH)
+ set(multi_value_options "")
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ add_plugin_binary(
+ NAME stub
+ ARCH ${arg_ARCH}
+ SOURCES stub.cpp
+ )
+endfunction()
+
+function(add_fat_binary)
+ set(no_value_options "")
+ set(single_value_options NAME OUT_TARGET)
+ set(multi_value_options TARGETS)
+ cmake_parse_arguments(PARSE_ARGV 0 arg
+ "${no_value_options}" "${single_value_options}" "${multi_value_options}"
+ )
+
+ set(arch_args "")
+ foreach(dependency IN LISTS arg_TARGETS)
+ get_target_property(arch ${dependency} OSX_ARCHITECTURES)
+ list(APPEND arch_args -arch ${arch} $<TARGET_FILE_NAME:${dependency}>)
+ endforeach()
+
+ set(output_name good.fat.${arg_NAME})
+ set(output_file ${output_name}.dylib)
+ set(target tst_qpluginloader.${output_name})
+ set(${arg_OUT_TARGET} ${target} PARENT_SCOPE)
+ add_custom_command(
+ OUTPUT ${output_file}
+ COMMAND lipo -create -output ${output_file} ${arch_args}
+ DEPENDS ${arg_TARGETS}
+ )
+ add_custom_target(${target}
+ DEPENDS ${output_file}
+ )
+ add_dependencies(tst_qpluginloader ${target})
+endfunction()
+
+set(archs_to_test arm64 x86_64)
+foreach(arch IN LISTS archs_to_test)
+ add_good_binary(ARCH ${arch})
+ add_stub_binary(ARCH ${arch})
+endforeach()
+
+get_directory_property(good_targets _qt_good_targets)
+add_fat_binary(NAME all TARGETS ${good_targets})
+
+set(targets ${good_targets})
+list(FILTER targets EXCLUDE REGEX "\\.arm64$")
+add_fat_binary(NAME no-arm64 TARGETS ${targets})
+
+set(targets ${good_targets})
+list(FILTER targets EXCLUDE REGEX "\\.x86_64$")
+add_fat_binary(NAME no-x86_64 TARGETS ${targets})
+
+get_directory_property(stub_targets _qt_stub_targets)
+set(targets ${stub_targets})
+list(FILTER targets INCLUDE REGEX "\\.arm64$")
+add_fat_binary(NAME stub-arm64 TARGETS ${targets})
+
+set(targets ${stub_targets})
+list(FILTER targets INCLUDE REGEX "\\.x86_64$")
+add_fat_binary(NAME stub-x86_64 TARGETS ${targets})
+
+set(bad_binary_names "")
+foreach(i RANGE 1 13)
+ list(APPEND bad_binary_names "bad${i}.dylib")
+endforeach()
+add_custom_command(
+ OUTPUT ${bad_binary_names}
+ COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/generate-bad.pl
+)
+add_custom_target(tst_qpluginloader_generate_bad_binaries
+ DEPENDS ${bad_binary_names}
+)
+add_dependencies(tst_qpluginloader tst_qpluginloader_generate_bad_binaries)
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl b/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
index 4fed135049..3de1eb581a 100755
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/generate-bad.pl
@@ -1,31 +1,6 @@
#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2016 Intel Corporation.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
+# Copyright (C) 2016 Intel Corporation.
+# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
use strict;
use constant FAT_MAGIC => 0xcafebabe;
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri
deleted file mode 100644
index ca4a0a07e9..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pri
+++ /dev/null
@@ -1,13 +0,0 @@
-TEMPLATE = aux
-
-# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
-load(qt)
-
-goodlib.target = good.$${QMAKE_APPLE_DEVICE_ARCHS}.dylib
-goodlib.commands = $(CXX) $(CXXFLAGS) -shared -o $@ -I$(INCPATH) $<
-goodlib.depends += $$PWD/../fakeplugin.cpp
-
-all.depends += goodlib
-
-QMAKE_EXTRA_TARGETS += goodlib all
-QMAKE_CLEAN += $$goodlib.target
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
deleted file mode 100644
index 795dd89895..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest.pro
+++ /dev/null
@@ -1,15 +0,0 @@
-TEMPLATE = subdirs
-
-SUBDIRS = \
- machtest_i386.pro \
- machtest_x86_64.pro \
- machtest_ppc64.pro \
- machtest_fat.pro
-
-machtest_fat-pro.depends = \
- machtest_i386.pro \
- machtest_x86_64.pro \
- machtest_ppc64.pro
-
-machtest_ppc64-pro.depends = \
- machtest_x86_64.pro
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro
deleted file mode 100644
index 9c34a873bc..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_fat.pro
+++ /dev/null
@@ -1,47 +0,0 @@
-TEMPLATE = aux
-OTHER_FILES += generate-bad.pl
-
-# Needs explicit load()ing due to aux template. Relies on QT being non-empty.
-load(qt)
-
-# Generate a fat binary with three architectures
-fat_all.target = good.fat.all.dylib
-fat_all.commands = lipo -create -output $@ \
- -arch ppc64 good.ppc64.dylib \
- -arch i386 good.i386.dylib \
- -arch x86_64 good.x86_64.dylib
-fat_all.depends += good.i386.dylib good.x86_64.dylib good.ppc64.dylib
-
-fat_no_i386.target = good.fat.no-i386.dylib
-fat_no_i386.commands = lipo -create -output $@ -arch x86_64 good.x86_64.dylib -arch ppc64 good.ppc64.dylib
-fat_no_i386.depends += good.x86_64.dylib good.ppc64.dylib
-
-fat_no_x86_64.target = good.fat.no-x86_64.dylib
-fat_no_x86_64.commands = lipo -create -output $@ -arch i386 good.i386.dylib -arch ppc64 good.ppc64.dylib
-fat_no_x86_64.depends += good.i386.dylib good.ppc64.dylib
-
-stub_i386.commands = $$QMAKE_CXX -shared -arch i386 -o stub.i386.dylib $$PWD/stub.cpp
-stub_i386.depends += $$PWD/stub.cpp
-
-stub_x86_64.commands = $$QMAKE_CXX -shared -arch x86_64 -o stub.x86_64.dylib $$PWD/stub.cpp
-stub_x86_64.depends += $$PWD/stub.cpp
-
-fat_stub_i386.target = good.fat.stub-i386.dylib
-fat_stub_i386.commands = lipo -create -output $@ -arch ppc64 good.ppc64.dylib -arch i386 stub.i386.dylib
-fat_stub_i386.depends += stub_i386 good.x86_64.dylib good.ppc64.dylib
-
-fat_stub_x86_64.target = good.fat.stub-x86_64.dylib
-fat_stub_x86_64.commands = lipo -create -output $@ -arch ppc64 good.ppc64.dylib -arch x86_64 stub.x86_64.dylib
-fat_stub_x86_64.depends += stub_x86_64 good.i386.dylib good.ppc64.dylib
-
-bad.commands = $$PWD/generate-bad.pl
-bad.depends += $$PWD/generate-bad.pl
-
-MYTARGETS = $$fat_all.depends fat_all fat_no_x86_64 fat_no_i386 \
- fat_stub_i386 fat_stub_x86_64 bad stub_i386 stub_x86_64
-all.depends += $$MYTARGETS
-QMAKE_EXTRA_TARGETS += $$MYTARGETS all
-
-QMAKE_CLEAN += $$fat_all.target $$fat_no_i386.target $$fat_no_x86_64.target \
- $$fat_stub_i386.target $$fat_stub_x86_64.target \
- "bad*.dylib"
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro
deleted file mode 100644
index bfb2e0930c..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_i386.pro
+++ /dev/null
@@ -1,3 +0,0 @@
-QMAKE_APPLE_DEVICE_ARCHS = i386
-include(machtest.pri)
-
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro
deleted file mode 100644
index a73f97ccc6..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_ppc64.pro
+++ /dev/null
@@ -1,9 +0,0 @@
-QMAKE_APPLE_DEVICE_ARCHS = ppc64
-include(machtest.pri)
-
-OTHER_FILES += ppcconverter.pl
-
-# Current macOS toolchains have no compiler for PPC anymore
-# So we fake it by converting an x86-64 binary to (little-endian!) PPC64
-goodlib.commands = $$PWD/ppcconverter.pl $< $@
-goodlib.depends = good.x86_64.dylib $$PWD/ppcconverter.pl
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro b/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro
deleted file mode 100644
index 9dbae5c4ee..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/machtest_x86_64.pro
+++ /dev/null
@@ -1,2 +0,0 @@
-QMAKE_APPLE_DEVICE_ARCHS = x86_64
-include(machtest.pri)
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl b/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl
deleted file mode 100755
index 7242d7596b..0000000000
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/ppcconverter.pl
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/perl
-#############################################################################
-##
-## Copyright (C) 2016 Intel Corporation.
-## Contact: https://www.qt.io/licensing/
-##
-## This file is the build configuration utility of the Qt Toolkit.
-##
-## $QT_BEGIN_LICENSE:GPL-EXCEPT$
-## Commercial License Usage
-## Licensees holding valid commercial Qt licenses may use this file in
-## accordance with the commercial license agreement provided with the
-## Software or, alternatively, in accordance with the terms contained in
-## a written agreement between you and The Qt Company. For licensing terms
-## and conditions see https://www.qt.io/terms-conditions. For further
-## information use the contact form at https://www.qt.io/contact-us.
-##
-## GNU General Public License Usage
-## Alternatively, this file may be used under the terms of the GNU
-## General Public License version 3 as published by the Free Software
-## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-## included in the packaging of this file. Please review the following
-## information to ensure the GNU General Public License requirements will
-## be met: https://www.gnu.org/licenses/gpl-3.0.html.
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# Changes the Mach-O file type header to PowerPC.
-#
-# The header is (from mach-o/loader.h):
-# struct mach_header {
-# uint32_t magic; /* mach magic number identifier */
-# cpu_type_t cputype; /* cpu specifier */
-# cpu_subtype_t cpusubtype; /* machine specifier */
-# uint32_t filetype; /* type of file */
-# uint32_t ncmds; /* number of load commands */
-# uint32_t sizeofcmds; /* the size of all the load commands */
-# uint32_t flags; /* flags */
-# };
-#
-# The 64-bit header is identical in the first three fields, except for a different
-# magic number. We will not touch the magic number, we'll just reset the cputype
-# field to the PowerPC type and the subtype field to zero.
-#
-# We will not change the file's endianness. That means we might create a little-endian
-# PowerPC binary, which could not be run in real life.
-#
-# We will also not change the 64-bit ABI flag, which is found in the cputype's high
-# byte. That means we'll create a PPC64 binary if fed a 64-bit input.
-#
-use strict;
-use constant MH_MAGIC => 0xfeedface;
-use constant MH_CIGAM => 0xcefaedfe;
-use constant MH_MAGIC_64 => 0xfeedfacf;
-use constant MH_CIGAM_64 => 0xcffaedfe;
-use constant CPU_TYPE_POWERPC => 18;
-use constant CPU_SUBTYPE_POWERPC_ALL => 0;
-
-my $infile = shift @ARGV or die("Missing input filename");
-my $outfile = shift @ARGV or die("Missing output filename");
-
-open IN, "<$infile" or die("Can't open $infile for reading: $!\n");
-open OUT, ">$outfile" or die("Can't open $outfile for writing: $!\n");
-
-binmode IN;
-binmode OUT;
-
-# Read the first 12 bytes, which includes the interesting fields of the header
-my $buffer;
-read(IN, $buffer, 12);
-
-my $magic = vec($buffer, 0, 32);
-if ($magic == MH_MAGIC || $magic == MH_MAGIC_64) {
- # Big endian
- # The low byte of cputype is at offset 7
- vec($buffer, 7, 8) = CPU_TYPE_POWERPC;
-} elsif ($magic == MH_CIGAM || $magic == MH_CIGAM_64) {
- # Little endian
- # The low byte of cpytype is at offset 4
- vec($buffer, 4, 8) = CPU_TYPE_POWERPC;
-} else {
- $magic = '';
- $magic .= sprintf("%02X ", $_) for unpack("CCCC", $buffer);
- die("Invalid input. Unknown magic $magic\n");
-}
-vec($buffer, 2, 32) = CPU_SUBTYPE_POWERPC_ALL;
-
-print OUT $buffer;
-
-# Copy the rest
-while (!eof(IN)) {
- read(IN, $buffer, 4096) and
- print OUT $buffer or
- die("Problem copying: $!\n");
-}
-close(IN);
-close(OUT);
diff --git a/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp b/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
index 24bac391fb..eed7228a29 100644
--- a/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
+++ b/tests/auto/corelib/plugin/qpluginloader/machtest/stub.cpp
@@ -1 +1,3 @@
+// Copyright (C) 2024 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
void dummy() {}