Skip to content

Commit a7fc3c7

Browse files
committed
vp_js_runtime: add FreeBSD to the supported OS set
vp_js_runtime's Os enum only lists Linux, Darwin, and Windows, and Os::current() has a compile_error! for any other target. FreeBSD is a legitimate target for the `vp` binary (the rest of the toolchain builds fine), so add a FreeBSD variant and route it through the same tar.gz + bin/node + bin/ conventions the other unix platforms use. Note: managed Node.js currently has no official FreeBSD build, so `vp env` downloads on FreeBSD will 404 at runtime. That is a distribution gap, not a code gap, and does not block the `vp` binary itself from compiling or running. If/when Node.js publishes FreeBSD artifacts, only the platform_string() mapping in providers/node.rs needs to be updated (FreeBSD -> "freebsd" instead of "linux"). Signed-off-by: Matthias Fechner <mfechner@FreeBSD.org>
1 parent 0126ece commit a7fc3c7

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

crates/vp_js_runtime/src/platform.rs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ pub enum Os {
1313
Linux,
1414
Darwin,
1515
Windows,
16+
FreeBSD,
1617
}
1718

1819
/// CPU architecture
@@ -59,10 +60,19 @@ impl Os {
5960
{
6061
Self::Windows
6162
}
62-
#[cfg(not(any(target_os = "linux", target_os = "macos", target_os = "windows")))]
63+
#[cfg(target_os = "freebsd")]
64+
{
65+
Self::FreeBSD
66+
}
67+
#[cfg(not(any(
68+
target_os = "linux",
69+
target_os = "macos",
70+
target_os = "windows",
71+
target_os = "freebsd"
72+
)))]
6373
{
6474
compile_error!(
65-
"Unsupported operating system. vp_js_runtime only supports Linux, macOS, and Windows."
75+
"Unsupported operating system. vp_js_runtime only supports Linux, macOS, Windows, and FreeBSD."
6676
)
6777
}
6878
}
@@ -74,6 +84,7 @@ impl fmt::Display for Os {
7484
Self::Linux => write!(f, "linux"),
7585
Self::Darwin => write!(f, "darwin"),
7686
Self::Windows => write!(f, "windows"),
87+
Self::FreeBSD => write!(f, "freebsd"),
7788
}
7889
}
7990
}

crates/vp_js_runtime/src/providers/node.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl NodeProvider {
171171
const fn archive_format(platform: Platform) -> ArchiveFormat {
172172
match platform.os {
173173
Os::Windows => ArchiveFormat::Zip,
174-
Os::Linux | Os::Darwin => ArchiveFormat::TarGz,
174+
Os::Linux | Os::Darwin | Os::FreeBSD => ArchiveFormat::TarGz,
175175
}
176176
}
177177

@@ -599,6 +599,7 @@ impl JsRuntimeProvider for NodeProvider {
599599
Os::Linux => "linux",
600600
Os::Darwin => "darwin",
601601
Os::Windows => "win",
602+
Os::FreeBSD => "linux",
602603
};
603604
let arch = match platform.arch {
604605
crate::platform::Arch::X64 => "x64",
@@ -653,14 +654,14 @@ impl JsRuntimeProvider for NodeProvider {
653654
fn binary_relative_path(&self, platform: Platform) -> Str {
654655
match platform.os {
655656
Os::Windows => "node.exe".into(),
656-
Os::Linux | Os::Darwin => "bin/node".into(),
657+
Os::Linux | Os::Darwin | Os::FreeBSD => "bin/node".into(),
657658
}
658659
}
659660

660661
fn bin_dir_relative_path(&self, platform: Platform) -> Str {
661662
match platform.os {
662663
Os::Windows => "".into(),
663-
Os::Linux | Os::Darwin => "bin".into(),
664+
Os::Linux | Os::Darwin | Os::FreeBSD => "bin".into(),
664665
}
665666
}
666667

0 commit comments

Comments
 (0)