chiark / gitweb /
changelog: document further make-release changes
[otter.git] / Makefile
index 36f13aafb5eaae08b09cd145e3e4fa6bce154991..b316edc6c24eb3d62576a00f0d2026f622a88bd7 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -37,11 +37,8 @@ BUNDLED_SOURCES += $(BUNDLED_SOURCES_FILES)
 
 #---------- programs and config variables ----------
 
-CARGO ?= cargo
 TARGET_DIR ?= target
 
-USVG_OPTIONS = "--sans-serif-family=DejaVu Sans"
-
 WASM_BINDGEN = $(TARGET_DIR)/debug/wasm-bindgen
 WASM_BINDGEN_OPTIONS =                                         \
        --remove-name-section --remove-producers-section        \
@@ -49,7 +46,7 @@ WASM_BINDGEN_OPTIONS =                                                \
 
 BUNDLE_SOURCES ?= bundle-rust-sources
 
-SPHINXBUILD   = sphinx-build
+SPHINXBUILD   ?= sphinx-build
 
 ifndef INKSCAPE_EXTENSIONS
 INKSCAPE ?= inkscape
@@ -61,17 +58,21 @@ endif
 RECOLOUR_SVG ?= ./run-inkscape-extension $(INKSCAPE_EXTENSIONS)/color_replace.py
 
 DEPLOY_ARCH=x86_64-unknown-linux-musl
-DEPLOY_RELEASE=debug
+DEPLOY_RELEASE=release
 DEPLOY_TARGET_DIR=$(TARGET_DIR)/$(addsuffix /,$(DEPLOY_ARCH))$(DEPLOY_RELEASE)
 DEPLOYED_BRANCH=deployed
 PUBLISHED_BRANCH=published
 
+RUST_CLIPPY_OPTIONS ?= $(shell perl -pe 's/\#.*//; s/\n/ /' clippy-options)
+RUST_CLIPPY ?= clippy
+RUST_CLIPPY_CMD := clippy $(RUST_CLIPPY_OPTIONS)
+
 #---------- nailing-cargo ----------
 
 ifneq (,$(wildcard ../Cargo.nail))
 
-NAILING_CARGO = nailing-cargo
-CARGO = $(NAILING_CARGO)
+NAILING_CARGO ?= nailing-cargo
+CARGO_CMD ?= $(NAILING_CARGO)
 BUILD_SUBDIR ?= ../Build
 TARGET_DIR = $(BUILD_SUBDIR)/$(notdir $(PWD))/target
 
@@ -80,12 +81,16 @@ BUNDLE_SOURCES_CMD ?= $(NAILING_CARGO) --- $(BUNDLE_SOURCES)
 USVG_CMD ?= $(NAILING_CARGO_JUST_RUN) $(USVG)
 WASM_BINDGEN_CLI_CARGO_OPTS ?= --subcommand-props=!manifest-path
 
+CARGO_DOCUMENT_PRIVATE_ITEMS ?= --document-private-items
+CARGO_DOC_OPTS += $(CARGO_DOCUMENT_PRIVATE_ITEMS)
+
 clean-nailing:
        $(NAILING_CARGO_JUST_RUN) \
  sh -c 'cd "$1"; find -mindepth 1 -maxdepth 1 -print0 | xargs -0r rm -rf --' \
                $(abspath $(BUILD_SUBDIR)/$(notdir $(PWD)))
 
 else
+CARGO_CMD ?= cargo
 clean-nailing:
 endif # Cargo.nail
 
@@ -123,9 +128,11 @@ TS_SRC_FILES= \
 LITFILES= LICENCE AGPLv3
 TXTFILES= CC-BY-SA-3.0 CC-BY-SA-4.0
 
-FILEASSETS = $(addprefix templates/, libre shapelib.html script.js \
+NWTEMPLATEASSETS = nwtemplates/die-overlay.tera
+FILEASSETS =   $(addprefix templates/, libre shapelib.html script.js \
                        $(LITFILES) $(TXTFILES)) \
-               $(wildcard templates/*.tera)
+               $(wildcard templates/*.tera) \
+               $(NWTEMPLATEASSETS)
 
 WASM := wasm32-unknown-unknown
 # ^ todo: Is this still right after
@@ -134,6 +141,9 @@ WASM := wasm32-unknown-unknown
 # ?  But maybe it doesn't matter since we're very conservative and
 # only pass JsValue and a few strings across the WASM ABI.
 
+RUST_NIGHTLY_VERSION ?= +nightly
+CARGO = $(CARGO_CMD) $(RUST_VERSION)
+
 #---------- toplevel aggregate targets ----------
 
 check: stamp/cargo.debug-check at wdt jstest
@@ -180,6 +190,12 @@ cargo-syntaxcheck-wasm:
 cargo-syntaxcheck-release:
        $(CARGO) check --workspace --release
 
+cargo-clippy: cargo-clippy-host cargo-clippy-wasm
+cargo-clippy-host: clippy-options
+       $(CARGO) $(RUST_CLIPPY) --workspace $(RUST_CLIPPY_OPTIONS)
+cargo-clippy-wasm: clippy-options
+       $(CARGO) $(RUST_CLIPPY) --target $(WASM) -p otter-wasm $(RUST_CLIPPY_OPTIONS)
+
 #---------- cargo ----------
 
 DR=debug release
@@ -197,7 +213,8 @@ $(TARGET_DIR)/debug/%: $(call rsrcs, ! -path './wasm/*')
        $(NAILING_CARGO_JUST_RUN) touch $(abspath $@)
 
 stamp/cargo.wasm-bindgen: $(call rsrcs, ! -name \*.rs)
-       $(CARGO) $(WASM_BINDGEN_CLI_CARGO_OPTS) build --target-dir=target \
+       $(CARGO_CMD) $(WASM_BINDGEN_CLI_CARGO_OPTS) $(RUST_VERSION) \
+               build --target-dir=target \
                --manifest-path=$(abspath wasm/Cargo.toml) -p wasm-bindgen-cli
        $(stamp)
 
@@ -206,7 +223,8 @@ stamp/cargo.%-check: $(call rsrcs,.)
        $(stamp)
 
 stamp/cargo.%-miri: $(call rsrcs,.)
-       $(CARGO) miri test --workspace $(call cr,$*)
+       $(CARGO_CMD) $(RUST_NIGHTLY_VERSION) \
+               miri test --workspace $(call cr,$*)
        $(stamp)
 
 stamp/cargo-at.debug: $(call rsrcs,.)
@@ -223,7 +241,8 @@ stamp/cargo-jstest.debug: $(call rsrcs,.)
 
 stamp/cargo.doc: $(call rsrcs,.)
        set -o pipefail -e; \
-       $(CARGO) doc $(CARGO_DOC_OPTS) --workspace 2>&1 |egrep -vf .cargo-doc-suppress-errors
+       $(CARGO) doc $(CARGO_DOC_OPTS) --workspace 2>&1 \
+               |egrep -vf .cargo-doc-suppress-errors
        $(stamp)
 
 $(addprefix stamp/cargo.wasm-,$(DR)):: \
@@ -232,7 +251,7 @@ stamp/cargo.wasm-%: $(call rsrcs, base wasm Cargo.*)
        $(stamp)
 
 stamp/cargo.deploy-build: $(call rsrcs,.)
-       $(CARGO) build --target $(DEPLOY_ARCH) $(call cr,$(DEPLOY_RELEASE)) -p otter -p otter-cli -p otter-daemon
+       $(CARGO) build --target $(DEPLOY_ARCH) $(call cr,$(DEPLOY_RELEASE)) -p otter -p otter-cli -p otter-daemon -p usvg
        $(NAILING_CARGO_JUST_RUN) \
        ln -sf otter $(abspath $(TARGET_DIR)/$(DEPLOY_ARCH))/$(DEPLOY_RELEASE)/otter-ssh-proxy
        $(stamp)
@@ -322,7 +341,7 @@ bundled-sources::
 #---------- svg processing ----------
 
 LIBRARIES ?= $(basename $(wildcard library/*.toml))
-USVG_DEP = stamp/cargo.usvg
+USVG_DEP = stamp/cargo.usvg src/USVG_DEFAULT_ARGS.txt
 
 include $(addsuffix /files.make, $(LIBRARIES))
 
@@ -352,11 +371,19 @@ $(addprefix templates/,$(TXTFILES)): templates/%: %.txt
 
 libraries: $(LIBRARY_FILES)
 
-templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES)
+templates/shapelib.html: $(TARGET_DIR)/debug/otterlib $(LIBRARY_FILES) \
+                       $(NWTEMPLATEASSETS)
        $(NAILING_CARGO_JUST_RUN) $(abspath $<) \
+       --nwtemplates $(abspath nwtemplates) \
        --libs '$(addprefix $(PWD)/, $(addsuffix .toml, $(LIBRARIES)))' \
                preview >$@.tmp && mv -f $@.tmp $@
 
+nwtemplates/die-overlay.tera: dice/overlay-template-extractor dice/die.svg
+       ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
+
+library/edited/die-image-d6-_c.svg: dice/extract-image-only dice/die.svg
+       ./$< <dice/die.svg >$@.tmp && mv -f $@.tmp $@
+
 #---------- examples ----------
 
 EXAMPLE_BUNDLE_INPUT_DEPS := $(shell                                   \
@@ -384,7 +411,7 @@ examples/big-bundle/otter.toml: $(LIBRARY_FILES) $(MAKEFILE_DEP)
                perl -p \
  -e 'BEGIN { print "# -- AUTOGENERATED FROM COPY IN OTTER SOURCE --\n" }' \
  -e 'if (m/^\[scraper]/..0) { unless (m/^\[(?!scraper)/..0) { s/^/\#/ } }' \
- -e 's/(?<=\s)\w\S*(?=\s)/-/ if m/^files = """/..m/^"""/;' \
+ -e 's/(?<=\s)\w\S*(?=\s)/-/ if m/^files = """/..m/^"""|^:/;' \
                        <$$l.toml >examples/big-bundle/$$l.toml; done
        @set -e; echo 'LN for $@'; \
        for e in $(LIBRARY_FILE_INPUTS); do \
@@ -445,13 +472,20 @@ stamp/wdt-%.lcheck:       $(WDT_DEPS)
 
 #---------- docs publication ----------
 
+PUBLISH_VERSION=unreleased
 PUBLISH_USER=ianmdlvl@login.chiark.greenend.org.uk
-PUBLISH_DOC_SPHINX=$(PUBLISH_USER):public-html/otter/docs
+PUBLISH_DOC_SPHINX_BASE=public-html/otter
+PUBLISH_DOC_SPHINX_TAIL=$(PUBLISH_VERSION)/docs
+PUBLISH_DOC_SPHINX=$(PUBLISH_USER):$(PUBLISH_DOC_SPHINX_BASE)/$(PUBLISH_DOC_SPHINX_TAIL)
 
 publish: doc-sphinx
+       ssh $(PUBLISH_USER) 'cd $(PUBLISH_DOC_SPHINX_BASE) && mkdir -p $(PUBLISH_DOC_SPHINX_TAIL)'
        rsync -r --delete-delay docs/html/. $(PUBLISH_DOC_SPHINX)/.
        git branch -f $(PUBLISHED_BRANCH)
 
+publish-make-current:
+       ssh $(PUBLISH_USER) 'set -e; cd $(PUBLISH_DOC_SPHINX_BASE); rm -f current.tmp; ln -s $(PUBLISH_VERSION) current.tmp; mv -T current.tmp current'
+
 #---------- deployment ----------
 
 DEPLOY_USER=ian@login.chiark.greenend.org.uk
@@ -461,7 +495,7 @@ DEPLOY_FINISH=/home/Otter/etc/deploy-finish
 for-deploy: stamp/cargo.deploy-build
 deploy: for-deploy bundled-sources assets libraries
        rsync -zvl --progress $(addprefix $(DEPLOY_TARGET_DIR)/,$(PROGRAMS) otter-ssh-proxy) $(DEPLOY_BASE)/bin/
-       rsync -zv --progress $(TARGET_DIR)/release/usvg $(DEPLOY_BASE)/libexec/
+       rsync -zv --progress $(DEPLOY_TARGET_DIR)/usvg $(DEPLOY_BASE)/libexec/
        rsync -rv --progress $(TARGET_DIR)/bundled-sources/. $(DEPLOY_BASE)/bundled-sources
        rsync -r README.md $(DEPLOY_BASE)/.
        rsync -r --delete --exclude=\*~ library specs $(DEPLOY_BASE)/.