Skip to content
Open
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
15 changes: 13 additions & 2 deletions crates/vp_js_runtime/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pub enum Os {
Linux,
Darwin,
Windows,
FreeBSD,
}

/// CPU architecture
Expand Down Expand Up @@ -59,10 +60,19 @@ impl Os {
{
Self::Windows
}
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
#[cfg(target_os = "freebsd")]
{
Self::FreeBSD
}
#[cfg(not(any(
target_os = "linux",
target_os = "macos",
target_os = "windows",
target_os = "freebsd"
)))]
{
compile_error!(
"Unsupported operating system. vp_js_runtime only supports Linux, macOS, and Windows."
"Unsupported operating system. vp_js_runtime only supports Linux, macOS, Windows, and FreeBSD."
)
}
}
Expand All @@ -74,6 +84,7 @@ impl fmt::Display for Os {
Self::Linux => write!(f, "linux"),
Self::Darwin => write!(f, "darwin"),
Self::Windows => write!(f, "windows"),
Self::FreeBSD => write!(f, "freebsd"),
}
}
}
Expand Down
7 changes: 4 additions & 3 deletions crates/vp_js_runtime/src/providers/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl NodeProvider {
const fn archive_format(platform: Platform) -> ArchiveFormat {
match platform.os {
Os::Windows => ArchiveFormat::Zip,
Os::Linux | Os::Darwin => ArchiveFormat::TarGz,
Os::Linux | Os::Darwin | Os::FreeBSD => ArchiveFormat::TarGz,
}
}

Expand Down Expand Up @@ -599,6 +599,7 @@ impl JsRuntimeProvider for NodeProvider {
Os::Linux => "linux",
Os::Darwin => "darwin",
Os::Windows => "win",
Os::FreeBSD => "linux",
};
let arch = match platform.arch {
crate::platform::Arch::X64 => "x64",
Expand Down Expand Up @@ -653,14 +654,14 @@ impl JsRuntimeProvider for NodeProvider {
fn binary_relative_path(&self, platform: Platform) -> Str {
match platform.os {
Os::Windows => "node.exe".into(),
Os::Linux | Os::Darwin => "bin/node".into(),
Os::Linux | Os::Darwin | Os::FreeBSD => "bin/node".into(),
}
}

fn bin_dir_relative_path(&self, platform: Platform) -> Str {
match platform.os {
Os::Windows => "".into(),
Os::Linux | Os::Darwin => "bin".into(),
Os::Linux | Os::Darwin | Os::FreeBSD => "bin".into(),
}
}

Expand Down
Loading