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

Sdk and Gradle update #21160

Closed
wants to merge 8 commits into from

introduce a simple servo library

  • Loading branch information
paulrouget committed Jul 10, 2018
commit b7348f2aeacac5b8fa3c137257ecca207ce5b501

Some generated files are not rendered by default. Learn more.

@@ -1,10 +1,12 @@
[workspace]
members = [
"ports/servo",
"ports/libsimpleservo/",
"tests/unit/*",
]
default-members = [
"ports/servo",
"ports/libsimpleservo/",
"tests/unit/*",
]
exclude = [".cargo"]
@@ -30,6 +30,3 @@ embedder_traits = { path = "../embedder_traits", features = ["tests"] }

[target.'cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))'.dependencies]
xdg = "2.0"

[target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = "0.2"
@@ -6,42 +6,34 @@
//! For linux based platforms, it uses the XDG base directory spec but provides
//! similar abstractions for non-linux platforms.

#[cfg(target_os = "android")]
use android_injected_glue;
#[cfg(any(target_os = "macos", target_os = "windows"))]
use std::env;
#[cfg(target_os = "android")]
use std::ffi::CStr;
use std::path::PathBuf;
#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
use xdg;

#[cfg(all(unix, not(target_os = "macos"), not(target_os = "ios"), not(target_os = "android")))]
pub fn default_config_dir() -> PathBuf {
pub fn default_config_dir() -> Option<PathBuf> {
let xdg_dirs = xdg::BaseDirectories::with_profile("servo", "default").unwrap();
xdg_dirs.get_config_home()
Some(xdg_dirs.get_config_home())
}

#[cfg(target_os = "android")]
#[allow(unsafe_code)]
pub fn default_config_dir() -> PathBuf {
let dir = unsafe {
CStr::from_ptr((*android_injected_glue::get_app().activity).externalDataPath)
};
PathBuf::from(dir.to_str().unwrap())
pub fn default_config_dir() -> Option<PathBuf> {
None
}

#[cfg(target_os = "macos")]
pub fn default_config_dir() -> PathBuf {
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = env::home_dir().unwrap();
config_dir.push("Library");
config_dir.push("Application Support");
config_dir.push("Servo");
config_dir
Some(config_dir)
}

#[cfg(target_os = "windows")]
pub fn default_config_dir() -> PathBuf {
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = match env::var_os("APPDATA") {
Some(appdata_path) => PathBuf::from(appdata_path),
None => {
@@ -52,5 +44,5 @@ pub fn default_config_dir() -> PathBuf {
}
};
config_dir.push("Servo");
config_dir
Some(config_dir)
}
@@ -4,8 +4,6 @@

#![deny(unsafe_code)]

#[cfg(target_os = "android")]
extern crate android_injected_glue;
extern crate embedder_traits;
extern crate euclid;
extern crate getopts;
@@ -183,9 +183,10 @@ pub fn add_user_prefs() {
init_user_prefs(&mut path);
}
None => {
let mut path = default_config_dir();
if path.join("prefs.json").exists() {
init_user_prefs(&mut path);
if let Some(mut path) = default_config_dir() {
if path.join("prefs.json").exists() {
init_user_prefs(&mut path);
}
}
}
}
@@ -48,6 +48,7 @@ fn test_get_set_reset_extend() {
assert_eq!(*PREFS.get("extra.stuff"), PrefValue::Boolean(false));
}

#[cfg(not(target_os = "android"))]
#[test]
fn test_default_config_dir_create_read_write() {
let json_str = "{\
@@ -56,7 +57,7 @@ fn test_default_config_dir_create_read_write() {
\"shell.homepage\": \"https://google.com\"\
}";
let mut expected_json = String::new();
let config_path = basedir::default_config_dir();
let config_path = basedir::default_config_dir().unwrap();

if !config_path.exists() {
fs::create_dir_all(&config_path).unwrap();
@@ -0,0 +1,44 @@
[package]
name = "libsimpleservo"
version = "0.0.1"
build = "build.rs"
authors = ["The Servo Project Developers"]
license = "MPL-2.0"
publish = false

[lib]
name = "simpleservo"
crate-type = ["cdylib"]
test = false
bench = false

[dependencies]
libservo = { path = "../../components/servo" }
log = "0.4"

[target.'cfg(target_os = "android")'.dependencies]
android_injected_glue = "0.2"
android_logger = "0.5"
# FIXME: use `jni = "0.10.2"` once
# https://github.com/prevoty/jni-rs/pull/98 lands and is published
jni = { git = "https://github.com/paulrouget/jni-rs", branch = "return_javavm" }

[target.'cfg(not(target_os = "macos"))'.dependencies]
libc = "0.2"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = "0.3.2"

[build-dependencies]
gl_generator = "0.9"

[features]
default = ["unstable", "default-except-unstable"]
default-except-unstable = ["webdriver", "max_log_level"]
max_log_level = ["log/release_max_level_info"]
webdriver = ["libservo/webdriver"]
energy-profiling = ["libservo/energy-profiling"]
debugmozjs = ["libservo/debugmozjs"]
unstable = ["libservo/unstable"]
googlevr = ["libservo/googlevr"]
oculusvr = ["libservo/oculusvr"]
@@ -0,0 +1,3 @@
This is a basic wrapper around Servo. While libservo itself (/components/servo/) offers a lot of flexibility,
libsimpleservo (/ports/libsimpleservo/) tries to make it easier to embed Servo, without much configuration needed.
It is limited to only one view (no tabs, no multiple rendering area).
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.