From: Ian Jackson Date: Sat, 10 Oct 2020 19:30:23 +0000 (+0100) Subject: wip makefile X-Git-Tag: otter-0.2.0~714 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=07051d2ade0b0ab8a3adaa4d8b1b6e149cabedf3;p=otter.git wip makefile Signed-off-by: Ian Jackson --- diff --git a/Makefile b/Makefile index 5010ec00..c80eeea1 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,7 @@ stamp=@mkdir -p stamp; touch $@ #---------- programs and config variables ---------- CARGO ?= cargo -CARGO_TARGET_DIR ?= target +TARGET_DIR ?= target USVG ?= usvg USVG_OPTIONS = "--sans-serif-family=DejaVu Sans" @@ -32,7 +32,7 @@ BUNDLE_SOURCES ?= bundle-rust-sources DEPLOY_ARCH=x86_64-unknown-linux-musl DEPLOY_RELEASE=debug -DEPLOY_TARGET_DIR=$(CARGO_TARGET_DIR)/$(addsuffix /,$(DEPLOY_ARCH))$(DEPLOY_RELEASE) +DEPLOY_TARGET_DIR=$(TARGET_DIR)/$(addsuffix /,$(DEPLOY_ARCH))$(DEPLOY_RELEASE) #---------- nailing-cargo ---------- @@ -41,16 +41,20 @@ ifneq (,$(wildcard(../Cargo.nail))) NAILING_CARGO = nailing-cargo CARGO = $(NAILING_CARGO) BUILD_SUBDIR ?= ../Build -CARGO_TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target +TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target BUNDLE_SOURCES_CMD ?= $(NAILING_CARGO) --- $(BUNDLE_SOURCES) USVG_CMD ?= $(NAILING_CARGO) --just-run -q --- $(USVG) +WASM_PACK_CMD ?= $(NAILING_CARGO) --linkfarm=git --- $(WASM_PACK) endif # Cargo.nail BUILD_SUBDIR ?= ../Build BUNDLE_SOURCES_CMD ?= $(BUNDLE_SOURCES) -USVG_CMD ?= =$(USVG) +USVG_CMD ?= $(USVG) +WASM_PACK_CMD ?= $(WASM_PACK) + +WASM_PACKED=$(TARGET_DIR)/packed-wasm #---------- local programs ---------- @@ -88,7 +92,11 @@ cargo-%: stamp/cargo.% cargo-wasm: cargo-wasm-release -assets: templates/script.js libraries $(FILEASSETS) +wasm-pack: stamp/wasm-pack + +assets: js libraries $(FILEASSETS) + +js: templates/script.js extra-debug: extra-release: bundled-sources @@ -121,22 +129,19 @@ stamp/cargo.deploy-build: $(call rsrcs,.) WASM_ASSETS := $(addprefix otter_wasm,.js _bg.wasm) WASM_OUTPUTS := $(addprefix otter_wasm,.d.ts) -$(WASM_ASSETS) $(WASM_OUTPUTS): wasm-pack -.PHONY: wasm-pack -wasm-pack: cargo/wasm-release - -real/wasm-pack: - -wasm-pack: - $(MAKE) real/$@ +$(addprefix $(WASM_PACKED)/,$(WASM_ASSETS) $(WASM_OUTPUTS)): stamp/wasm-pack +stamp/wasm-pack: stamp/cargo.wasm-release + $(WASM_PACK_CMD) $(WASM_PACK_OPTIONS) build \ + --out-dir=../target/packed-wasm wasm -t no-modules --release + $(stamp) #---------- bundle-sources ---------- -bundled-sources: $(CARGO_TARGET_DIR)/bundled-sources -$(CARGO_TARGET_DIR)/bundled-sources: $(BUNDLE_SOURCES) +bundled-sources: $(TARGET_DIR)/bundled-sources +$(TARGET_DIR)/bundled-sources: $(BUNDLE_SOURCES) $(BUNDLE_SOURCES_CMD) --output $(abspath $@) @echo Bundled sources. -.PHONY: bundle-sources $(CARGO_TARGET_DIR)/bundled-sources +.PHONY: bundle-sources $(TARGET_DIR)/bundled-sources #---------- svg processing ---------- @@ -151,7 +156,10 @@ $(LIBRARY_FILES): $(USVG_PROCESSOR) $(USVG_BINARY) Makefile #---------- typescript ---------- TS_SRCS= script bigfloat -TS_SRC_FILES= $(addprefix templates/,$(addsuffix .ts,$(TS_SRCS))) +TS_SRC_FILES= \ + ../webassembly-types/webassembly.d.ts \ + $(addprefix $(WASM_PACKED)/,otter_wasm.d.ts) \ + $(addprefix templates/,$(addsuffix .ts,$(TS_SRCS))) LITFILES= LICENCE AGPLv3 TXTFILES= CC-BY-SA-3.0 CC-BY-SA-4.0 @@ -186,7 +194,7 @@ DEPLOY_BASE=Otter@login.chiark.greenend.org.uk:/volatile/Otter deploy: stamp/cargo.deploy-build bundled-sources rsync -zv --progress $(addprefix $(DEPLOY_TARGET_DIR)/,$(PROGRAMS)) $(DEPLOY_BASE)/bin/ - rsync -rv --progress $(CARGO_TARGET_DIR)/bundled-sources/. $(DEPLOY_BASE)/bundled-sources + rsync -rv --progress $(TARGET_DIR)/bundled-sources/. $(DEPLOY_BASE)/bundled-sources #---------- clean ----------