This repository was archived by the owner on Oct 31, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 247
Update spirv-tools #1127
Merged
Merged
Update spirv-tools #1127
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ea43b29
Update to spirv-tools 0.10.0
Jake-Shadle 09170ee
Use pre-built binaries from spirv-tools-rs
Jake-Shadle 05472ac
Oops
Jake-Shadle 57bc8b4
Target != host for android
Jake-Shadle d5f7e32
Use non-ancient ubuntu
Jake-Shadle 159076a
Oh right
Jake-Shadle 3cd9ef0
Update expected output
Jake-Shadle d18533f
Address feedback
Jake-Shadle cd3796f
Oops
Jake-Shadle 3b94062
Cancel actions when new commits are pushed
Jake-Shadle 2874de3
Update CHANGELOG
Jake-Shadle 56820d1
Fixup
Jake-Shadle 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
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,14 @@ | ||
| # We make this tool its own workspace as it doesn't share dependencies with the | ||
| # rest of the workspace, and it shouldn't be built normally, only as a helper | ||
| # for CI so it would just slow down local development for no reason | ||
| [workspace] | ||
|
|
||
| [package] | ||
| name = "install-spirv-tools" | ||
| edition = "2021" | ||
| version = "0.1.0" | ||
| publish = false | ||
|
|
||
| [dependencies] | ||
| tar = "0.4" | ||
| zstd = "0.13" |
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,109 @@ | ||
| use std::{env, fs, io::Write as _, process::Command}; | ||
|
|
||
| struct Group(bool); | ||
|
|
||
| impl Group { | ||
| fn new(group: &str) -> Self { | ||
| let is_gh = env::var_os("CI").is_some(); | ||
| if is_gh { | ||
| println!("::group::{group}"); | ||
| } else { | ||
| println!("{group}"); | ||
| } | ||
| Self(is_gh) | ||
| } | ||
| } | ||
|
|
||
| impl Drop for Group { | ||
| fn drop(&mut self) { | ||
| if self.0 { | ||
| println!("::endgroup::"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn main() { | ||
| let (triple, release, td) = { | ||
| let mut args = env::args().skip(1); | ||
| let triple = args.next().expect("expected target triple"); | ||
| let release = args.next().expect("expected release tag name"); | ||
| let td = args.next().expect("expected output directory"); | ||
|
|
||
| (triple, release, td) | ||
| }; | ||
|
|
||
| let compressed = { | ||
| let _s = Group::new(&format!("downloading {triple} tarball")); | ||
| let mut cmd = Command::new("curl"); | ||
| cmd.args(["-f", "-L"]) | ||
| .arg(format!("https://github.com/EmbarkStudios/spirv-tools-rs/releases/download/{release}/{triple}.tar.zst")) | ||
| .stdout(std::process::Stdio::piped()); | ||
|
|
||
| let output = cmd | ||
| .spawn() | ||
| .expect("curl is not installed") | ||
| .wait_with_output() | ||
| .expect("failed to wait for curl"); | ||
|
|
||
| if !output.status.success() { | ||
| panic!("failed to download tarball via curl"); | ||
| } | ||
|
|
||
| output.stdout | ||
| }; | ||
|
|
||
| let decoded = { | ||
| let _s = Group::new(&format!("decompressing {triple} tarball")); | ||
| // All archives are <8MiB decompressed | ||
| let uncompressed = Vec::with_capacity(8 * 1024 * 1024); | ||
| let mut decoder = | ||
| zstd::stream::write::Decoder::new(uncompressed).expect("failed to create decoder"); | ||
| decoder | ||
| .write_all(&compressed) | ||
| .expect("failed to decompress"); | ||
| decoder.flush().expect("failed to flush decompress stream"); | ||
|
|
||
| decoder.into_inner() | ||
| }; | ||
|
|
||
| { | ||
| let _s = Group::new(&format!("untarring {triple} tarball")); | ||
| { | ||
| let mut tar = tar::Archive::new(std::io::Cursor::new(&decoded)); | ||
|
|
||
| if tar | ||
| .entries() | ||
| .expect("failed to retrieve entries") | ||
| .filter(|ent| ent.is_ok()) | ||
| .count() | ||
| == 0 | ||
| { | ||
| panic!("no valid entries found in tarball"); | ||
| } | ||
| } | ||
|
|
||
| let mut tar = tar::Archive::new(std::io::Cursor::new(decoded)); | ||
| tar.unpack(&td).expect("failed to untar files"); | ||
| } | ||
|
|
||
| if let Some(gh_path) = env::var_os("GITHUB_PATH") { | ||
| let _s = Group::new(&format!("adding '{td}' to $GITHUB_PATH ({gh_path:?})")); | ||
|
|
||
| // emulate >> for both empty and non-empty files | ||
| let has_contents = fs::metadata(&gh_path).map_or(false, |md| md.len() > 0); | ||
|
|
||
| let mut file = fs::OpenOptions::new() | ||
| .append(true) | ||
| .open(gh_path) | ||
| .expect("failed to open $GITHUB_PATH"); | ||
|
|
||
| let td = if has_contents { | ||
| format!("\n{td}\n") | ||
| } else { | ||
| td | ||
| }; | ||
|
|
||
| file.write_all(td.as_bytes()) | ||
| .expect("failed to write to $GITHUB_PATH"); | ||
| } | ||
| } |
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 |
|---|---|---|
|
|
@@ -2,3 +2,4 @@ target/ | |
| .vscode/ | ||
| .vim/ | ||
| tests/Cargo.lock | ||
| .github/install-spirv-tools/Cargo.lock | ||
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
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
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
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.