From eb82efc14dd2ca813b969f4a27d908f459823796 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 1 Jul 2024 11:27:34 -0400 Subject: [PATCH 1/7] refactor: Improve Makefile similarity --- xsnap/makefiles/lin/xsnap-worker.mk | 5 ++--- xsnap/makefiles/lin/xsnap.mk | 5 ++--- xsnap/makefiles/mac/xsnap-worker.mk | 4 ++-- xsnap/makefiles/mac/xsnap.mk | 6 +++--- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/xsnap/makefiles/lin/xsnap-worker.mk b/xsnap/makefiles/lin/xsnap-worker.mk index 3575557..dd95698 100644 --- a/xsnap/makefiles/lin/xsnap-worker.mk +++ b/xsnap/makefiles/lin/xsnap-worker.mk @@ -24,6 +24,8 @@ PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME) +LIBRARIES = -ldl -lm -lpthread + C_OPTIONS = \ -fno-common \ -DINCLUDE_XSPLATFORM \ @@ -56,9 +58,6 @@ ifeq ($(GOAL),debug) else C_OPTIONS += -O3 endif - -LIBRARIES = -ldl -lm -lpthread - ifeq ($(XSNAP_RANDOM_INIT),1) LIBRARIES += -lbsd C_OPTIONS += -DmxSnapshotRandomInit diff --git a/xsnap/makefiles/lin/xsnap.mk b/xsnap/makefiles/lin/xsnap.mk index d6860af..a897cb7 100644 --- a/xsnap/makefiles/lin/xsnap.mk +++ b/xsnap/makefiles/lin/xsnap.mk @@ -18,6 +18,8 @@ PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME) +LIBRARIES = -ldl -lm -lpthread + C_OPTIONS = \ -fno-common \ -DINCLUDE_XSPLATFORM \ @@ -45,9 +47,6 @@ ifeq ($(GOAL),debug) else C_OPTIONS += -DmxBoundsCheck=1 -O3 endif - -LIBRARIES = -ldl -lm -lpthread - ifeq ($(XSNAP_RANDOM_INIT),1) LIBRARIES += -lbsd C_OPTIONS += -DmxSnapshotRandomInit diff --git a/xsnap/makefiles/mac/xsnap-worker.mk b/xsnap/makefiles/mac/xsnap-worker.mk index 80dd47c..3e5be05 100644 --- a/xsnap/makefiles/mac/xsnap-worker.mk +++ b/xsnap/makefiles/mac/xsnap-worker.mk @@ -27,6 +27,8 @@ TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) MACOS_ARCH ?= MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 +LIBRARIES = -framework CoreServices + C_OPTIONS = \ -fno-common \ $(MACOS_ARCH) \ @@ -65,8 +67,6 @@ ifeq ($(XSNAP_RANDOM_INIT),1) C_OPTIONS += -DmxSnapshotRandomInit endif -LIBRARIES = -framework CoreServices - LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH) ifneq ("x$(SDKROOT)", "x") LINK_OPTIONS += -isysroot $(SDKROOT) diff --git a/xsnap/makefiles/mac/xsnap.mk b/xsnap/makefiles/mac/xsnap.mk index 5c784e8..6b5e2a0 100644 --- a/xsnap/makefiles/mac/xsnap.mk +++ b/xsnap/makefiles/mac/xsnap.mk @@ -21,6 +21,8 @@ TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) MACOS_ARCH ?= MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 +LIBRARIES = -framework CoreServices + C_OPTIONS = \ -fno-common \ $(MACOS_ARCH) \ @@ -54,8 +56,6 @@ ifeq ($(XSNAP_RANDOM_INIT),1) C_OPTIONS += -DmxSnapshotRandomInit endif -LIBRARIES = -framework CoreServices - LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH) ifneq ("x$(SDKROOT)", "x") LINK_OPTIONS += -isysroot $(SDKROOT) @@ -132,7 +132,7 @@ $(BIN_DIR): $(BIN_DIR)/$(NAME): $(OBJECTS) @echo "#" $(NAME) $(GOAL) ": cc" $(@F) - $(CC) $(LINK_OPTIONS) $(LIBRARIES) $(OBJECTS) -o $@ + $(CC) $(LINK_OPTIONS) $(OBJECTS) $(LIBRARIES) -o $@ $(OBJECTS): $(TLS_DIR)/xsnap.h $(OBJECTS): $(TLS_DIR)/xsnapPlatform.h From fdab8da7d1cb8e5316198b654c3390f3d7960db6 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 8 Jul 2024 15:23:44 -0400 Subject: [PATCH 2/7] refactor: Build `xsnap` executables in local directories rather than under a MODDABLE dependency This aligns with the `xsnap-worker` build process. --- xsnap/makefiles/lin/xsnap-worker.mk | 4 ---- xsnap/makefiles/lin/xsnap.mk | 4 ++-- xsnap/makefiles/mac/xsnap-worker.mk | 4 ---- xsnap/makefiles/mac/xsnap.mk | 4 ++-- 4 files changed, 4 insertions(+), 12 deletions(-) diff --git a/xsnap/makefiles/lin/xsnap-worker.mk b/xsnap/makefiles/lin/xsnap-worker.mk index dd95698..022fd7f 100644 --- a/xsnap/makefiles/lin/xsnap-worker.mk +++ b/xsnap/makefiles/lin/xsnap-worker.mk @@ -9,13 +9,9 @@ endif EXTRA_DEPS = -# MODDABLE = $(CURDIR)/../../moddable BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources -# BUILD_DIR = $(MODDABLE)/build -# TLS_DIR = ../../sources - XS_DIR = $(MODDABLE)/xs BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL) diff --git a/xsnap/makefiles/lin/xsnap.mk b/xsnap/makefiles/lin/xsnap.mk index a897cb7..6ec4885 100644 --- a/xsnap/makefiles/lin/xsnap.mk +++ b/xsnap/makefiles/lin/xsnap.mk @@ -7,8 +7,8 @@ ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -BUILD_DIR = $(MODDABLE)/build -TLS_DIR = ../../sources +BUILD_DIR = $(CURDIR)/../../build +TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs diff --git a/xsnap/makefiles/mac/xsnap-worker.mk b/xsnap/makefiles/mac/xsnap-worker.mk index 3e5be05..084b6fc 100644 --- a/xsnap/makefiles/mac/xsnap-worker.mk +++ b/xsnap/makefiles/mac/xsnap-worker.mk @@ -9,13 +9,9 @@ endif EXTRA_DEPS = -# MODDABLE = $(CURDIR)/../../moddable BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources -# BUILD_DIR = $(MODDABLE)/build -# TLS_DIR = ../../sources - XS_DIR = $(MODDABLE)/xs BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL) diff --git a/xsnap/makefiles/mac/xsnap.mk b/xsnap/makefiles/mac/xsnap.mk index 6b5e2a0..d3c3eb8 100644 --- a/xsnap/makefiles/mac/xsnap.mk +++ b/xsnap/makefiles/mac/xsnap.mk @@ -7,8 +7,8 @@ ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -BUILD_DIR = $(MODDABLE)/build -TLS_DIR = ../../sources +BUILD_DIR = $(CURDIR)/../../build +TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs From 3a174c6d01aaacb496775e9fae24bd8cf60c0f36 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 8 Jul 2024 15:25:40 -0400 Subject: [PATCH 3/7] refactor: Support EXTRA_DEPS for building `xsnap` executables This aligns with the `xsnap-worker` build process. --- xsnap/makefiles/lin/xsnap.mk | 3 +++ xsnap/makefiles/mac/xsnap.mk | 3 +++ 2 files changed, 6 insertions(+) diff --git a/xsnap/makefiles/lin/xsnap.mk b/xsnap/makefiles/lin/xsnap.mk index 6ec4885..654af7b 100644 --- a/xsnap/makefiles/lin/xsnap.mk +++ b/xsnap/makefiles/lin/xsnap.mk @@ -7,6 +7,8 @@ ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif +EXTRA_DEPS = + BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources @@ -132,6 +134,7 @@ $(OBJECTS): $(SRC_DIR)/xsAll.h $(OBJECTS): $(SRC_DIR)/xsScript.h $(OBJECTS): $(SRC_DIR)/xsSnapshot.h $(OBJECTS): $(INC_DIR)/xs.h +$(OBJECTS): $(EXTRA_DEPS) $(TMP_DIR)/%.o: %.c @echo "#" $(NAME) $(GOAL) ": cc" $( Date: Mon, 8 Jul 2024 16:04:38 -0400 Subject: [PATCH 4/7] style: Differentiate Makefile variables as constant vs. required vs. optional --- xsnap/makefiles/lin/xsnap-worker.mk | 14 +++++++++++--- xsnap/makefiles/lin/xsnap.mk | 13 ++++++++++--- xsnap/makefiles/mac/xsnap-worker.mk | 19 +++++++++++++------ xsnap/makefiles/mac/xsnap.mk | 18 ++++++++++++------ 4 files changed, 46 insertions(+), 18 deletions(-) diff --git a/xsnap/makefiles/lin/xsnap-worker.mk b/xsnap/makefiles/lin/xsnap-worker.mk index 022fd7f..26b844a 100644 --- a/xsnap/makefiles/lin/xsnap-worker.mk +++ b/xsnap/makefiles/lin/xsnap-worker.mk @@ -1,14 +1,22 @@ % : %.c %.o : %.c -GOAL ?= debug +# CONSTANTS NAME = xsnap-worker + +# REQUIRED INPUTS +MODDABLE = # /path/to/moddable/repo +XSNAP_VERSION = + +# OPTIONAL INPUTS +GOAL ?= debug +EXTRA_DEPS = +VERBOSE = + ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -EXTRA_DEPS = - BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources diff --git a/xsnap/makefiles/lin/xsnap.mk b/xsnap/makefiles/lin/xsnap.mk index 654af7b..529e3b6 100644 --- a/xsnap/makefiles/lin/xsnap.mk +++ b/xsnap/makefiles/lin/xsnap.mk @@ -1,14 +1,21 @@ % : %.c %.o : %.c -GOAL ?= debug +# CONSTANTS NAME = xsnap + +# REQUIRED INPUTS +MODDABLE = # /path/to/moddable/repo + +# OPTIONAL INPUTS +GOAL ?= debug +EXTRA_DEPS = +VERBOSE = + ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -EXTRA_DEPS = - BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources diff --git a/xsnap/makefiles/mac/xsnap-worker.mk b/xsnap/makefiles/mac/xsnap-worker.mk index 084b6fc..34664ae 100644 --- a/xsnap/makefiles/mac/xsnap-worker.mk +++ b/xsnap/makefiles/mac/xsnap-worker.mk @@ -1,14 +1,24 @@ % : %.c %.o : %.c -GOAL ?= debug +# CONSTANTS NAME = xsnap-worker + +# REQUIRED INPUTS +MODDABLE = # /path/to/moddable/repo +XSNAP_VERSION = + +# OPTIONAL INPUTS +GOAL ?= debug +EXTRA_DEPS = +VERBOSE = +MACOS_ARCH ?= +MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 + ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -EXTRA_DEPS = - BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources @@ -20,9 +30,6 @@ PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) -MACOS_ARCH ?= -MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 - LIBRARIES = -framework CoreServices C_OPTIONS = \ diff --git a/xsnap/makefiles/mac/xsnap.mk b/xsnap/makefiles/mac/xsnap.mk index 68e3acf..7250bba 100644 --- a/xsnap/makefiles/mac/xsnap.mk +++ b/xsnap/makefiles/mac/xsnap.mk @@ -1,14 +1,23 @@ % : %.c %.o : %.c -GOAL ?= debug +# CONSTANTS NAME = xsnap + +# REQUIRED INPUTS +MODDABLE = # /path/to/moddable/repo + +# OPTIONAL INPUTS +GOAL ?= debug +EXTRA_DEPS = +VERBOSE = +MACOS_ARCH ?= +MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 + ifneq ($(VERBOSE),1) MAKEFLAGS += --silent endif -EXTRA_DEPS = - BUILD_DIR = $(CURDIR)/../../build TLS_DIR = $(CURDIR)/../../sources @@ -20,9 +29,6 @@ PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) -MACOS_ARCH ?= -MACOS_VERSION_MIN ?= -mmacosx-version-min=10.7 - LIBRARIES = -framework CoreServices C_OPTIONS = \ From 3b8a0484ff4b72ed1a5f430d237b9da9e4e5f5d1 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 8 Jul 2024 16:25:17 -0400 Subject: [PATCH 5/7] feat: Provide helpful errors when required Makefile inputs are missing --- xsnap/makefiles/lin/xsnap-worker.mk | 4 ++++ xsnap/makefiles/lin/xsnap.mk | 4 ++++ xsnap/makefiles/mac/xsnap-worker.mk | 4 ++++ xsnap/makefiles/mac/xsnap.mk | 4 ++++ 4 files changed, 16 insertions(+) diff --git a/xsnap/makefiles/lin/xsnap-worker.mk b/xsnap/makefiles/lin/xsnap-worker.mk index 26b844a..6a928a1 100644 --- a/xsnap/makefiles/lin/xsnap-worker.mk +++ b/xsnap/makefiles/lin/xsnap-worker.mk @@ -150,8 +150,12 @@ $(OBJECTS): $(INC_DIR)/xs.h $(OBJECTS): $(EXTRA_DEPS) $(TMP_DIR)/%.o: %.c @echo "#" $(NAME) $(GOAL) ": cc" $( Date: Mon, 8 Jul 2024 16:45:59 -0400 Subject: [PATCH 6/7] refactor: Improve Makefile similarity across platform and executable-name dimensions --- xsnap/makefiles/lin/xsnap-worker.mk | 15 ++++++++------- xsnap/makefiles/lin/xsnap.mk | 15 ++++++++------- xsnap/makefiles/mac/xsnap-worker.mk | 15 ++++++++------- xsnap/makefiles/mac/xsnap.mk | 15 ++++++++------- 4 files changed, 32 insertions(+), 28 deletions(-) diff --git a/xsnap/makefiles/lin/xsnap-worker.mk b/xsnap/makefiles/lin/xsnap-worker.mk index 6a928a1..1900da9 100644 --- a/xsnap/makefiles/lin/xsnap-worker.mk +++ b/xsnap/makefiles/lin/xsnap-worker.mk @@ -3,6 +3,7 @@ # CONSTANTS NAME = xsnap-worker +PLATFORM = lin # REQUIRED INPUTS MODDABLE = # /path/to/moddable/repo @@ -10,6 +11,7 @@ XSNAP_VERSION = # OPTIONAL INPUTS GOAL ?= debug +# GOAL ?= release EXTRA_DEPS = VERBOSE = @@ -22,11 +24,11 @@ TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs -BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL) +BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL) INC_DIR = $(XS_DIR)/includes PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources -TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME) +TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME) LIBRARIES = -ldl -lm -lpthread @@ -120,7 +122,7 @@ OBJECTS = \ $(TMP_DIR)/textencoder.o \ $(TMP_DIR)/modBase64.o \ $(TMP_DIR)/xsnapPlatform.o \ - $(TMP_DIR)/xsnap-worker.o + $(TMP_DIR)/$(NAME).o VPATH += $(SRC_DIR) $(TLS_DIR) VPATH += $(MODDABLE)/modules/data/text/decoder @@ -157,7 +159,6 @@ $(TMP_DIR)/%.o: %.c @$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required)) clean: - rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME) - rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME) - rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME) - rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME) + # Remove files for all values of $(GOAL). + rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME) + rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME) diff --git a/xsnap/makefiles/lin/xsnap.mk b/xsnap/makefiles/lin/xsnap.mk index e60c118..d519105 100644 --- a/xsnap/makefiles/lin/xsnap.mk +++ b/xsnap/makefiles/lin/xsnap.mk @@ -3,12 +3,14 @@ # CONSTANTS NAME = xsnap +PLATFORM = lin # REQUIRED INPUTS MODDABLE = # /path/to/moddable/repo # OPTIONAL INPUTS GOAL ?= debug +# GOAL ?= release EXTRA_DEPS = VERBOSE = @@ -21,11 +23,11 @@ TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs -BIN_DIR = $(BUILD_DIR)/bin/lin/$(GOAL) +BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL) INC_DIR = $(XS_DIR)/includes PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources -TMP_DIR = $(BUILD_DIR)/tmp/lin/$(GOAL)/$(NAME) +TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME) LIBRARIES = -ldl -lm -lpthread @@ -114,7 +116,7 @@ OBJECTS = \ $(TMP_DIR)/textencoder.o \ $(TMP_DIR)/modBase64.o \ $(TMP_DIR)/xsnapPlatform.o \ - $(TMP_DIR)/xsnap.o + $(TMP_DIR)/$(NAME).o VPATH += $(SRC_DIR) $(TLS_DIR) VPATH += $(MODDABLE)/modules/data/text/decoder @@ -151,7 +153,6 @@ $(TMP_DIR)/%.o: %.c @$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required)) clean: - rm -rf $(BUILD_DIR)/bin/lin/debug/$(NAME) - rm -rf $(BUILD_DIR)/bin/lin/release/$(NAME) - rm -rf $(BUILD_DIR)/tmp/lin/debug/$(NAME) - rm -rf $(BUILD_DIR)/tmp/lin/release/$(NAME) + # Remove files for all values of $(GOAL). + rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME) + rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME) diff --git a/xsnap/makefiles/mac/xsnap-worker.mk b/xsnap/makefiles/mac/xsnap-worker.mk index b3e1011..854d6f6 100644 --- a/xsnap/makefiles/mac/xsnap-worker.mk +++ b/xsnap/makefiles/mac/xsnap-worker.mk @@ -3,6 +3,7 @@ # CONSTANTS NAME = xsnap-worker +PLATFORM = mac # REQUIRED INPUTS MODDABLE = # /path/to/moddable/repo @@ -10,6 +11,7 @@ XSNAP_VERSION = # OPTIONAL INPUTS GOAL ?= debug +# GOAL ?= release EXTRA_DEPS = VERBOSE = MACOS_ARCH ?= @@ -24,11 +26,11 @@ TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs -BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL) +BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL) INC_DIR = $(XS_DIR)/includes PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources -TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) +TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME) LIBRARIES = -framework CoreServices @@ -129,7 +131,7 @@ OBJECTS = \ $(TMP_DIR)/textencoder.o \ $(TMP_DIR)/modBase64.o \ $(TMP_DIR)/xsnapPlatform.o \ - $(TMP_DIR)/xsnap-worker.o + $(TMP_DIR)/$(NAME).o VPATH += $(SRC_DIR) $(TLS_DIR) VPATH += $(MODDABLE)/modules/data/text/decoder @@ -166,7 +168,6 @@ $(TMP_DIR)/%.o: %.c @$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required)) clean: - rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME) - rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME) - rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME) - rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME) + # Remove files for all values of $(GOAL). + rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME) + rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME) diff --git a/xsnap/makefiles/mac/xsnap.mk b/xsnap/makefiles/mac/xsnap.mk index 1a7c913..ff07038 100644 --- a/xsnap/makefiles/mac/xsnap.mk +++ b/xsnap/makefiles/mac/xsnap.mk @@ -3,12 +3,14 @@ # CONSTANTS NAME = xsnap +PLATFORM = mac # REQUIRED INPUTS MODDABLE = # /path/to/moddable/repo # OPTIONAL INPUTS GOAL ?= debug +# GOAL ?= release EXTRA_DEPS = VERBOSE = MACOS_ARCH ?= @@ -23,11 +25,11 @@ TLS_DIR = $(CURDIR)/../../sources XS_DIR = $(MODDABLE)/xs -BIN_DIR = $(BUILD_DIR)/bin/mac/$(GOAL) +BIN_DIR = $(BUILD_DIR)/bin/$(PLATFORM)/$(GOAL) INC_DIR = $(XS_DIR)/includes PLT_DIR = $(XS_DIR)/platforms SRC_DIR = $(XS_DIR)/sources -TMP_DIR = $(BUILD_DIR)/tmp/mac/$(GOAL)/$(NAME) +TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME) LIBRARIES = -framework CoreServices @@ -123,7 +125,7 @@ OBJECTS = \ $(TMP_DIR)/textencoder.o \ $(TMP_DIR)/modBase64.o \ $(TMP_DIR)/xsnapPlatform.o \ - $(TMP_DIR)/xsnap.o + $(TMP_DIR)/$(NAME).o VPATH += $(SRC_DIR) $(TLS_DIR) VPATH += $(MODDABLE)/modules/data/text/decoder @@ -160,7 +162,6 @@ $(TMP_DIR)/%.o: %.c @$(if $(MODDABLE),,$(error MODDABLE=/path/to/moddable/repo is required)) clean: - rm -rf $(BUILD_DIR)/bin/mac/debug/$(NAME) - rm -rf $(BUILD_DIR)/bin/mac/release/$(NAME) - rm -rf $(BUILD_DIR)/tmp/mac/debug/$(NAME) - rm -rf $(BUILD_DIR)/tmp/mac/release/$(NAME) + # Remove files for all values of $(GOAL). + rm -rf $(BUILD_DIR)/bin/$(PLATFORM)/*/$(NAME) + rm -rf $(BUILD_DIR)/tmp/$(PLATFORM)/*/$(NAME) From c9dc03c7130fcfe2e8061602b32919165d00f9b0 Mon Sep 17 00:00:00 2001 From: Richard Gibson Date: Mon, 8 Jul 2024 16:56:41 -0400 Subject: [PATCH 7/7] refactor: Remove duplicated Makefile conditions --- xsnap/makefiles/mac/xsnap.mk | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/xsnap/makefiles/mac/xsnap.mk b/xsnap/makefiles/mac/xsnap.mk index ff07038..914ad14 100644 --- a/xsnap/makefiles/mac/xsnap.mk +++ b/xsnap/makefiles/mac/xsnap.mk @@ -33,6 +33,11 @@ TMP_DIR = $(BUILD_DIR)/tmp/$(PLATFORM)/$(GOAL)/$(NAME) LIBRARIES = -framework CoreServices +SHARED_OPTIONS = +ifneq ("x$(SDKROOT)", "x") + SHARED_OPTIONS += -isysroot $(SDKROOT) +endif + C_OPTIONS = \ -fno-common \ $(MACOS_ARCH) \ @@ -53,10 +58,8 @@ C_OPTIONS = \ -I$(PLT_DIR) \ -I$(SRC_DIR) \ -I$(TLS_DIR) \ - -I$(TMP_DIR) -ifneq ("x$(SDKROOT)", "x") - C_OPTIONS += -isysroot $(SDKROOT) -endif + -I$(TMP_DIR) \ + $(SHARED_OPTIONS) ifeq ($(GOAL),debug) C_OPTIONS += -DmxDebug=1 -g -O0 -Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter else @@ -66,10 +69,7 @@ ifeq ($(XSNAP_RANDOM_INIT),1) C_OPTIONS += -DmxSnapshotRandomInit endif -LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH) -ifneq ("x$(SDKROOT)", "x") - LINK_OPTIONS += -isysroot $(SDKROOT) -endif +LINK_OPTIONS = $(MACOS_VERSION_MIN) $(MACOS_ARCH) $(SHARED_OPTIONS) # C_OPTIONS += -fsanitize=address -fno-omit-frame-pointer # LINK_OPTIONS += -fsanitize=address -fno-omit-frame-pointer