summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorNeal H. Walfield <neal@pep.foundation>2020-08-11 17:47:46 +0200
committerNeal H. Walfield <neal@pep.foundation>2020-08-11 17:52:18 +0200
commita0b4afd578e1cd76aa2d82bdf7d53d20d9ec6965 (patch)
tree8f04bc1ae8a7ab306be5d0944cb6d2b4306427ea /Makefile
parent07ab892191120e20696818619c5e4171b6e777fb (diff)
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.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile27
1 files changed, 19 insertions, 8 deletions
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