Skip to content

Commit dc54ac0

Browse files
authored
Rust: Makefile.toml: Add Feature flag support (#298)
Adds additional environment variables to the Makefile.toml to set features when building. setting the variable `FEATURES` will translate to passing `--features <features>` to the underlying build command.
1 parent c05e96f commit dc54ac0

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

.sync/rust_config/Makefile.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ RUSTC_BOOTSTRAP = 1
77
ARCH = "X64"
88
TARGET_TRIPLE = { source = "${ARCH}", mapping = { "X64" = "x86_64-unknown-uefi", "IA32" = "i686-unknown-uefi", "AARCH64" = "aarch64-unknown-uefi", "LOCAL" = "${CARGO_MAKE_RUST_TARGET_TRIPLE}" }, condition = { env_not_set = [ "TARGET_TRIPLE" ] } }
99

10+
CARGO_FEATURES_FLAG = {value = "--features ${FEATURES}", condition = {env_set = ["FEATURES"], env_true = ["FEATURES"]}}
1011
BUILD_FLAGS = "--profile ${RUSTC_PROFILE} --target ${TARGET_TRIPLE} -Zbuild-std=core,compiler_builtins,alloc -Zbuild-std-features=compiler-builtins-mem -Zunstable-options --timings=html"
1112
TEST_FLAGS = { value = "", condition = { env_not_set = ["TEST_FLAGS"] } }
1213
COV_FLAGS = { value = "--out html --exclude-files **/tests/*", condition = { env_not_set = ["COV_FLAGS"] } }
@@ -47,15 +48,17 @@ description = """Builds a single rust package.
4748
Customizations:
4849
-p [development|release]: Builds in debug or release. Default: development
4950
-e ARCH=[IA32|X64|AARCH64|LOCAL]: Builds with specifed arch. Default: X64
51+
-e FEATURES=[feature,...]: Builds with the specified features. Default: none
5052
5153
Example:
5254
`cargo make build RustModule`
5355
`cargo make -p release build RustModule`
5456
`cargo make -e ARCH=IA32 build RustLib`
57+
`cargo make -e FEATURES=feature1,feature2 build RustLib`
5558
"""
5659
clear = true
5760
command = "cargo"
58-
args = ["build", "@@split(INDIVIDUAL_PACKAGE_TARGETS, )", "@@split(BUILD_FLAGS, )"]
61+
args = ["build", "@@split(INDIVIDUAL_PACKAGE_TARGETS, )", "@@split(BUILD_FLAGS, )", "@@split(CARGO_FEATURES_FLAG, ,remove-empty)"]
5962
dependencies = ["individual-package-targets"]
6063

6164
[tasks.check]

0 commit comments

Comments
 (0)