From 7bdceca9ddfaa5d35d2cbcf459242478e786a5b5 Mon Sep 17 00:00:00 2001 From: Stefano D'Angelo Date: Sat, 4 Jan 2025 09:50:15 +0100 Subject: [PATCH] modular strip (except android yet, ios, daisy-seed) --- templates/cmd-make/Makefile | 10 +++++++--- templates/lv2-make/Makefile | 8 ++++++-- templates/vst3-make/Makefile | 11 +++++++---- templates/web-demo/rules-extra-web-demo.mk | 6 ++++++ templates/web-demo/vars-extra-web-demo.mk | 4 ++++ templates/web-make/Makefile | 12 ++++++------ 6 files changed, 36 insertions(+), 15 deletions(-) diff --git a/templates/cmd-make/Makefile b/templates/cmd-make/Makefile index 606462e..8e4265c 100644 --- a/templates/cmd-make/Makefile +++ b/templates/cmd-make/Makefile @@ -78,6 +78,10 @@ DIRS := build build/obj ALL := build/$(PROGRAM) +STRIP_ALL := build/$(PROGRAM) +STRIP_PHONY := +STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY) + -include $(MKINC_DIR)/vars-extra.mk all: $(ALL) @@ -96,17 +100,17 @@ $(DIRS): clean: rm -fr build -strip: all +strip: $(STRIP_PREREQS) strip build/$(PROGRAM) ifeq ($(OS), Windows_NT) -.PHONY: all clean +.PHONY: all clean strip $(STRIP_PHONY) else install: all mkdir -m 0755 -p $(BINDIR) install -m 0755 build/$(PROGRAM) $(BINDIR) -.PHONY: all clean strip install +.PHONY: all clean strip $(STRIP_PHONY) install endif -include $(MKINC_DIR)/rules-extra.mk diff --git a/templates/lv2-make/Makefile b/templates/lv2-make/Makefile index c67caf7..aae0ee8 100644 --- a/templates/lv2-make/Makefile +++ b/templates/lv2-make/Makefile @@ -92,6 +92,10 @@ DIRS := build build/$(BUNDLE_DIR) build/obj ALL := build/$(BUNDLE_DIR)/manifest.ttl build/$(BUNDLE_DIR)/$(DLL_FILE) +STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE) build/$(BUNDLE_DIR)/manifest.ttl +STRIP_PHONY := +STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY) + -include $(MKINC_DIR)/vars-extra.mk all: $(ALL) @@ -113,7 +117,7 @@ $(DIRS): clean: rm -fr build -strip: all +strip: $(STRIP_PREREQS) strip build/$(BUNDLE_DIR)/$(DLL_FILE) #Reaper can't handle this #rdfproc lv2_store parse build/$(BUNDLE_DIR)/manifest.ttl turtle || (rm lv2_store* && exit 1) @@ -150,7 +154,7 @@ install-user: all -include $(MKINC_DIR)/rules-extra.mk -.PHONY: all clean strip install install-user +.PHONY: all clean strip $(STRIP_PHONY) install install-user .SECONDEXPANSION: diff --git a/templates/vst3-make/Makefile b/templates/vst3-make/Makefile index 20d8456..8a8245a 100644 --- a/templates/vst3-make/Makefile +++ b/templates/vst3-make/Makefile @@ -113,11 +113,14 @@ CXX_OBJS := $(addprefix build/obj/, $(notdir $(CXX_SRCS:.cpp=.o))) DIRS := build build/obj build/$(BUNDLE_DIR) build/$(BUNDLE_DIR)/Contents build/$(BUNDLE_DIR)/Contents/Resources build/$(BUNDLE_DIR)/$(DLL_DIR) ALL := build/$(BUNDLE_DIR)/$(DLL_FILE) - ifeq ($(UNAME_S), Darwin) -ALL := $(ALL) build/$(BUNDLE_DIR)/Contents/Info.plist build/$(BUNDLE_DIR)/Contents/PkgInfo + ALL := $(ALL) build/$(BUNDLE_DIR)/Contents/Info.plist build/$(BUNDLE_DIR)/Contents/PkgInfo endif +STRIP_ALL := build/$(BUNDLE_DIR)/$(DLL_FILE) +STRIP_PHONY := +STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY) + -include $(MKINC_DIR)/vars-extra.mk all: $(ALL) @@ -144,7 +147,7 @@ $(DIRS): clean: rm -fr build -strip: all +strip: $(STRIP_PREREQS) strip build/$(BUNDLE_DIR)/$(DLL_FILE) install: all @@ -177,7 +180,7 @@ install-user: all -include $(MKINC_DIR)/rules-extra.mk -.PHONY: all clean strip install install-user +.PHONY: all clean strip $(STRIP_PHONY) install install-user .SECONDEXPANSION: diff --git a/templates/web-demo/rules-extra-web-demo.mk b/templates/web-demo/rules-extra-web-demo.mk index 531a10a..3130085 100644 --- a/templates/web-demo/rules-extra-web-demo.mk +++ b/templates/web-demo/rules-extra-web-demo.mk @@ -25,3 +25,9 @@ build/web/key.pem: build/web/cert.pem build/web/cert.pem: | build yes "" | openssl req -x509 -newkey rsa:2048 -keyout build/web/key.pem -out build/web/cert.pem -days 365 -nodes 2>/dev/null + +strip-web-demo: build/web/index.html + $(eval TMP := $(shell mktemp /tmp/index.XXXXXX)) + html-minifier --collapse-whitespace --remove-comments --remove-redundant-attributes --remove-script-type-attributes --minify-css true --minify-js true build/web/index.html > $(TMP) || (rm $(TMP) && exit 1) + cp $(TMP) build/web/index.html || (rm $(TMP) && exit 1) + rm $(TMP) diff --git a/templates/web-demo/vars-extra-web-demo.mk b/templates/web-demo/vars-extra-web-demo.mk index 59f5792..93374ec 100644 --- a/templates/web-demo/vars-extra-web-demo.mk +++ b/templates/web-demo/vars-extra-web-demo.mk @@ -19,3 +19,7 @@ # ALL := $(ALL) build/web/index.html build/web/cert.pem build/web/key.pem + +STRIP_ALL := $(STRIP_ALL) build/web/index.html +STRIP_PHONY := strip-web-demo +STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY) diff --git a/templates/web-make/Makefile b/templates/web-make/Makefile index 8b2238f..4f1f839 100644 --- a/templates/web-make/Makefile +++ b/templates/web-make/Makefile @@ -85,6 +85,10 @@ DIRS := build build/obj build/web build/web/$(BUNDLE_NAME) ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js +STRIP_ALL := build/web/$(BUNDLE_NAME)/module.wasm build/web/$(BUNDLE_NAME)/processor.js build/web/$(BUNDLE_NAME)/module.js +STRIP_PHONY := +STRIP_PREREQS := $(STRIP_ALL) $(STRIP_PHONY) + -include $(MKINC_DIR)/vars-extra.mk all: $(ALL) @@ -109,19 +113,15 @@ $(DIRS): clean: rm -fr build -strip: +strip: $(STRIP_PREREQS) #already stripped #wasm-strip build/web/$(BUNDLE_NAME)/module.wasm uglifyjs -c pure_funcs -m reserved build/web/$(BUNDLE_NAME)/module.js -o build/web/$(BUNDLE_NAME)/module.js uglifyjs -c pure_funcs -m reserved build/web/$(BUNDLE_NAME)/processor.js -o build/web/$(BUNDLE_NAME)/processor.js - $(eval TMP := $(shell mktemp /tmp/index.XXXXXX)) - html-minifier --collapse-whitespace --remove-comments --remove-redundant-attributes --remove-script-type-attributes --minify-css true --minify-js true build/web/index.html > $(TMP) || (rm $(TMP) && exit 1) - cp $(TMP) build/web/index.html || (rm $(TMP) && exit 1) - rm $(TMP) -include $(MKINC_DIR)/rules-extra.mk -.PHONY: all clean strip +.PHONY: all clean strip $(STRIP_PHONY) .SECONDEXPANSION: