1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
#!/usr/bin/make -f
# resolve DEB_VERSION DEB_VERSION_UPSTREAM DEB_VERSION_UPSTREAM_REVISION
include /usr/share/dpkg/pkg-info.mk
export DEB_BUILD_MAINT_OPTIONS = hardening=+all
export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
export DEB_CXXFLAGS_MAINT_APPEND = -Wall -pedantic
# trust upstream optimization level unless explicitly disabled
ifeq (,$(filter noopt,$(DEB_BUILD_OPTIONS)))
export DEB_CFLAGS_MAINT_STRIP=-O2
export DEB_CXXFLAGS_MAINT_STRIP=-O2
endif
# resolve crate version
# * get topmost version except prerelease suffix
# from Cargo.toml file in dir passed as argument
# * source package version if matching upstream part modulo prerelease
# * otherwise append source package version
crate_version = \
$(shell perl -n \
-E '/version\W+\K\d+\.\d+\.\d+/ ' \
-E 'and say "$(DEB_VERSION_UPSTREAM)" =~ /^\Q$$&\E(?:~[a-z]+\d*)?$$/ ? "$(DEB_VERSION)" : "$$&+$(DEB_VERSION_UPSTREAM_REVISION)" and exit' \
$1/Cargo.toml)
# general wasm-pack settings lifted from <js/package.json>
WASM_PACK_ENV = \
RUSTFLAGS='--cfg getrandom_backend="wasm_js" --codegen opt-level=z'
WASM_PACK_OPTS = --mode no-install --weak-refs --reference-types --release
# general wasm-pack settings needed for Debian integration
WASM_PACK_ENV += \
CARGO_HOME=$(CURDIR)/debian/cargo_home \
XDG_CACHE_HOME=$(CURDIR)/debian/cache
WASM_PACK_OPTS += -- --offline
%:
dh $@
execute_after_dh_auto_build-indep:
# FIXME: redefine HOME or something more specific for <~/.wasm-pack>
cd js && $(WASM_PACK_ENV) wasm-pack build --target web --out-name web $(WASM_PACK_OPTS)
cd js && $(WASM_PACK_ENV) wasm-pack build --target nodejs --out-name node $(WASM_PACK_OPTS)
cd js && node build_package.mjs
# TODO: enable when vitest is in Debian
#execute_after_dh_auto_test-arch:
# cd js && $(WASM_PACK_ENV) $(WASM_PACK_BUILD) --debug --target nodejs
# cd js && vitest
execute_after_dh_auto_install-arch:
cp $(firstword $(wildcard target/*/*/build/oxigraph-cli-*/out/complete/oxigraph.bash)) debian/bash-completion
# packages needing workaround for previous main-library-versioning
# TODO: drop version prefix "really" when crate version reaches 0.4
broken_version = $(patsubst %,librust-%-dev,\
oxrdf oxsdatatypes sparesults)
# declare version for virtually provided embedded crates
packages = $(patsubst %,librust-%-dev,\
oxigraph oxrdf oxrocksdb-sys oxsdatatypes sparesults spargebra)
packages_virtual = $(patsubst %,librust-%-dev,\
oxjsonld oxrdfio oxrdfxml oxttl spareval sparopt)
override_dh_gencontrol:
$(eval librust-oxigraph-dev_version = $(call crate_version,.))\
$(eval librust-oxjsonld-dev_version = $(call crate_version,lib/oxjsonld))\
$(eval librust-oxrdf-dev_version = $(call crate_version,lib/oxrdf))\
$(eval librust-oxrdfio-dev_version = $(call crate_version,lib/oxrdfio))\
$(eval librust-oxrdfxml-dev_version = $(call crate_version,lib/oxrdfxml))\
$(eval librust-oxrocksdb-sys-dev_version = $(call crate_version,.))\
$(eval librust-oxsdatatypes-dev_version = $(call crate_version,lib/oxsdatatypes))\
$(eval librust-oxttl-dev_version = $(call crate_version,lib/oxttl))\
$(eval librust-sparesults-dev_version = $(call crate_version,lib/sparesults))\
$(eval librust-spareval-dev_version = $(call crate_version,lib/spareval))\
$(eval librust-spargebra-dev_version = $(call crate_version,lib/spargebra))\
$(eval librust-sparopt-dev_version = $(call crate_version,lib/sparopt))\
set -e; $(foreach p,$(packages),\
dh_gencontrol -p$p -- \
-v'$(if $(filter $(broken_version),$p),0.4.0~really$($p_version),$($p_version))' \
$(foreach q,$(filter-out $p,$(packages) $(packages_virtual)),\
-V'rust:Version:$q=$($q_version)');)
dh_gencontrol --remaining-packages
|