diff options
author | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2019-11-27 09:17:27 -0500 |
---|---|---|
committer | Mike Gerwitz <mike.gerwitz@ryansg.com> | 2019-12-02 10:00:49 -0500 |
commit | e53482f2a3af95338acded5a6a5b970c879e88c5 (patch) | |
tree | ea43df3e902e39248e00b207101e1dcd5afc34a9 | |
parent | d96f090337d2510de2668b733d8a17746f267eb1 (diff) | |
download | tame-e53482f2a3af95338acded5a6a5b970c879e88c5.tar.gz tame-e53482f2a3af95338acded5a6a5b970c879e88c5.tar.bz2 tame-e53482f2a3af95338acded5a6a5b970c879e88c5.zip |
Introduce CARGO_BUILD_FLAGS
This is intended to permit passing `--release`, since dev builds are
terribly slow (e.g. 6s -> 0.2s). See README.md for more information.
-rw-r--r-- | tamer/Cargo.toml | 8 | ||||
-rw-r--r-- | tamer/Makefile.am | 4 | ||||
-rw-r--r-- | tamer/README.md | 23 | ||||
-rw-r--r-- | tamer/configure.ac | 3 |
4 files changed, 36 insertions, 2 deletions
diff --git a/tamer/Cargo.toml b/tamer/Cargo.toml index a8b246b..8a31d36 100644 --- a/tamer/Cargo.toml +++ b/tamer/Cargo.toml @@ -6,7 +6,13 @@ description="TAME on Rust" license="GPLv3+" edition = "2018" -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html +[profile.dev] +# Release-level optimizations. Spending the extra couple of moments +# compile-time is well worth the huge savings we get at runtime. Note that +# this is still every so slightly slower than a release build; see other +# profile options for release at +# <https://doc.rust-lang.org/cargo/reference/manifest.html>. +opt-level = 3 [dependencies] quick-xml = ">= 0.17.0" diff --git a/tamer/Makefile.am b/tamer/Makefile.am index 51fdcdd..2cc502c 100644 --- a/tamer/Makefile.am +++ b/tamer/Makefile.am @@ -20,8 +20,10 @@ .PHONY: all +CARGO_BUILD_FLAGS=@CARGO_BUILD_FLAGS@ + all: - @CARGO@ build + @CARGO@ build $(CARGO_BUILD_FLAGS) doc: html html-am: diff --git a/tamer/README.md b/tamer/README.md index 686f2ff..6d44f02 100644 --- a/tamer/README.md +++ b/tamer/README.md @@ -24,3 +24,26 @@ To bootstrap from the source repository, run `./bootstrap`. To configure the build for your system, run `./configure`. To build, run `make`. To run tests, run `make check`. +You may also invoke `cargo` directly, which `make` will do for you using +options provided to `configure`. + +*Note that the default development build results in terrible runtime +performance!* See [#Build Flags][] below for instructions on how to +generate a release binary. + + +### Build Flags +The environment variable `CARGO_BUILD_FLAGS` can be used to provide +additional arguments to `cargo build` when invoked via `make`. This can be +provided optionally during `configure` and can be overridden when invoking +`make`. For example: + +```sh +# release build +$ ./configure && make CARGO_BUILD_FLAGS=--release +$ ./configure CARGO_BUILD_FLAGS=--release && make + +# dev build +$ ./configure && make +$ ./configure CARGO_BUILD_FLAGS=--release && make CARGO_BUILD_FLAGS= +``` diff --git a/tamer/configure.ac b/tamer/configure.ac index 0fc7bf4..9ed3526 100644 --- a/tamer/configure.ac +++ b/tamer/configure.ac @@ -52,6 +52,9 @@ AX_COMPARE_VERSION([$rustc_version], [ge], [$rustc_ver_req], [AC_MSG_RESULT([yes ($rustc_version)])], [AC_MSG_ERROR([no ($rustc_version)])]) +AC_ARG_VAR([CARGO_BUILD_FLAGS], + [Flags to be passed to `cargo build' when invoked via Make]) + AC_CONFIG_FILES([Makefile]) AC_OUTPUT |