Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [Unreleased]
- Update Vulkan sdk to [vulkan-sdk-1.4.363](https://github.com/KhronosGroup/Vulkan-Headers/tree/vulkan-sdk-1.4.363)
## [0.1.0+sdk-1.4.357](https://github.com/Rust-GPU/rspirv2/releases/tag/v0.1.0+sdk-1.4.357) - 2026-07-29
- Initial release of rspirv2
40 changes: 32 additions & 8 deletions xtask/src/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@ pub struct HeadersUpdate {
/// Branch or revision to point the submodule at. Defaults to the branch
/// with the highest semver matching `vulkan-sdk-*.*.*`.
rev: Option<String>,
/// Proceed updating things anyway, even if the version didn't change. Useful if submodules are in a weird state.
#[clap(long)]
force: bool,
/// Skip running autogen to update generated files
#[clap(long)]
skip_autogen: bool,
/// Skip updating the workspace version `+sdk-<version>` suffix
#[clap(long)]
skip_version: bool,
/// Skip updating the changelog
#[clap(long)]
skip_changelog: bool,
}

impl HeadersUpdate {
Expand All @@ -45,7 +51,7 @@ impl HeadersUpdate {
} else {
let branch = SubmoduleBranches::fetch(repo, SUBMODULE_PATH, BRANCH_PREFIX)?
.highest_semver_branch(BRANCH_PREFIX)?;
println!("Newest SPIR-V header version is `{branch}`");
println!("Resolved newest SPIR-V header version `{branch}`");
branch
};

Expand All @@ -57,12 +63,13 @@ impl HeadersUpdate {
&format!("submodule.{SUBMODULE_PATH}.branch"),
])
.context("reading submodule branch from .gitmodules")?;
if old_branch.trim() == branch {
let old_branch = old_branch.trim();
if !self.force && old_branch == branch {
println!("SPIR-V headers is already set to `{branch}`, skipping");
return Ok(());
}

println!("Setting SPIR-V headers to `{branch}`");
println!("Updating SPIR-V headers from `{old_branch}` to `{branch}`");
repo.git(&[
"submodule",
"set-branch",
Expand All @@ -74,10 +81,14 @@ impl HeadersUpdate {
repo.git(&["submodule", "update", "--remote", SUBMODULE_PATH])?;

if !self.skip_version {
set_workspace_sdk_version(repo, &branch)
set_workspace_sdk_version(repo, &branch, self.force)
.context("updating workspace sdk version suffix")?;
}

if !self.skip_changelog {
update_changelog(repo, &branch).context("updating changelog")?;
}

if !self.skip_autogen {
println!("Running `cargo autogen`");
let status = Command::new("cargo")
Expand All @@ -94,7 +105,7 @@ impl HeadersUpdate {
}

/// Update the workspace version `+sdk-<version>` appendix
fn set_workspace_sdk_version(repo: &GitRepo, branch: &str) -> anyhow::Result<()> {
fn set_workspace_sdk_version(repo: &GitRepo, branch: &str, force: bool) -> anyhow::Result<()> {
let sdk_version = {
let (major, minor, patch) =
parse_branch_semver(branch, BRANCH_PREFIX).context("failed to parse branch")?;
Expand All @@ -113,17 +124,30 @@ fn set_workspace_sdk_version(repo: &GitRepo, branch: &str) -> anyhow::Result<()>
.context("no workspace `version` line found")?;
let base = old_version.split('+').next().unwrap_or(old_version);
let new_version = format!("{base}+sdk-{sdk_version}");
if old_version == new_version {
println!("Workspace version already `{new_version}`");
if !force && old_version == new_version {
println!("Workspace version already set to `{new_version}`");
return Ok(());
}

println!("Setting workspace version to `{new_version}`");
println!("Updating workspace version from `{old_version}` to `{new_version}`");
let content = content.replacen(old_version, &new_version, 1);
fs::write(&path, content).context("writing Cargo.toml")?;
Ok(())
}

/// Update the changelog to include a sdk update message
fn update_changelog(repo: &GitRepo, branch: &str) -> anyhow::Result<()> {
const UNRELEASED_TAG: &str = "## [Unreleased]\n";
let path = repo.root.join("CHANGELOG.md");
let replacement = format!(
"{UNRELEASED_TAG}- Update Vulkan sdk to [{branch}](https://github.com/KhronosGroup/Vulkan-Headers/tree/{branch})\n"
);
let content = fs::read_to_string(&path).context("reading CHANGELOG.md")?;
let content = content.replacen(UNRELEASED_TAG, &replacement, 1);
fs::write(&path, content).context("writing CHANGELOG.md")?;
Ok(())
}

/// List the release branches of the SPIR-V headers repo
#[derive(Clone, Debug, Parser)]
pub struct HeadersList {}
Expand Down
Loading