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

Move servoshell code into an internal lib crate #31439

Merged
merged 2 commits into from
Feb 28, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions ports/servoshell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ edition = "2021"
build = "build.rs"
publish = false

[lib]
name = "servoshell"
path = "lib.rs"
bench = false

[[bin]]
name = "servo"
path = "main.rs"
Expand Down
38 changes: 38 additions & 0 deletions ports/servoshell/main2.rs → ports/servoshell/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,44 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */

// For Android, see /support/android/apk/ + /ports/jniapi/.
#![cfg(not(target_os = "android"))]

#[cfg(any(target_os = "macos", target_os = "linux"))]
#[macro_use]
extern crate sig;

#[cfg(test)]
mod test;

mod app;
mod backtrace;
mod crash_handler;
mod egui_glue;
mod embedder;
mod events_loop;
mod geometry;
mod headed_window;
mod headless_window;
mod keyutils;
mod minibrowser;
mod parser;
mod prefs;
mod resources;
mod webview;
mod window_trait;

pub mod platform {
#[cfg(target_os = "macos")]
pub use crate::platform::macos::deinit;

#[cfg(target_os = "macos")]
pub mod macos;

#[cfg(not(target_os = "macos"))]
pub fn deinit(_clean_shutdown: bool) {}
}

use std::io::Write;
use std::{env, panic, process, thread};

Expand Down
52 changes: 7 additions & 45 deletions ports/servoshell/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,52 +20,14 @@
// mode is turned on.
#![cfg_attr(not(debug_assertions), windows_subsystem = "windows")]

cfg_if::cfg_if! {
if #[cfg(not(target_os = "android"))] {
#[cfg(any(target_os = "macos", target_os = "linux"))]
#[macro_use]
extern crate sig;

#[cfg(test)]
mod test;

mod app;
mod backtrace;
mod crash_handler;
mod egui_glue;
mod embedder;
mod events_loop;
mod geometry;
mod headed_window;
mod headless_window;
mod keyutils;
mod main2;
mod minibrowser;
mod parser;
mod prefs;
mod resources;
mod webview;
mod window_trait;

pub mod platform {
#[cfg(target_os = "macos")]
pub use crate::platform::macos::deinit;

#[cfg(target_os = "macos")]
pub mod macos;

#[cfg(not(target_os = "macos"))]
pub fn deinit(_clean_shutdown: bool) {}
}

pub fn main() {
main2::main()
}
} else {
pub fn main() {
fn main() {
cfg_if::cfg_if! {
if #[cfg(not(target_os = "android"))] {
servoshell::main()
} else {
println!(
"Cannot start /ports/servo/ on Android. \
Use /support/android/apk/ + /ports/libsimpleservo/ instead"
"Cannot start /ports/servoshell/ on Android. \
Use /support/android/apk/ + /ports/jniapi/ instead"
);
}
}
Expand Down