mirror of
https://github.com/GoogleChromeLabs/squoosh.git
synced 2025-11-16 18:49:50 +00:00
Use a shared base image with fixed Emscripten version, autotools and optimisation flags for all C++ codecs. Additionally, move build commands for codecs themselves to Makefile - they're already platform-specific, and Make allows for better caching and parallelisation that custom ad-hoc scripts. This is essentially same as #777 but for C++.
34 lines
702 B
Makefile
34 lines
702 B
Makefile
CODEC_DIR := node_modules/libimagequant
|
|
CODEC_OUT_RELATIVE := libimagequant.a
|
|
CODEC_OUT := $(addprefix $(CODEC_DIR)/, $(CODEC_OUT_RELATIVE))
|
|
OUT_JS := imagequant.js
|
|
OUT_WASM := $(OUT_JS:.js=.wasm)
|
|
|
|
.PHONY: all clean
|
|
|
|
all: $(OUT_JS)
|
|
|
|
%.js: %.cpp $(CODEC_OUT)
|
|
$(CXX) \
|
|
-I $(CODEC_DIR) \
|
|
${CXXFLAGS} \
|
|
${LDFLAGS} \
|
|
--bind \
|
|
--closure 1 \
|
|
-s ALLOW_MEMORY_GROWTH=1 \
|
|
-s MODULARIZE=1 \
|
|
-s 'EXPORT_NAME="$(basename $(@F))"' \
|
|
-o $@ \
|
|
$+
|
|
|
|
$(CODEC_OUT): $(CODEC_DIR)/config.mk
|
|
$(MAKE) -C $(CODEC_DIR) $(CODEC_OUT_RELATIVE)
|
|
|
|
$(CODEC_DIR)/config.mk: $(CODEC_DIR)/configure
|
|
cd $(CODEC_DIR) && ./configure \
|
|
--disable-sse
|
|
|
|
clean:
|
|
$(RM) $(OUT_JS) $(OUT_WASM)
|
|
$(MAKE) -C $(CODEC_DIR) clean
|