<pre style='margin:0'>
Clemens Lang (neverpanic) pushed a commit to branch master
in repository macports-base.
</pre>
<p><a href="https://github.com/macports/macports-base/commit/63ac5dfbdc9cc11d71552290abdebf96cb45267d">https://github.com/macports/macports-base/commit/63ac5dfbdc9cc11d71552290abdebf96cb45267d</a></p>
<pre style="white-space: pre; background: #F8F8F8"><span style='display:block; white-space:pre;color:#808000;'>commit 63ac5dfbdc9cc11d71552290abdebf96cb45267d
</span>Author: Clemens Lang <cal@macports.org>
AuthorDate: Wed Dec 9 00:09:50 2020 +0100
<span style='display:block; white-space:pre;color:#404040;'> machista1.0: Use a locally-built lib for tests
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> The tests for this library need a universal lib; we used to just use
</span><span style='display:block; white-space:pre;color:#404040;'> /usr/lib/libSystem.B.dylib, but Apple has removed that with macOS 11, so
</span><span style='display:block; white-space:pre;color:#404040;'> now we need a different alternative.
</span><span style='display:block; white-space:pre;color:#404040;'>
</span><span style='display:block; white-space:pre;color:#404040;'> Build a library that's dual arch, relying on $OS_MAJOR to figure out
</span><span style='display:block; white-space:pre;color:#404040;'> whatever dual arch means on the current platform.
</span>---
src/machista1.0/Makefile.in | 38 +++++++++++++++++++++++++++++---
src/machista1.0/tests/empty.c | 1 +
src/machista1.0/tests/libmachista-test.c | 14 ++++++------
3 files changed, 43 insertions(+), 10 deletions(-)
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/machista1.0/Makefile.in b/src/machista1.0/Makefile.in
</span><span style='display:block; white-space:pre;color:#808080;'>index c0d20a9d..7ab8d2cd 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/machista1.0/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/machista1.0/Makefile.in
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -43,8 +43,12 @@ ${PKG_INDEX}:: ${SWIG_SHLIB}
</span>
clean::
rm -f ${SWIG_OBJS} ${PKG_INDEX}
<span style='display:block; white-space:pre;background:#ffe0e0;'>- rm -f ${TESTS}
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- rm -rf ${TESTS:%=%.dSYM}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rm -f ${TESTS} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ tests/libmachista-test-dependency${SHLIB_SUFFIX} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ tests/libmachista-test-lib${SHLIB_SUFFIX}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ rm -rf ${TESTS:%=%.dSYM} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ tests/libmachista-test-dependency${SHLIB_SUFFIX}.dSYM \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ tests/libmachista-test-lib${SHLIB_SUFFIX}.dSYM
</span>
distclean::
rm -f Makefile
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -52,8 +56,36 @@ distclean::
</span> test:: ${TESTS}
${TESTS}
<span style='display:block; white-space:pre;background:#ffe0e0;'>-tests/libmachista-test: tests/libmachista-test.c libmachista.h libmachista.o hashmap.o
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+tests/libmachista-test: tests/libmachista-test.c libmachista.h libmachista.o hashmap.o tests/libmachista-test-lib${SHLIB_SUFFIX}
</span> $(CC) $(CFLAGS) -D_POSIX_SOURCE -o $@ -I. $< libmachista.o hashmap.o
<span style='display:block; white-space:pre;background:#e0ffe0;'>+# The tests for this library need a universal lib; we used to just use
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# /usr/lib/libSystem.B.dylib, but Apple has removed that with macOS 11, so now
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# we need a different alternative.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# Build a library that's dual arch, relying on $OS_MAJOR to figure out whatever
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# dual arch means on the current platform. Note the use of -nostdlib, because
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# later versions of macOS actually didn't ship support for i386 stdlibs for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# a while, so no universal compiling was possible on those machines at all
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# (which didn't matter, since libSystem.B.dylib was still universal on those).
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# The if expression below is basically the equivalent from aclocal.m4 for
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+# UNIVERSAL_ARCHS, except that we're always forcing some kind of universiality.
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+tests/%${SHLIB_SUFFIX}:
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ifeq (darwin,@OS_PLATFORM@)
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ ${SHLIB_LD} \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $$(if [ @OS_MAJOR@ -lt 10 ]; then echo "-arch i386 -arch ppc"; elif [ @OS_MAJOR@ -lt 20 ]; then echo "-arch x86_64 -arch i386"; else echo "-arch x86_64 -arch arm64"; fi) \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -nostdlib \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -install_name $@ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ $^ \
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ -o $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+else
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ touch $@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+endif
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+tests/libmachista-test-dependency${SHLIB_SUFFIX}: tests/empty.c
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+tests/libmachista-test-lib${SHLIB_SUFFIX}: tests/empty.c tests/libmachista-test-dependency${SHLIB_SUFFIX}
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+
</span> codesign:: $(SHLIB_NAME)
../codesign.sh $?
<span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/machista1.0/tests/empty.c b/src/machista1.0/tests/empty.c
</span>new file mode 100644
<span style='display:block; white-space:pre;color:#808080;'>index 00000000..85e6cd8c
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>--- /dev/null
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/machista1.0/tests/empty.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -0,0 +1 @@
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+void foo() {}
</span><span style='display:block; white-space:pre;color:#808080;'>diff --git a/src/machista1.0/tests/libmachista-test.c b/src/machista1.0/tests/libmachista-test.c
</span><span style='display:block; white-space:pre;color:#808080;'>index 527e415c..3f70fc93 100644
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>--- a/src/machista1.0/tests/libmachista-test.c
</span><span style='display:block; white-space:pre;background:#e0e0ff;'>+++ b/src/machista1.0/tests/libmachista-test.c
</span><span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -10,7 +10,7 @@
</span> #include <sys/wait.h>
#include <unistd.h>
<span style='display:block; white-space:pre;background:#ffe0e0;'>-#define LIBSYSTEM_PATH "/usr/lib/libSystem.B.dylib"
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+#define TEST_LIB_PATH "tests/libmachista-test-lib.dylib"
</span> #define OTOOL_PATH "/usr/bin/otool"
// check helper
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -276,7 +276,7 @@ static bool test_destroy_null(void) {
</span> }
/**
<span style='display:block; white-space:pre;background:#ffe0e0;'>- * Test reading libSystem.B.dylib
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ * Test reading TEST_LIB_PATH
</span> */
static void forked_test_libsystem(void) {
macho_handle_t *handle = macho_create_handle();
<span style='display:block; white-space:pre;background:#e0e0e0;'>@@ -284,20 +284,20 @@ static void forked_test_libsystem(void) {
</span> int ret = 0;
// parse file
<span style='display:block; white-space:pre;background:#ffe0e0;'>- if ((ret = macho_parse_file(handle, LIBSYSTEM_PATH, &result)) != MACHO_SUCCESS) {
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- printf("\tError parsing `%s': %s\n", LIBSYSTEM_PATH, macho_strerror(ret));
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if ((ret = macho_parse_file(handle, TEST_LIB_PATH, &result)) != MACHO_SUCCESS) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ printf("\tError parsing `%s': %s\n", TEST_LIB_PATH, macho_strerror(ret));
</span> }
// get otool reference output
<span style='display:block; white-space:pre;background:#ffe0e0;'>- bool success = compare_to_otool_output(LIBSYSTEM_PATH, result);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ bool success = compare_to_otool_output(TEST_LIB_PATH, result);
</span>
macho_destroy_handle(handle);
exit(!success);
}
static bool test_libsystem(void) {
<span style='display:block; white-space:pre;background:#ffe0e0;'>- puts("Testing parsing libSystem.B.dylib");
</span><span style='display:block; white-space:pre;background:#ffe0e0;'>- if (fork_test(forked_test_libsystem, "Error parsing libSystem.B.dylib")) {
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ puts("Testing parsing " TEST_LIB_PATH);
</span><span style='display:block; white-space:pre;background:#e0ffe0;'>+ if (fork_test(forked_test_libsystem, "Error parsing " TEST_LIB_PATH)) {
</span> puts("\tOK");
return true;
}
</pre><pre style='margin:0'>
</pre>