-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Examples cannot have separate sets of dependencies #523
Comments
Do you know about
|
No I didn't know about that. Still, it would be kinda hard to work out what dependency is used where. Are the examples required to be in the root of the |
Here are the dependencies of each example. If we use dev-dependencies, then they would be all smooshed together in the top level [[bin]]
name = "cube"
path = "main.rs"
[dependencies.gfx]
path = "../../"
[dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git"
[dependencies.cgmath]
git = "http://github.com/bjz/cgmath-rs" [[bin]]
name = "gl-init"
path = "main.rs"
[dependencies.gfx]
path = "../../"
[dependencies.gl_init]
git = "https://github.com/tomaka/gl-init-rs.git" [[bin]]
name = "gfx-perf"
path = "main.rs"
[dependencies.gfx]
path = "../../"
[dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git"
[dependencies.gfx_gl]
git = "https://github.com/gfx-rs/gfx_gl.git"
[dependencies.cgmath]
git = "http://github.com/bjz/cgmath-rs" [[bin]]
name = "terrain"
path = "main.rs"
[dependencies.gfx]
path = "../../"
[dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git"
[dependencies.cgmath]
git = "http://github.com/bjz/cgmath-rs"
[dependencies.genmesh]
git = "https://github.com/csherratt/genmesh.git"
[dependencies.noise-rs]
git = "https://github.com/bjz/noise-rs.git" [[bin]]
name = "triangle"
path = "main.rs"
[dependencies.gfx]
path = "../../"
[dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git" |
I believe you can put things in whatever order you like, and you can also define examples explicitly via the [[example]]
name = "foo"
[dev_dependencies.x]
...
[dev_dependencies.y]
...
[[example]]
name = "bar"
[dev_dependencies.x]
...
[dev_dependencies.z]
... I'm not 100% sure that cargo handles duplicated deps like that, so you may just have to write them once, and I guess you'll need Lastly, each example needs an |
Ah yep, # ...
[[example]]
name = "triangle"
path = "examples/triangle/main.rs"
[dev_dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git"
[[example]]
name = "cube"
path = "examples/cube/main.rs"
[dev_dependencies.glfw]
git = "https://github.com/bjz/glfw-rs.git" Gives:
|
It would be cool if |
See rust-lang/cargo#523 Still doesn't solve the multiple recompilations during `make test` though.
@bjz, it sounds like you've learned some new things in this issue, which is great! I've got a few follow-up questions at this point.
|
Our The navigation on http://crates.io/ is right down the bottom. It might be nicer if it was easier to find. It might be cool to a hierarchical index of the |
There's a proposal for toml to add "inline table" syntax, which would transform your [package]
name = "gfx"
version = "0.1.0"
authors = [
"Brendan Zabarauskas <bjzaba@yahoo.com.au>",
"Corey Richardson <corey@octayn.net>",
"kvark",
]
[lib]
name = "gfx"
path = "src/gfx/lib.rs"
[dependencies]
gfx_macros = { path = "src/gfx_macros" }
device = { path = "src/device" }
render = { path = "src/render" }
[[example]]
name = "triangle"
path = "examples/triangle/main.rs"
[[example]]
name = "cube"
path = "examples/cube/main.rs"
[[example]]
name = "terrain"
path = "examples/terrain/main.rs"
[[example]]
name = "gl-init"
path = "examples/gl-init/main.rs"
[[example]]
name = "performance"
path = "examples/performance/main.rs"
[dev-dependencies]
glfw = { git = "https://github.com/bjz/glfw-rs.git" }
gfx_gl = { git = "https://github.com/gfx-rs/gfx_gl.git" }
gl_init = { git = "https://github.com/tomaka/gl-init-rs.git" }
genmesh = { git = "https://github.com/csherratt/genmesh.git" }
noise-rs = { git = "https://github.com/bjz/noise-rs.git" }
cgmath = { git = "http://github.com/bjz/cgmath-rs" } Out of curiosity, how does that look to you? |
That looks nicer, but I would still really prefer per-example dependency specification. Or a recursive [[example]]
name = "performance"
path = "examples/performance/" # looks for cargo.toml The latter would make it more self-explanatory for the gfx-rs users about how to set up their projects locally. (Just go to the respective |
I don't believe that we're planning on supporting sub- From what it sounds like, however, this issue doesn't seem particularly actionable. The issue as-is is solved by |
Yeah, the issue with the |
The solution for #483 will definitely solve the problem of redundant compilations for sub-packages, as it's basically the same problem there. I hope to have a fix soon-ish! |
maybe the proposed syntax for cargo-script could be used for something like this as well: #12207, rust-lang/rfcs#3424 //! ```cargo
//! [dependencies]
//! clap = { version = "4.2", features = ["derive"] }
//! ```
|
gfx-rs has examples which have different dependency requirements. It would be great not to have to litter the Cargo.toml with them.
At the moment we have a Makefile to build them, but it results in a huge amount of recompilation.
This could be also useful for external API tests and benchmarks that need to test themselves against different libraries.
The text was updated successfully, but these errors were encountered: