build(zig): support wasmtime in more archs
This commit is contained in:
parent
b57b7213a9
commit
e6fe91e2e7
3 changed files with 70 additions and 57 deletions
|
|
@ -33,7 +33,7 @@ fn update_cargo(version: &Version) -> Result<()> {
|
|||
fn zig_fetch(lines: &mut Vec<String>, version: &Version, url_suffix: &str) -> Result<()> {
|
||||
let url = &format!("{WASMTIME_RELEASE_URL}/v{version}/wasmtime-v{version}-{url_suffix}");
|
||||
println!(" Fetching {url}");
|
||||
lines.push(format!(" .url = \"{url}\","));
|
||||
lines.push(format!(" .url = \"{url}\","));
|
||||
|
||||
let output = Command::new("zig")
|
||||
.arg("fetch")
|
||||
|
|
@ -42,7 +42,7 @@ fn zig_fetch(lines: &mut Vec<String>, version: &Version, url_suffix: &str) -> Re
|
|||
.with_context(|| format!("Failed to execute zig fetch {url}"))?;
|
||||
|
||||
let hash = String::from_utf8_lossy(&output.stdout);
|
||||
lines.push(format!(" .hash = \"{}\",", hash.trim_end()));
|
||||
lines.push(format!(" .hash = \"{}\",", hash.trim_end()));
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
@ -52,59 +52,33 @@ fn update_zig(version: &Version) -> Result<()> {
|
|||
let mut old_lines = file.lines();
|
||||
let new_lines = &mut Vec::with_capacity(old_lines.size_hint().0);
|
||||
|
||||
macro_rules! match_wasmtime_zig_dep {
|
||||
($line:ident, {$($platform:literal => [$($arch:literal),*]),*,}) => {
|
||||
match $line {
|
||||
$($(concat!(" .wasmtime_c_api_", $arch, "_", $platform, " = .{") => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
let suffix = if $platform == "windows" || $platform == "mingw" {
|
||||
concat!($arch, "-", $platform, "-c-api.zip")
|
||||
} else {
|
||||
concat!($arch, "-", $platform, "-c-api.tar.xz")
|
||||
};
|
||||
zig_fetch(new_lines, version, suffix)?;
|
||||
})*)*
|
||||
_ => {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
while let Some(line) = old_lines.next() {
|
||||
new_lines.push(line.to_string());
|
||||
match line {
|
||||
" .wasmtime_c_api_aarch64_android = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "aarch64-android-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_aarch64_linux = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "aarch64-linux-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_aarch64_macos = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "aarch64-macos-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_aarch64_windows = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "aarch64-windows-c-api.zip")?;
|
||||
}
|
||||
" .wasmtime_c_api_riscv64gc_linux = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "riscv64gc-linux-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_s390x_linux = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "s390x-linux-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_android = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-android-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_linux = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-linux-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_macos = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-macos-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_mingw = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-mingw-c-api.zip")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_musl = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-musl-c-api.tar.xz")?;
|
||||
}
|
||||
" .wasmtime_c_api_x86_64_windows = .{" => {
|
||||
let (_, _) = (old_lines.next(), old_lines.next());
|
||||
zig_fetch(new_lines, version, "x86_64-windows-c-api.zip")?;
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
match_wasmtime_zig_dep!(line, {
|
||||
"android" => ["aarch64", "x86_64"],
|
||||
"linux" => ["aarch64", "armv7", "i686", "riscv64gc", "s390x", "x86_64"],
|
||||
"macos" => ["aarch64", "x86_64"],
|
||||
"mingw" => ["x86_64"],
|
||||
"musl" => ["aarch64", "x86_64"],
|
||||
"windows" => ["aarch64", "i686", "x86_64"],
|
||||
});
|
||||
}
|
||||
|
||||
std::fs::write("build.zig.zon", new_lines.join("\n") + "\n")?;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue