From a0b4afd578e1cd76aa2d82bdf7d53d20d9ec6965 Mon Sep 17 00:00:00 2001 From: "Neal H. Walfield" Date: Tue, 11 Aug 2020 17:47:46 +0200 Subject: Add a variable to only build, test, and document specific packages. - Add the CARGO_PACKAGES variable to allow the user to restrict the packages that are built, test, and documented. - If it contains a package, don't run non-cargo test tests. --- Makefile | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 6f015703..dcd9b837 100644 --- a/Makefile +++ b/Makefile @@ -10,8 +10,10 @@ CARGO_FLAGS ?= CARGO_TARGET_DIR ?= $(shell pwd)/target # We currently only support absolute paths. CARGO_TARGET_DIR := $(abspath $(CARGO_TARGET_DIR)) -# The tests to run. -CARGO_TEST_ARGS ?= --all +# The packages to build, test and document, e.g., "-p sequoia-openpgp" +CARGO_PACKAGES ?= --all +# Additional arguments to pass to cargo test, e.g., "--doc". +CARGO_TEST_ARGS ?= # Version as stated in the top-level Cargo.toml. VERSION ?= $(shell grep '^version[[:space:]]*=[[:space:]]*' Cargo.toml\ | cut -d'"' -f2) @@ -48,23 +50,32 @@ export PREFIX export DESTDIR export CARGO_FLAGS export CARGO_TARGET_DIR +export CARGO_PACKAGES export CARGO_TEST_ARGS all: build examples .PHONY: build build: - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) build $(CARGO_FLAGS) --all + CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) build $(CARGO_FLAGS) $(CARGO_PACKAGES) $(MAKE) -Copenpgp-ffi build $(MAKE) -Cffi build # Testing and examples. +# +# If CARGO_PACKAGES contains a package specification ("-p foo"), then +# only run cargo test. .PHONY: test check test check: - CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) test $(CARGO_FLAGS) $(CARGO_TEST_ARGS) - $(MAKE) -Copenpgp-ffi test - $(MAKE) -Cffi test - $(MAKE) examples + CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) $(CARGO) test $(CARGO_FLAGS) $(CARGO_PACKAGES) $(CARGO_TEST_ARGS) + if echo "$(CARGO_PACKAGES)" | grep -q -E -e '(^| )[-]p +.'; \ + then \ + echo 'WARNING: Not running other tests, because $$CARGO_PACKAGES specifies a package.'; \ + else \ + $(MAKE) -Copenpgp-ffi test; \ + $(MAKE) -Cffi test; \ + $(MAKE) examples; \ + fi .PHONY: examples examples: @@ -80,7 +91,7 @@ doc: > $(CARGO_TARGET_DIR)/inc.html RUSTDOCFLAGS="$$RUSTDOCFLAGS --html-in-header $(CARGO_TARGET_DIR)/inc.html" \ CARGO_TARGET_DIR=$(CARGO_TARGET_DIR) \ - $(CARGO) doc $(CARGO_FLAGS) --no-deps --all + $(CARGO) doc $(CARGO_FLAGS) --no-deps $(CARGO_PACKAGES) # Installation. .PHONY: build-release -- cgit v1.2.3