Checklist
Describe your request
tl;dr allow the user to pass-in environment variables of their choosing to the docker instance
I have an unusual build.rs that looks at some environment variables to determine what to build. In my case, environment variable S4_BUILD_REGEX determines which regular expressions to build. Limiting the built regular expressions is useful in various development scenarios.
But the command env S4_BUILD_REGEX=1 cargo cross build ..., the environment variable S4_BUILD_REGEX has no effect on what is built. That is presumably because it's a project-specific environment variable that is not brought into the launched docker instance.
Checklist
That would infeasible as the build environment variable S4_BUILD_REGEX changes often. Rebuilding a docker image every time would be a lot of tedious wrapper scripts. This Feature seems like an easy and useful addition to cross.
Describe why this would be a good inclusion for cross
Allows the user flexibility in builds using cross. like for example, allow the user to pass-in environment variables that effect their project's build.
Other users may want to forward some uncommon environment variables to the compiler within the docker container. This feature would make that easy and intuitive.
Design suggestion
My suggestion is a CLI option, for example call it --env, that takes values VAR=VAL.
The option --env should be allowed multiple times. The parsing code splits on the first = char.
Examples:
cargo cross build --env=S4_BUILD_REGEX=1,2 --env=S4_BUILD_PRINT=1 ... would pass along two environment variables with the shown values.
These arguments would be passed along to docker run as --env argument(s).
Checklist
Describe your request
tl;dr allow the user to pass-in environment variables of their choosing to the docker instance
I have an unusual
build.rsthat looks at some environment variables to determine what to build. In my case, environment variableS4_BUILD_REGEXdetermines which regular expressions to build. Limiting the built regular expressions is useful in various development scenarios.But the command
env S4_BUILD_REGEX=1 cargo cross build ..., the environment variableS4_BUILD_REGEXhas no effect on what is built. That is presumably because it's a project-specific environment variable that is not brought into the launched docker instance.Checklist
That would infeasible as the build environment variable
S4_BUILD_REGEXchanges often. Rebuilding a docker image every time would be a lot of tedious wrapper scripts. This Feature seems like an easy and useful addition tocross.Describe why this would be a good inclusion for
crossAllows the user flexibility in builds using
cross. like for example, allow the user to pass-in environment variables that effect their project's build.Other users may want to forward some uncommon environment variables to the compiler within the docker container. This feature would make that easy and intuitive.
Design suggestion
My suggestion is a CLI option, for example call it
--env, that takes valuesVAR=VAL.The option
--envshould be allowed multiple times. The parsing code splits on the first=char.Examples:
cargo cross build --env=S4_BUILD_REGEX=1,2 --env=S4_BUILD_PRINT=1 ...would pass along two environment variables with the shown values.These arguments would be passed along to
docker runas--envargument(s).