Need to put more words to this, but: I think http://build.rs 's include!() macro behavior is alright, but not great. Either you use it to import real basic files only. Or you need to declare every dependency in Cargo.toml *twice*. One regular dep, and one build-dep.
-
Show this thread
-
It seems the include!() macro works similar-ish to C-style headers. Basically copy-paste a file into where the macro would otherwise be. And that works well for basic things, but it's what I believe is called "unhygienic" -- imports leak, and the compiler doesn't like it.
2 replies 0 retweets 0 likesShow this thread -
To recap: 1. Regular dependencies aren't available in http://build.rs , leading to duplicated declarations 2. `include!()` is unhygienic A solution? Not sure. Ideally `extern crate` would work, but I'm *sure* there's reasons why it was chosen not to.
1 reply 0 retweets 0 likesShow this thread -
Replying to @yoshuawuyts
You don't want to wait for the entire deptree to build to run a potentially expensive build script. The common/intended use case for build scripts is compiling native deps or doing codegen, neither use case typically requires shared deps.
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @yoshuawuyts
Rust tries to explicitly declare costs so if you don't need your build script to compile the entire deptree it won't. Consider factoring out the shared code into its own crate if possible.
1 reply 0 retweets 0 likes -
Replying to @ManishEarth @yoshuawuyts
Sharing code between build scripts and the crate itself isn't really a supported use case. It's also kinda cyclic so doesn't make as much sense? Worth posting about this on the internals forum with concrete examples.
2 replies 0 retweets 1 like -
Replying to @ManishEarth
Yeah, I really should post about this in more words. Im using it to output things like man pages / autocomplete scripts. Will write something up later!
1 reply 0 retweets 1 like -
Replying to @yoshuawuyts @ManishEarth
Ooph, it's been hard to find the time to write this. Im not sure I'll make it :(
1 reply 0 retweets 1 like
Got around to writing it! :D https://internals.rust-lang.org/t/problems-with-using-include-in-build-rs-for-rs-code/8447 …
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.