-
Notifications
You must be signed in to change notification settings - Fork 15
Split install action into the new crate cargo-gpu-install
#132
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
Draft
Firestar99
wants to merge
8
commits into
target-specs-v3
Choose a base branch
from
install-crate
base: target-specs-v3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2280193
install-crate: move crate properties (version, edition) to workspace
Firestar99 7dacbb7
install-crate: move install action to new `cargo-gpu-install` crate
Firestar99 1345eff
install-crate: fix clippy
Firestar99 09151d5
install-crate: cargo shear
Firestar99 4b520d6
install-crate: clap and watch feature for optional deps
Firestar99 3ffed8b
install-crate: tty feature to make crossterm and user output optional
Firestar99 440ecf5
install-crate: remove spirv-builder direct dep in cargo-gpu
Firestar99 d43927a
install-crate: fix test instability
Firestar99 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| [package] | ||
| name = "cargo-gpu-install" | ||
| version.workspace = true | ||
| edition.workspace = true | ||
| description = "Install rust-gpu and it's required toolchain automatically" | ||
| repository.workspace = true | ||
| readme.workspace = true | ||
| keywords.workspace = true | ||
| license.workspace = true | ||
|
|
||
| [features] | ||
| clap = ["dep:clap", "spirv-builder/clap"] | ||
| watch = ["spirv-builder/watch"] | ||
| test = ["dep:tempfile"] | ||
| tty = ["dep:crossterm"] | ||
|
|
||
| [dependencies] | ||
| cargo_metadata.workspace = true | ||
| anyhow.workspace = true | ||
| spirv-builder.workspace = true | ||
| clap = { workspace = true, optional = true } | ||
| directories.workspace = true | ||
| log.workspace = true | ||
| serde.workspace = true | ||
| crossterm = { workspace = true, optional = true } | ||
| tempfile = { workspace = true, optional = true } | ||
|
|
||
| [dev-dependencies] | ||
| test-log.workspace = true | ||
| cargo_metadata = { workspace = true, features = ["builder"] } | ||
| cargo-util-schemas = "0.8.2" | ||
|
|
||
| [lints] | ||
| workspace = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| # cargo-gpu-install | ||
|
|
||
| `cargo-gpu-install` is the install action of `cargo-gpu`, separated into its own crate. It's intended to be used | ||
| by build scripts and other binaries that need automated installation of rust-gpu and it's required toolchain, | ||
| without having to pull all the other cli dependencies of the full `cargo-gpu` (like clap). | ||
|
|
||
| ## Example | ||
|
|
||
| This is an example build script meant to be placed in your "main" std crate, to build a secondary no-std "shader" crate. | ||
| But you can just as well use this in your executable directly, with some minor adjustments. | ||
| ```rust,no_run | ||
| # use std::path::PathBuf; | ||
| # use cargo_gpu_install::install::Install; | ||
| # use cargo_gpu_install::spirv_builder::SpirvMetadata; | ||
|
|
||
| pub fn main() -> Result<(), Box<dyn std::error::Error>> { | ||
| // path to your shader crate | ||
| let shader_crate = PathBuf::from("./shaders"); | ||
|
|
||
| // install the toolchain and build the `rustc_codegen_spirv` codegen backend with it | ||
| let backend = Install::from_shader_crate(shader_crate.clone()).run()?; | ||
|
|
||
| // build the shader crate | ||
| let mut builder = backend.to_spirv_builder(shader_crate, "spirv-unknown-vulkan1.2"); | ||
| // set to true when you're in a build script, false when outside one | ||
| builder.build_script.defaults = true; | ||
| // enable debug information in the shaders | ||
| builder.spirv_metadata = SpirvMetadata::Full; | ||
| let spv_result = builder.build()?; | ||
| let path_to_spv = spv_result.module.unwrap_single(); | ||
|
|
||
| // emit path to the artifact into env var, use it anywhere in your crate like: | ||
| // > include_str!(env!("MY_SHADER_PATH")) | ||
| println!( | ||
| "cargo::rustc-env=MY_SHADER_PATH={}", | ||
| path_to_spv.display() | ||
| ); | ||
|
|
||
| // you could also generate some rust source code into the `std::env::var("OUT_DIR")` dir | ||
| // and use `include!(concat!(env!("OUT_DIR"), "/shader_symbols.rs"));` to include it | ||
| Ok(()) | ||
| } | ||
| ``` | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is already adjusted for Rust-GPU/rust-gpu#488, even though it is not yet in this branch. So this will fail doctests (which we don't test in ci...)