Description
Motivation
Some projects cross-compile for multiple targets; all of which need a .json
target specification. This can quickly clutter the root directory when there are numerous target specifications that are not, and cannot be, grouped alphabetically.
One solution is to move all the target specs to a separate directory, build_targets
for instance. Now, however, the RUST_TARGET_PATH
needs to have build_targets
appended to it.
This complicates the build process as you now need to tell users to export said variable or use make
or some other build system to drive Cargo.
Solution
Cargo configuration (.cargo/config
) already supports a large number of options for configuring the build environment. I propose simply adding the RUST_TARGET_PATH
variable to that list.
A usage example:
[build]
# append these paths to RUST_TARGET_PATH
target_path = ["build_targets/x86", "build_targets/ARM"]
Possible issues
- If crate
Foo
sets this variable, I am not sure if the variable should be isolated to onlyFoo
, or should carry through to the crates that depend on it. - Being unfamiliar with compiler internals, absolute vs. relative directories could come into play especially when considering (1).