Auto merge of #23559 - jdm:uwp-dirs, r=asajeffrey

Remove dirs crate from use in UWP builds.

The dirs crate relies on APIs that aren't available to UWP apps. This adds the ability to hide it from builds that need to run in UWP environments.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/23559)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2019-06-14 04:50:18 -04:00 committed by GitHub
commit 09f9273b2d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 15 additions and 4 deletions

View file

@ -6,6 +6,9 @@ license = "MPL-2.0"
edition = "2018"
publish = false
[features]
uwp = []
[lib]
name = "servo_config"
path = "lib.rs"
@ -29,5 +32,5 @@ servo_config_plugins = { path = "../config_plugins" }
env_logger = "0.6"
std_test_override = { path = "../std_test_override" }
[target.'cfg(not(target_os = "android"))'.dependencies]
[target.'cfg(not(any(target_os = "android", feature = "uwp")))'.dependencies]
dirs = "1.0"

View file

@ -35,9 +35,14 @@ pub fn default_config_dir() -> Option<PathBuf> {
Some(config_dir)
}
#[cfg(target_os = "windows")]
#[cfg(all(target_os = "windows", not(feature = "uwp")))]
pub fn default_config_dir() -> Option<PathBuf> {
let mut config_dir = ::dirs::config_dir().unwrap();
config_dir.push("Servo");
Some(config_dir)
}
#[cfg(all(target_os = "windows", feature = "uwp"))]
pub fn default_config_dir() -> Option<PathBuf> {
None
}

View file

@ -58,7 +58,7 @@ pub fn pref_map() -> &'static Preferences<'static, Prefs> {
&PREFS
}
pub fn add_user_prefs() {
pub(crate) fn add_user_prefs() {
if let Some(path) = user_prefs_path() {
init_user_prefs(path);
}

View file

@ -244,7 +244,7 @@ fn test_set_all_error_on_unknown_field() -> Result<(), Box<dyn Error>> {
Ok(())
}
#[cfg(not(target_os = "android"))]
#[cfg(not(any(target_os = "android", feature = "uwp")))]
#[test]
fn test_default_config_dir_create_read_write() {
let json_str = "{\

View file

@ -22,6 +22,7 @@ max_log_level = ["log/release_max_level_info"]
native-bluetooth = ["bluetooth/native-bluetooth"]
no_wgl = ["canvas/no_wgl"]
raqote_backend = ["canvas/raqote_backend"]
uwp = ["servo_config/uwp"]
webrender_debugger = ["webrender/debugger"]
no_static_freetype = ["webrender/no_static_freetype"]
oculusvr = ["webvr/oculusvr"]

View file

@ -41,4 +41,5 @@ oculusvr = ["libservo/oculusvr"]
raqote_backend = ["libservo/raqote_backend"]
webdriver = ["libservo/webdriver"]
unstable = ["libservo/unstable"]
uwp = ["libservo/uwp"]
webgl_backtrace = ["libservo/webgl_backtrace"]

View file

@ -34,5 +34,6 @@ no_wgl = ["simpleservo/no_wgl"]
oculusvr = ["simpleservo/oculusvr"]
raqote_backend = ["simpleservo/raqote_backend"]
unstable = ["simpleservo/unstable"]
uwp = ["simpleservo/uwp"]
webdriver = ["simpleservo/webdriver"]
webgl_backtrace = ["simpleservo/webgl_backtrace"]