-
Notifications
You must be signed in to change notification settings - Fork 105
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
Is there a reason build_scripts does not include flags? #97
Comments
I think I may have understood something fundamental about the |
Fighting the same problem at the moment. Trying to compile I am also willing to help this project, but as beginner at Bazel and semi-experienced rust programmer I am not sure where to start. EDIT: |
My recollection of these cargo specifics is unfortunately foggy (and incidentally the reason I punted on replying to this once it hit my inbox, though regretably I forgot about it until this subsequent ping). I can say that we do properly propagate feature flags, which manifest as "CARGO_FEATURE_*". I also recall that CARGO_MANIFEST_DIR support was added manually due to the large number of build scripts that require that specific env var, but it seems that change was folded into the original commit for this feature. That variable alone required what I consider to be some absurd combinations of tera template substitution and arcane BUILD features, and my idealized form of this support would take the form of adding some kind of build script runner, instead of adding more crazy stuff to the genrule.cmd field. Even if the change just includes an incremental addition to genrule.cmd, I would be happy and grateful to review PRs that include more of these environment variables. Some may be easier to furnish than others. I believe this is the authoritative source for these env vars. |
For my own (future) edification while this is fresh in my mind, I want to expand a bit upon the "build script runner" thing. Build Script Runner ThingI think even since build script support was first implemented, the current approach of running the build script as a genrule was considered hacky. I went with this approach above something more sophisticated because I wanted to avoid forcing the bazel workspace to have a dependency upon bazel content in cargo-raze. That is to say, requiring it to be loaded as an
It was easiest at the time to say "no" to these concerns and simply ensure that generated BUILD files never had external dependencies beyond rules_rust. This led to the abomination that is build_script.template. In the real world though, or at least in Google, people build sensible utility binaries (e.g. py_binary) to do this kind of thing. Such a binary for our use case could:
While the handling of build script output (beyond generated files) is still an open question, I think capturing this stuff now is a good first step to eventually handling this. Perhaps we could locate requested As an aside, perhaps such a utility binary could live in bazelbuild/rules_rust itself? I would be quite happy with an outcome like that, provided the utility binary was user friendly enough to be used by humans and not just generated BUILD files. Output From Build ScriptsFor reference, Cargo has a strange relationship with build scripts. Basically, it runs them, dumps the output into target/ (iirc?), and consumes stdout from the script. The list of valid directives from a build script is available here. |
Hey!
Currently some crates has conditional behaviour in their build scripts that can be specified with
--cfg
flags. Currentlycargo-raze
does not pass on flags to thebuild_script
targets. Is there a reason for that?Just wanted to check in, I can create a PR if it's acceptable to pass them to the
build_script
target.The text was updated successfully, but these errors were encountered: