Skip to content
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

use emscripten-wasm32 and wasi-wasm32 #333

Merged
merged 1 commit into from
Sep 12, 2023
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
38 changes: 29 additions & 9 deletions crates/rattler_conda_types/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ pub enum Platform {
Win64,
WinArm64,

Emscripten32,
EmscriptenWasm32,
WasiWasm32,
}

impl PartialOrd for Platform {
Expand Down Expand Up @@ -60,6 +61,7 @@ pub enum Arch {
S390X,
Riscv32,
Riscv64,
Wasm32,
}

impl Platform {
Expand Down Expand Up @@ -139,13 +141,20 @@ impl Platform {
#[cfg(target_os = "emscripten")]
{
#[cfg(target_arch = "wasm32")]
return Platform::Emscripten32;
return Platform::EmscriptenWasm32;
}

#[cfg(target_os = "wasi")]
{
#[cfg(target_arch = "wasm32")]
return Platform::WasiWasm32;
}

#[cfg(not(any(
target_os = "linux",
target_os = "macos",
target_os = "emscripten",
target_os = "wasi",
windows
)))]
{
Expand Down Expand Up @@ -211,7 +220,8 @@ impl Platform {
| Platform::LinuxRiscv64 => Some("linux"),
Platform::Osx64 | Platform::OsxArm64 => Some("osx"),
Platform::Win32 | Platform::Win64 | Platform::WinArm64 => Some("win"),
Platform::Emscripten32 => Some("emscripten"),
Platform::EmscriptenWasm32 => Some("emscripten"),
Platform::WasiWasm32 => Some("wasi"),
}
}
}
Expand Down Expand Up @@ -255,7 +265,8 @@ impl FromStr for Platform {
"win-32" => Platform::Win32,
"win-64" => Platform::Win64,
"win-arm64" => Platform::WinArm64,
"emscripten-32" => Platform::Emscripten32,
"emscripten-wasm32" => Platform::EmscriptenWasm32,
"wasi-wasm32" => Platform::WasiWasm32,
string => {
return Err(ParsePlatformError {
string: string.to_owned(),
Expand Down Expand Up @@ -284,7 +295,8 @@ impl From<Platform> for &'static str {
Platform::Win32 => "win-32",
Platform::Win64 => "win-64",
Platform::WinArm64 => "win-arm64",
Platform::Emscripten32 => "emscripten-32",
Platform::EmscriptenWasm32 => "emscripten-wasm32",
Platform::WasiWasm32 => "wasi-wasm32",
Platform::Unknown => "unknown",
}
}
Expand Down Expand Up @@ -313,7 +325,8 @@ impl Platform {
Platform::Win32 => Some(Arch::X86),
Platform::Win64 => Some(Arch::X86_64),
Platform::WinArm64 => Some(Arch::Aarch64),
Platform::Emscripten32 => Some(Arch::X86),
Platform::EmscriptenWasm32 => Some(Arch::Wasm32),
Platform::WasiWasm32 => Some(Arch::Wasm32),
}
}
}
Expand Down Expand Up @@ -380,6 +393,7 @@ impl FromStr for Arch {
"s390x" => Arch::S390X,
"riscv32" => Arch::Riscv32,
"riscv64" => Arch::Riscv64,
"wasm32" => Arch::Wasm32,
string => {
return Err(ParseArchError {
string: string.to_owned(),
Expand All @@ -402,6 +416,7 @@ impl From<Arch> for &'static str {
Arch::S390X => "s390x",
Arch::Riscv32 => "riscv32",
Arch::Riscv64 => "riscv64",
Arch::Wasm32 => "wasm32",
}
}
}
Expand Down Expand Up @@ -450,8 +465,12 @@ mod tests {
);
assert_eq!("win-arm64".parse::<Platform>().unwrap(), Platform::WinArm64);
assert_eq!(
"emscripten-32".parse::<Platform>().unwrap(),
Platform::Emscripten32
"emscripten-wasm32".parse::<Platform>().unwrap(),
Platform::EmscriptenWasm32
);
assert_eq!(
"wasi-wasm32".parse::<Platform>().unwrap(),
Platform::WasiWasm32
);
assert_eq!("noarch".parse::<Platform>().unwrap(), Platform::NoArch);
}
Expand Down Expand Up @@ -486,7 +505,8 @@ mod tests {
assert_eq!(Platform::Win32.arch(), Some(Arch::X86));
assert_eq!(Platform::Win64.arch(), Some(Arch::X86_64));
assert_eq!(Platform::WinArm64.arch(), Some(Arch::Aarch64));
assert_eq!(Platform::Emscripten32.arch(), Some(Arch::X86));
assert_eq!(Platform::EmscriptenWasm32.arch(), Some(Arch::Wasm32));
assert_eq!(Platform::WasiWasm32.arch(), Some(Arch::Wasm32));
assert_eq!(Platform::NoArch.arch(), None);
}
}
3 changes: 2 additions & 1 deletion crates/rattler_virtual_packages/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,8 @@ impl Archspec {
pub fn from_platform(platform: Platform) -> Option<Self> {
let archspec = match platform {
Platform::NoArch | Platform::Unknown => return None,
Platform::Emscripten32 | Platform::Win32 | Platform::Linux32 => "x86",
Platform::EmscriptenWasm32 | Platform::WasiWasm32 => "wasm32",
Platform::Win32 | Platform::Linux32 => "x86",
Platform::Win64 | Platform::Osx64 | Platform::Linux64 => "x86_64",
Platform::LinuxAarch64 => "aarch64",
Platform::LinuxArmV6l => "armv6l",
Expand Down