Skip to content

Commit d9cebe2

Browse files
committed
fix(fetch): fall back to bundled file for unmatched upstream URLs
Also add the upstream URL for xxHash HEAD. Signed-off-by: Steven Noonan <steven@uplinklabs.net>
1 parent 1321ac7 commit d9cebe2

1 file changed

Lines changed: 14 additions & 11 deletions

File tree

src/fetch.rs

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,12 @@ use crate::bundled;
1212
const BASE_GL: &str = "https://raw.githubusercontent.com/KhronosGroup/OpenGL-Registry/main/xml/";
1313
const BASE_EGL: &str = "https://raw.githubusercontent.com/KhronosGroup/EGL-Registry/main/api/";
1414
const BASE_VK: &str = "https://raw.githubusercontent.com/KhronosGroup/Vulkan-Docs/main/xml/";
15-
// The auxiliary-header subsystem (load_auxiliary_header and its helpers) is
16-
// infrastructure for copying headers to the output directory. It is not yet
17-
// wired into the generators.
18-
#[allow(dead_code)]
1915
const BASE_VK_HEADERS: &str =
2016
"https://raw.githubusercontent.com/KhronosGroup/Vulkan-Headers/main/include/";
2117
const BASE_ANGLE: &str = "https://raw.githubusercontent.com/google/angle/main/scripts/";
2218
const GLSL_EXTS_URL: &str = "https://www.uplinklabs.net/glsl_exts.xml";
19+
const XXHASH_HEAD_URL: &str =
20+
"https://raw.githubusercontent.com/Cyan4973/xxHash/refs/heads/dev/xxhash.h";
2321

2422
// ---------------------------------------------------------------------------
2523
// SpecSources
@@ -45,15 +43,19 @@ pub fn load_spec(spec_name: &str, use_fetch: bool) -> Result<SpecSources> {
4543
}
4644
}
4745

48-
#[allow(dead_code)]
4946
pub fn load_auxiliary_header(path: &str, use_fetch: bool) -> Result<String> {
5047
if use_fetch {
51-
let url = auxiliary_url(path)
52-
.ok_or_else(|| anyhow::anyhow!("no remote URL known for '{}'", path))?;
53-
fetch_text(&url).with_context(|| format!("fetching auxiliary header '{}'", path))
54-
} else {
55-
bundled_auxiliary(path).map(str::to_string)
48+
if let Some(url) = auxiliary_url(path) {
49+
return fetch_text(&url)
50+
.with_context(|| format!("fetching auxiliary header '{}'", path));
51+
}
52+
eprintln!(
53+
"no remote auxiliary URL for '{}'; using bundled version",
54+
path
55+
);
5656
}
57+
58+
bundled_auxiliary(path).map(str::to_string)
5759
}
5860

5961
// ---------------------------------------------------------------------------
@@ -146,12 +148,13 @@ fn fetch_spec(spec_name: &str) -> Result<SpecSources> {
146148
})
147149
}
148150

149-
#[allow(dead_code)]
150151
fn auxiliary_url(path: &str) -> Option<String> {
151152
if path.starts_with("vk_video/") || path == "vk_platform.h" {
152153
Some(format!("{}vulkan/{}", BASE_VK_HEADERS, path))
153154
} else if path.starts_with("KHR/") || path.starts_with("EGL/") {
154155
Some(format!("{}{}", BASE_EGL, path))
156+
} else if path == "xxhash.h" {
157+
Some(XXHASH_HEAD_URL.to_string())
155158
} else {
156159
None
157160
}

0 commit comments

Comments
 (0)