From 4f2d2143f9d05cfbf8758a7d3854680ad095e3ab Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Tue, 4 Mar 2025 21:57:59 +0100 Subject: [PATCH 1/2] Add amalgamation Makefile target Also include quickjs-libc.h, otherwise downstream users can compile but not call its functions. --- .github/workflows/ci.yml | 3 ++- .github/workflows/release.yml | 4 +--- Makefile | 9 ++++++++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0c11e626e..002fd763c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -582,9 +582,10 @@ jobs: make - name: create amalgamation run: | - build/qjs amalgam.js $RUNNER_TEMP/quickjs-amalgam.c + make amalgam - name: build amalgamation run: | + unzip -d $RUNNER_TEMP build/quickjs-amalgam.zip cc -Wall -I. -o $RUNNER_TEMP/run-test262.o -c run-test262.c cc -Wall -I/ -DQJS_BUILD_LIBC -o $RUNNER_TEMP/quickjs-amalgam.o -c $RUNNER_TEMP/quickjs-amalgam.c cc -o $RUNNER_TEMP/run-test262 $RUNNER_TEMP/run-test262.o $RUNNER_TEMP/quickjs-amalgam.o -lm diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7f137d4df..fc433c43d 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -50,9 +50,7 @@ jobs: cd build cmake -DCMAKE_OSX_ARCHITECTURES="x86_64;arm64" .. make -j$(getconf _NPROCESSORS_ONLN) - (cd .. && build/qjs amalgam.js build/quickjs-amalgam.c) - cp ../quickjs.h . - zip -9 quickjs-amalgam.zip quickjs-amalgam.c quickjs.h + make -C .. amalgam # writes build/quickjs-amalgam.zip mv qjs qjs-darwin mv qjsc qjsc-darwin - name: check diff --git a/Makefile b/Makefile index 982ce16c3..a4db8bd9c 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,13 @@ endif all: $(QJS) +amalgam: TEMP := $(shell mktemp -d) +amalgam: $(QJS) + $(QJS) amalgam.js $(TEMP)/quickjs-amalgam.c + cp quickjs.h quickjs-libc.h $(TEMP) + cd $(TEMP) && zip -9 quickjs-amalgam.zip quickjs-amalgam.c quickjs.h quickjs-libc.h + cp $(TEMP)/quickjs-amalgam.zip $(BUILD_DIR) + fuzz: clang -g -O1 -fsanitize=address,undefined,fuzzer -o fuzz fuzz.c ./fuzz @@ -117,4 +124,4 @@ unicode_gen: $(BUILD_DIR) libunicode-table.h: unicode_gen $(BUILD_DIR)/unicode_gen unicode $@ -.PHONY: all ctest cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC) +.PHONY: all amalgam ctest cxxtest debug fuzz install clean codegen distclean stats test test262 test262-update test262-check microbench unicode_gen $(QJS) $(QJSC) From a56543efe2cf5533510cff85ff1485f62f8acb35 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 5 Mar 2025 10:49:20 +0100 Subject: [PATCH 2/2] squash! rm tmpdir --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index a4db8bd9c..403461dad 100644 --- a/Makefile +++ b/Makefile @@ -51,6 +51,8 @@ amalgam: $(QJS) cp quickjs.h quickjs-libc.h $(TEMP) cd $(TEMP) && zip -9 quickjs-amalgam.zip quickjs-amalgam.c quickjs.h quickjs-libc.h cp $(TEMP)/quickjs-amalgam.zip $(BUILD_DIR) + cd $(TEMP) && $(RM) quickjs-amalgam.zip quickjs-amalgam.c quickjs.h quickjs-libc.h + $(RM) -d $(TEMP) fuzz: clang -g -O1 -fsanitize=address,undefined,fuzzer -o fuzz fuzz.c