-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Pass parameters to build.rs script via CLI #3646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Currently this is typically done through environment variables, would that work for you? |
Yes and no: I plan to do it that way, but this adds more complexity to makefile: I have to set environment variables differently for Linux and Windows where it is ugly (cmd /V /C "set VAR123=$(CC) && echo !VAR123!"). It gets more ugly when having more variables. Because of that I consider to stop using build.rs and do stuff in Python. BTW: |
If you're writing a Makefile, instead of doing this: foo:
cargo build --some-argument foo can't you do this? foo: export FOO=foo
foo:
cargo build |
For linux I can do I know I am picky, and I don't waste your time: is it OK if I make PR with handling those params in this way(it is like in npm run Or passing params to build script is against some idea about cargo? |
Does the environment variable syntax in the makefile work? That tends to be more portable than bash itself. |
Proposition for discussion in issue rust-lang#3646
I made PR to have CLI parameters feature. Env var syntax in make works. My opinion about using it is bad. I think that it is just like global scope - polluting it makes only problems. In small build systems I can control it. In bigger, you never know who, when and why changed variable you use. Especially when there is large number of dependencies. |
I agree with @kolipka. I think it's cleaner (and simpler) to support arguments for |
I feel like whats missing from this issue is use cases for why flags are being passed to |
I've created a Pre-RFC for mutually-exclusive, global features which might be pertinent to the discussion. |
For one, I am using |
In #14903 (comment), I propose |
Well, I afraid it is going to slide off-topic, but the main idea is that a crate and it's dependencies could be configured in the top-level manifest, similarly |
Ah, you are looking for transitive dependencies. global features could help with that. |
Hello,
I use make to call cargo build for few modules. For one of them I have to generate some code based on folder structure. I need to pass that folder location via CLI, since it can change. For now I pass it via env var, but it is not nice in multiplatform make. It looks more like workaround than real solution.
I think it could be something like:
cargo build --release -- folder=/my/folder
build.rs could receive everything after -- via std::env::args()
Thanks!
The text was updated successfully, but these errors were encountered: