Skip to content

Commit e6098a8

Browse files
authored
Get warp compiling on FreeBSD (#9362)
Most `target_os = "linux"` cfg sites in this tree gate code that already works fine on FreeBSD. wayland-client, cctk, fontconfig, x11rb, native-dialog, notify-rust, and the WindowingSystem enum all compile and run there using the existing Linux branches. Widening those cfg guards from `target_os = "linux"` to `any(target_os = "linux", target_os = "freebsd")` is enough to get a working build. The change is mechanical: 79 files across `app/` and `crates/`, all of them just adjusting the cfg. One Linux-only carveout: `InputFlags::IUTF8` in `app/src/terminal/local_tty/unix.rs`. nix does not expose that termios input flag on FreeBSD, and the PTY works without it. Linux, macOS, and Windows are unaffected by construction: every widened cfg already evaluated true on Linux and continues to; neither macOS nor Windows ever matched these guards. Tested by building `warp-oss` on FreeBSD 16-CURRENT amd64 with rust 1.92 and launching it under wayland (niri). <img width="2560" height="1440" alt="image" src="https://github.com/user-attachments/assets/085f3b8c-621c-4fbb-adc8-69daebc03d3a" />
1 parent 2f84587 commit e6098a8

70 files changed

Lines changed: 300 additions & 183 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ nix = { workspace = true, features = [
349349
"mman",
350350
] }
351351

352-
[target.'cfg(any(target_os = "linux", target_os = "windows"))'.dependencies]
352+
[target.'cfg(any(target_os = "linux", target_os = "freebsd", target_os = "windows"))'.dependencies]
353353
crash-handler = { version = "0.6.3", optional = true }
354354
minidumper = { version = "0.8.3", optional = true }
355355

356-
[target.'cfg(target_os = "linux")'.dependencies]
356+
[target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies]
357357
freedesktop-desktop-entry = "0.5.0"
358358
x11rb.workspace = true
359359
zbus.workspace = true

app/src/app_services/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
//! Finder such that the user can open a new Warp tab or window
66
//! in a given directory.
77
8-
#[cfg(target_os = "linux")]
8+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
99
pub mod linux;
1010
#[cfg(target_os = "macos")]
1111
mod mac;
@@ -17,7 +17,7 @@ use warpui::AppContext;
1717
pub fn init(_ctx: &mut AppContext) {
1818
log::info!("Initializing app services");
1919

20-
#[cfg(target_os = "linux")]
20+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
2121
linux::init(_ctx);
2222
#[cfg(target_os = "macos")]
2323
mac::init();
@@ -28,6 +28,6 @@ pub fn init(_ctx: &mut AppContext) {
2828
pub fn teardown(_ctx: &mut AppContext) {
2929
log::info!("Tearing down app services...");
3030

31-
#[cfg(target_os = "linux")]
31+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
3232
linux::teardown(_ctx);
3333
}

app/src/auth/auth_view_modal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub fn init(app: &mut AppContext) {
6464
// to solve it in a more general way later). In the meantime, we
6565
// add a basic ctrl+v binding for the auth view, since there is no
6666
// terminal to interact with yet.
67-
#[cfg(any(target_os = "linux", target_os = "windows"))]
67+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "windows"))]
6868
app.register_fixed_bindings([FixedBinding::new(
6969
"cmdorctrl-v",
7070
AuthViewAction::PasteAuthUrl,

app/src/auth/login_slide.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn init(app: &mut AppContext) {
7878
),
7979
]);
8080

81-
#[cfg(any(target_os = "linux", target_os = "windows"))]
81+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "windows"))]
8282
app.register_fixed_bindings([FixedBinding::new(
8383
"cmdorctrl-v",
8484
LoginSlideAction::PasteAuthUrl,

app/src/auth/paste_auth_token_modal.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ pub fn init(app: &mut AppContext) {
6363
),
6464
]);
6565

66-
#[cfg(any(target_os = "linux", target_os = "windows"))]
66+
#[cfg(any(target_os = "linux", target_os = "freebsd", target_os = "windows"))]
6767
app.register_fixed_bindings([FixedBinding::new(
6868
"cmdorctrl-v",
6969
PasteAuthTokenModalAction::PasteIntoEditor,

app/src/code_review/code_review_view.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7797,7 +7797,11 @@ impl BackingView for CodeReviewView {
77977797
AppContext::show_native_platform_modal(ctx, dialog);
77987798
} else if cfg!(all(
77997799
not(target_family = "wasm"),
7800-
any(target_os = "linux", target_os = "windows")
7800+
any(
7801+
target_os = "linux",
7802+
target_os = "freebsd",
7803+
target_os = "windows"
7804+
)
78017805
)) {
78027806
// Find the workspace to show the Warp-native modal
78037807
if let Some(workspace) = ctx

app/src/debug_dump.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub(crate) fn run() -> anyhow::Result<()> {
3636
));
3737

3838
// Log some additional windowing system information on Linux.
39-
#[cfg(target_os = "linux")]
39+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
4040
{
4141
use winit::raw_window_handle::HasDisplayHandle as _;
4242

@@ -54,7 +54,7 @@ pub(crate) fn run() -> anyhow::Result<()> {
5454
}
5555
}
5656

57-
#[cfg(any(target_os = "linux", windows))]
57+
#[cfg(any(target_os = "linux", target_os = "freebsd", windows))]
5858
{
5959
use std::ops::Deref as _;
6060

@@ -90,7 +90,7 @@ pub(crate) fn run() -> anyhow::Result<()> {
9090
));
9191
}
9292

93-
#[cfg(target_os = "linux")]
93+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
9494
{
9595
let lspci_info = collect_output_or_suggest_install("lspci");
9696
println!("##################################################");

app/src/lib.rs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -824,12 +824,18 @@ fn run_internal(mut launch_mode: LaunchMode) -> Result<()> {
824824
// Collect errors that occur in run_internal() before the Sentry client is initialized,
825825
// so they can be replayed to Sentry once it's ready.
826826
#[cfg_attr(
827-
not(all(feature = "release_bundle", any(windows, target_os = "linux"))),
827+
not(all(
828+
feature = "release_bundle",
829+
any(windows, any(target_os = "linux", target_os = "freebsd"))
830+
)),
828831
expect(unused_mut)
829832
)]
830833
let mut pre_sentry_errors: Vec<anyhow::Error> = Vec::new();
831834

832-
#[cfg(all(feature = "release_bundle", target_os = "linux"))]
835+
#[cfg(all(
836+
feature = "release_bundle",
837+
any(target_os = "linux", target_os = "freebsd")
838+
))]
833839
if let LaunchMode::App { .. } = launch_mode {
834840
match app_services::linux::pass_startup_args_to_existing_instance(
835841
launch_mode.args().as_ref(),
@@ -887,7 +893,10 @@ fn run_internal(mut launch_mode: LaunchMode) -> Result<()> {
887893
// When the SettingsFile feature flag is enabled, public settings live in
888894
// the TOML-backed store. When disabled, they live in the platform-native
889895
// store (same backend as private). Use the correct one for pre-app reads.
890-
#[cfg_attr(not(any(enable_crash_recovery, target_os = "linux")), expect(unused))]
896+
#[cfg_attr(
897+
not(any(enable_crash_recovery, any(target_os = "linux", target_os = "freebsd"))),
898+
expect(unused)
899+
)]
891900
let prefs_for_public_settings: &dyn warpui_extras::user_preferences::UserPreferences =
892901
if FeatureFlag::SettingsFile.is_enabled() {
893902
public_preferences.as_ref()
@@ -936,7 +945,7 @@ fn run_internal(mut launch_mode: LaunchMode) -> Result<()> {
936945
app_builder.set_dock_menu_builder(|_| app_menus::dock_menu());
937946
}
938947

939-
#[cfg(target_os = "linux")]
948+
#[cfg(any(target_os = "linux", target_os = "freebsd"))]
940949
{
941950
use crate::settings::ForceX11;
942951
use warpui::platform::linux::{self, AppBuilderExt};
@@ -1061,7 +1070,7 @@ fn initialize_app(
10611070
cfg_if::cfg_if! {
10621071
if #[cfg(feature = "integration_tests")] {
10631072
warpui_extras::secure_storage::register_noop(&data_domain, ctx);
1064-
} else if #[cfg(target_os = "linux")] {
1073+
} else if #[cfg(any(target_os = "linux", target_os = "freebsd"))] {
10651074
warpui_extras::secure_storage::register_with_fallback(&data_domain, warp_core::paths::state_dir(), ctx)
10661075
} else if #[cfg(target_os = "windows")] {
10671076
warpui_extras::secure_storage::register_with_dir(&data_domain, warp_core::paths::state_dir(), ctx)
@@ -1997,8 +2006,9 @@ fn app_callbacks(is_integration_test: bool) -> warpui::platform::AppCallbacks {
19972006
let general_settings = GeneralSettings::as_ref(ctx);
19982007
// On Linux or Windows, if we're about to close the final window, we should quit the app instead.
19992008
// On Mac, we do this conditionally based on a user setting.
2000-
let quit_on_last_window_closed = cfg!(any(target_os = "linux", windows))
2001-
|| *general_settings.quit_on_last_window_closed;
2009+
let quit_on_last_window_closed =
2010+
cfg!(any(target_os = "linux", target_os = "freebsd", windows))
2011+
|| *general_settings.quit_on_last_window_closed;
20022012
if ctx.window_ids().count() == 1 && quit_on_last_window_closed {
20032013
log::info!("No windows left, terminating app");
20042014
ctx.terminate_app(TerminationMode::Cancellable, None);

app/src/quit_warning/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,7 @@ impl<'a> QuitWarningDialog<'a> {
468468
shown = true;
469469
} else if cfg!(all(
470470
not(target_family = "wasm"),
471-
any(target_os = "linux", windows)
471+
any(target_os = "linux", target_os = "freebsd", windows)
472472
)) {
473473
// Find a window to show the Warp-native modal in. If there is no active window, use
474474
// one of the windows with a running process.

app/src/settings/cloud_preferences.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,10 @@ impl Platform {
6868
return Self::Mac;
6969
}
7070

71-
if cfg!(all(not(target_family = "wasm"), target_os = "linux")) {
71+
if cfg!(all(
72+
not(target_family = "wasm"),
73+
any(target_os = "linux", target_os = "freebsd")
74+
)) {
7275
return Self::Linux;
7376
}
7477

0 commit comments

Comments
 (0)