mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
Support passing in arguments from embedding. Read arguments for Magic Leap from SERVO_ARGS env var.
This commit is contained in:
parent
d0e9acf1eb
commit
a207574b4c
10 changed files with 46 additions and 18 deletions
|
@ -9,7 +9,6 @@ publish = false
|
|||
[dependencies]
|
||||
libservo = { path = "../../../components/servo" }
|
||||
log = "0.4"
|
||||
serde_json = "1.0"
|
||||
|
||||
[target.'cfg(not(target_os = "macos"))'.dependencies]
|
||||
libc = "0.2"
|
||||
|
|
|
@ -41,7 +41,7 @@ thread_local! {
|
|||
pub use servo::embedder_traits::EventLoopWaker;
|
||||
|
||||
pub struct InitOptions {
|
||||
pub args: Option<String>,
|
||||
pub args: Vec<String>,
|
||||
pub url: Option<String>,
|
||||
pub coordinates: Coordinates,
|
||||
pub density: f32,
|
||||
|
@ -135,16 +135,15 @@ pub fn servo_version() -> String {
|
|||
/// Initialize Servo. At that point, we need a valid GL context.
|
||||
/// In the future, this will be done in multiple steps.
|
||||
pub fn init(
|
||||
init_opts: InitOptions,
|
||||
mut init_opts: InitOptions,
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
waker: Box<dyn EventLoopWaker>,
|
||||
callbacks: Box<dyn HostTrait>,
|
||||
) -> Result<(), &'static str> {
|
||||
resources::set(Box::new(ResourceReaderInstance::new()));
|
||||
|
||||
if let Some(args) = init_opts.args {
|
||||
let mut args: Vec<String> = serde_json::from_str(&args)
|
||||
.map_err(|_| "Invalid arguments. Servo arguments must be formatted as a JSON array")?;
|
||||
let mut args = mem::replace(&mut init_opts.args, vec![]);
|
||||
if !args.is_empty() {
|
||||
// opts::from_cmdline_args expects the first argument to be the binary name.
|
||||
args.insert(0, "servo".to_string());
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue