From ece74ceaaf0f1dd89e8520f73149867a6fa73082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Reimar=20D=C3=B6ffinger?= Date: Sun, 29 Oct 2023 17:05:40 +0100 Subject: [PATCH] tests: Add support for codesigning command. Allows running the tests out-of-the-box on macOS. Also delete *.dylib in tests2 dir on "make clean". One remaining issue on macOS 14.1 is that the -undefined warning option no longer works, thus breaking test3 and test1b. --- Makefile | 6 ++++++ tests/Makefile | 6 +++++- tests/tests2/Makefile | 7 +++++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 11cc9a88..018b9887 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,12 @@ TCCFLAGS = $(TCCFLAGS$(CFG)) TCC_LOCAL = $(TOP)/tcc$(EXESUF) TCC = $(TCC_LOCAL) $(TCCFLAGS) +ifdef CONFIG_OSX +CODESIGN = codesign -s - +else +CODESIGN = true +endif + CFLAGS_P = $(CFLAGS) -pg -static -DCONFIG_TCC_STATIC -DTCC_PROFILE LIBS_P = $(LIBS) LDFLAGS_P = $(LDFLAGS) diff --git a/tests/Makefile b/tests/Makefile index a46c8524..020ed049 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -81,7 +81,7 @@ all test : hello-exe: ../examples/ex1.c @echo ------------ $@ ------------ - $(TCC) $< -o hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC) + $(TCC) $< -o hello$(EXESUF) && $(CODESIGN) hello$(EXESUF) && ./hello$(EXESUF) || $(DUMPTCC) hello-run: ../examples/ex1.c @echo ------------ $@ ------------ @@ -156,7 +156,9 @@ test4_static: tcctest.c test.ref dlltest: @echo ------------ $@ ------------ $(TCC) $(NATIVE_DEFINES) -DLIBTCC_AS_DLL $(TOPSRC)/libtcc.c $(LIBS) -shared -o libtcc2$(DLLSUF) + $(CODESIGN) libtcc2$(DLLSUF) $(TCC) $(NATIVE_DEFINES) -DONE_SOURCE=0 $(TOPSRC)/tcc.c libtcc2$(DLLSUF) $(LIBS) -Wl,-rpath=. -o tcc2$(EXESUF) + $(CODESIGN) tcc2$(EXESUF) ./tcc2$(EXESUF) $(TCCFLAGS) $(RUN_TCC) -run $(TOPSRC)/examples/ex1.c ifeq (,$(filter Darwin WIN32,$(TARGETOS))) @echo ------------ $@ with PIC ------------ @@ -241,6 +243,7 @@ abitest-cc.exe: abitest.c $(LIBTCC) abitest-tcc.exe: abitest.c libtcc.c $(TCC) -o $@ $^ $(NATIVE_DEFINES) $(LIBS) + $(CODESIGN) $@ abitest-% : abitest-%.exe @echo ------------ $@ ------------ @@ -253,6 +256,7 @@ endif vla_test$(EXESUF): vla_test.c $(TCC) -o $@ $^ + $(CODESIGN) $@ vla_test-run: vla_test$(EXESUF) @echo ------------ $@ ------------ diff --git a/tests/tests2/Makefile b/tests/tests2/Makefile index 8ce149b2..fe140751 100644 --- a/tests/tests2/Makefile +++ b/tests/tests2/Makefile @@ -105,8 +105,11 @@ GEN-ALWAYS = # this test creates two DLLs and an EXE 113_btdll.test: T1 = \ $(TCC) -bt $1 -shared -D DLL=1 -o a1$(DLLSUF) && \ + $(CODESIGN) a1$(DLLSUF) && \ $(TCC) -bt $1 -shared -D DLL=2 -o a2$(DLLSUF) && \ + $(CODESIGN) a2$(DLLSUF) && \ $(TCC) -bt $1 a1$(DLLSUF) a2$(DLLSUF) -Wl,-rpath=. -o $(basename $@).exe && \ + $(CODESIGN) $(basename $@).exe && \ ./$(basename $@).exe 114_bound_signal.test: FLAGS += -b @@ -136,7 +139,7 @@ all test tests2.all: $(filter-out $(SKIP),$(TESTS)) @$(call T1,$<) $(T3) T1 = $(TCC) $(FLAGS) $(T2) $(ARGS) -T2 = $(if $(NORUN),$1 -o $(basename $@).exe && ./$(basename $@).exe,-run $1) +T2 = $(if $(NORUN),$1 -o $(basename $@).exe && $(CODESIGN) $(basename $@).exe && ./$(basename $@).exe,-run $1) T3 = $(FILTER) >$*.output 2>&1 || true \ && diff -Nbu $(filter %.expect,$^) $*.output \ && rm -f $*.output $(filter $*.expect,$(GEN-ALWAYS)) @@ -177,4 +180,4 @@ $(sort $(GEN-ALWAYS) $(UPDATE)) : force force: clean : - rm -f fred.txt *.output *.exe *.dll *.so *.def $(GEN-ALWAYS) + rm -f fred.txt *.output *.exe *.dll *.so *.dylib *.def $(GEN-ALWAYS)