diff options
author | bors-servo <lbergstrom+bors@mozilla.com> | 2019-07-02 23:55:44 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-02 23:55:44 -0400 |
commit | 50033878a6d687a54ee5b3d1631cca2bcc32e508 (patch) | |
tree | 85ca839949d0c48cec32a486ca041fe7e6931b54 | |
parent | a7ff87f0e97447fbe347fe0d188fad524c80ffa8 (diff) | |
parent | 6609b098d6f12e6ccaeb83783778efa80fd20271 (diff) | |
download | servo-50033878a6d687a54ee5b3d1631cca2bcc32e508.tar.gz servo-50033878a6d687a54ee5b3d1631cca2bcc32e508.zip |
Auto merge of #23676 - servo:check, r=Manishearth
Share more `./mach build` logic with mach check, doc, test-unit
Fixes #23659
<!-- 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/23676)
<!-- Reviewable:end -->
32 files changed, 272 insertions, 306 deletions
diff --git a/components/canvas/Cargo.toml b/components/canvas/Cargo.toml index 6e6fb2b0a76..906fa84b434 100644 --- a/components/canvas/Cargo.toml +++ b/components/canvas/Cargo.toml @@ -11,10 +11,10 @@ name = "canvas" path = "lib.rs" [features] -azure_backend = ["azure"] -default = ["azure_backend"] +canvas2d-azure = ["azure"] +canvas2d-raqote = ["raqote"] +default = ["canvas2d-azure"] webgl_backtrace = ["canvas_traits/webgl_backtrace"] -raqote_backend = ["raqote"] no_wgl = ["offscreen_gl_context/no_wgl"] [dependencies] diff --git a/components/canvas/build.rs b/components/canvas/build.rs new file mode 100644 index 00000000000..17010bce69d --- /dev/null +++ b/components/canvas/build.rs @@ -0,0 +1,20 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * 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/. */ + +fn main() { + let azure = std::env::var_os("CARGO_FEATURE_CANVAS2D_AZURE").is_some(); + let raqote = std::env::var_os("CARGO_FEATURE_CANVAS2D_RAQOTE").is_some(); + + if !(azure || raqote) { + error("Must enable one of the `canvas2d-azure` or `canvas2d-raqote` features.") + } + if azure && raqote { + error("Must not enable both of the `canvas2d-azure` and `canvas2d-raqote` features.") + } +} + +fn error(message: &str) { + print!("\n\n Error: {}\n\n", message); + std::process::exit(1) +} diff --git a/components/canvas/canvas_data.rs b/components/canvas/canvas_data.rs index 79adbee7df8..aa6539ebbb9 100644 --- a/components/canvas/canvas_data.rs +++ b/components/canvas/canvas_data.rs @@ -281,92 +281,92 @@ pub trait GenericDrawTarget { #[derive(Clone)] pub enum ExtendMode { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::ExtendMode), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } pub enum GradientStop { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::AzGradientStop), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } pub enum GradientStops { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::GradientStops), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum Color { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::Color), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum CompositionOp { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::CompositionOp), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } pub enum SurfaceFormat { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::SurfaceFormat), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum SourceSurface { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::SourceSurface), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } pub enum Path { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::Path), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum Pattern { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::Pattern), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } pub enum DrawSurfaceOptions { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::DrawSurfaceOptions), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum DrawOptions { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::DrawOptions), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(()), } #[derive(Clone)] pub enum StrokeOptions<'a> { - #[cfg(feature = "azure_backend")] + #[cfg(feature = "canvas2d-azure")] Azure(azure::azure_hl::StrokeOptions<'a>), - #[cfg(feature = "raqote_backend")] + #[cfg(feature = "canvas2d-raqote")] Raqote(PhantomData<&'a ()>), } @@ -391,12 +391,12 @@ pub struct CanvasData<'a> { pub canvas_id: CanvasId, } -#[cfg(feature = "azure_backend")] +#[cfg(feature = "canvas2d-azure")] fn create_backend() -> Box<dyn Backend> { Box::new(crate::azure_backend::AzureBackend) } -#[cfg(feature = "raqote_backend")] +#[cfg(feature = "canvas2d-raqote")] fn create_backend() -> Box<dyn Backend> { Box::new(crate::raqote_backend::RaqoteBackend) } diff --git a/components/canvas/lib.rs b/components/canvas/lib.rs index 28dd1e04f5d..ba10f02636c 100644 --- a/components/canvas/lib.rs +++ b/components/canvas/lib.rs @@ -7,10 +7,10 @@ #[macro_use] extern crate log; -#[cfg(feature = "azure_backend")] +#[cfg(feature = "canvas2d-azure")] mod azure_backend; -#[cfg(feature = "raqote_backend")] +#[cfg(feature = "canvas2d-raqote")] mod raqote_backend; pub mod canvas_data; diff --git a/components/constellation/Cargo.toml b/components/constellation/Cargo.toml index 0831cd33b0c..718e537e64b 100644 --- a/components/constellation/Cargo.toml +++ b/components/constellation/Cargo.toml @@ -11,8 +11,8 @@ name = "constellation" path = "lib.rs" [features] -azure_backend = ["canvas/azure_backend"] -raqote_backend = ["canvas/raqote_backend"] +canvas2d-azure = ["canvas/canvas2d-azure"] +canvas2d-raqote = ["canvas/canvas2d-raqote"] no_wgl = ["canvas/no_wgl"] [dependencies] diff --git a/components/constellation/lib.rs b/components/constellation/lib.rs index 2beee10e78d..b102a0bc2b5 100644 --- a/components/constellation/lib.rs +++ b/components/constellation/lib.rs @@ -3,7 +3,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ #![deny(unsafe_code)] -#![cfg_attr(feature = "unstable", feature(conservative_impl_trait))] #[macro_use] extern crate crossbeam_channel; diff --git a/components/gfx/Cargo.toml b/components/gfx/Cargo.toml index 3818a2f30a6..a95fb6d1046 100644 --- a/components/gfx/Cargo.toml +++ b/components/gfx/Cargo.toml @@ -13,9 +13,6 @@ path = "lib.rs" test = false doctest = false -[features] -unstable = ["packed_simd"] - [dependencies] app_units = "0.7" bitflags = "1.0" @@ -31,7 +28,7 @@ log = "0.4" malloc_size_of = { path = "../malloc_size_of" } net_traits = {path = "../net_traits"} ordered-float = "1.0" -packed_simd = {version = "0.3", optional = true} +packed_simd = "0.3" range = {path = "../range"} serde = "1.0" servo_arc = {path = "../servo_arc"} diff --git a/components/gfx/text/glyph.rs b/components/gfx/text/glyph.rs index df8180688f0..82d002e61f4 100644 --- a/components/gfx/text/glyph.rs +++ b/components/gfx/text/glyph.rs @@ -4,10 +4,7 @@ use app_units::Au; use euclid::Point2D; -#[cfg(all( - feature = "unstable", - any(target_feature = "sse2", target_feature = "neon") -))] +#[cfg(any(target_feature = "sse2", target_feature = "neon"))] use packed_simd::u32x4; use range::{self, EachIndex, Range, RangeIndex}; use std::cmp::{Ordering, PartialOrd}; @@ -75,7 +72,6 @@ pub type GlyphId = u32; // TODO: make this more type-safe. const FLAG_CHAR_IS_SPACE: u32 = 0x40000000; -#[cfg(feature = "unstable")] #[cfg(any(target_feature = "sse2", target_feature = "neon"))] const FLAG_CHAR_IS_SPACE_SHIFT: u32 = 30; const FLAG_IS_SIMPLE_GLYPH: u32 = 0x80000000; @@ -625,7 +621,6 @@ impl<'a> GlyphStore { } #[inline] - #[cfg(feature = "unstable")] #[cfg(any(target_feature = "sse2", target_feature = "neon"))] fn advance_for_byte_range_simple_glyphs( &self, @@ -644,7 +639,7 @@ impl<'a> GlyphStore { for i in 0..num_simd_iterations { let offset = begin + i * 4; - let v = u32x4::load_unaligned(&buf[offset..]); + let v = u32x4::from_slice_unaligned(&buf[offset..]); let advance = (v & advance_mask) >> GLYPH_ADVANCE_SHIFT; let spaces = (v & space_flag_mask) >> FLAG_CHAR_IS_SPACE_SHIFT; simd_advance = simd_advance + advance; @@ -672,10 +667,7 @@ impl<'a> GlyphStore { /// When SIMD isn't available, fallback to the slow path. #[inline] - #[cfg(not(all( - feature = "unstable", - any(target_feature = "sse2", target_feature = "neon") - )))] + #[cfg(not(any(target_feature = "sse2", target_feature = "neon")))] fn advance_for_byte_range_simple_glyphs( &self, range: &Range<ByteIndex>, @@ -686,7 +678,6 @@ impl<'a> GlyphStore { /// Used for SIMD. #[inline] - #[cfg(feature = "unstable")] #[cfg(any(target_feature = "sse2", target_feature = "neon"))] #[allow(unsafe_code)] fn transmute_entry_buffer_to_u32_buffer(&self) -> &[u32] { diff --git a/components/layout_thread/Cargo.toml b/components/layout_thread/Cargo.toml index 8c98a809c1a..9ae8a6f953d 100644 --- a/components/layout_thread/Cargo.toml +++ b/components/layout_thread/Cargo.toml @@ -10,9 +10,6 @@ publish = false name = "layout_thread" path = "lib.rs" -[features] -unstable = ["parking_lot/nightly"] - [dependencies] app_units = "0.7" atomic_refcell = "0.1" @@ -36,7 +33,7 @@ malloc_size_of = { path = "../malloc_size_of" } metrics = {path = "../metrics"} msg = {path = "../msg"} net_traits = {path = "../net_traits"} -parking_lot = "0.8" +parking_lot = {version = "0.8", features = ["nightly"]} profile_traits = {path = "../profile_traits"} range = {path = "../range"} rayon = "1" diff --git a/components/profile/Cargo.toml b/components/profile/Cargo.toml index c1d14c3c31a..baf7d340cb2 100644 --- a/components/profile/Cargo.toml +++ b/components/profile/Cargo.toml @@ -10,9 +10,6 @@ publish = false name = "profile" path = "lib.rs" -[features] -unstable = ["servo_allocator"] - [dependencies] profile_traits = {path = "../profile_traits"} influent = "0.5" @@ -33,4 +30,4 @@ regex = "1.1" [target.'cfg(not(target_os = "windows"))'.dependencies] libc = "0.2" -servo_allocator = {path = "../allocator", optional = true} +servo_allocator = {path = "../allocator"} diff --git a/components/profile/mem.rs b/components/profile/mem.rs index cf67560ad83..bb4688f397c 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -389,14 +389,14 @@ mod system_reporter { use super::{JEMALLOC_HEAP_ALLOCATED_STR, SYSTEM_HEAP_ALLOCATED_STR}; #[cfg(target_os = "linux")] use libc::c_int; - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] use libc::{c_void, size_t}; use profile_traits::mem::{Report, ReportKind, ReporterRequest}; - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] use std::ffi::CString; - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] use std::mem::size_of; - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] use std::ptr::null_mut; #[cfg(target_os = "macos")] use task_info::task_basic_info::{resident_size, virtual_size}; @@ -495,10 +495,10 @@ mod system_reporter { None } - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] use servo_allocator::jemalloc_sys::mallctl; - #[cfg(all(feature = "unstable", not(target_os = "windows")))] + #[cfg(not(target_os = "windows"))] fn jemalloc_stat(value_name: &str) -> Option<usize> { // Before we request the measurement of interest, we first send an "epoch" // request. Without that jemalloc gives cached statistics(!) which can be @@ -545,7 +545,7 @@ mod system_reporter { Some(value as usize) } - #[cfg(any(target_os = "windows", not(feature = "unstable")))] + #[cfg(target_os = "windows")] fn jemalloc_stat(_value_name: &str) -> Option<usize> { None } diff --git a/components/script/Cargo.toml b/components/script/Cargo.toml index deeb5f7a3bf..1b9dade72eb 100644 --- a/components/script/Cargo.toml +++ b/components/script/Cargo.toml @@ -15,7 +15,6 @@ path = "lib.rs" [features] debugmozjs = ['js/debugmozjs'] profilemozjs = ['js/profilemozjs'] -unstable = [] unrooted_must_root_lint = ["script_plugins/unrooted_must_root_lint"] webidl_lint = ["script_plugins/webidl_lint"] default = ["unrooted_must_root_lint", "webidl_lint"] diff --git a/components/script/dom/bindings/conversions.rs b/components/script/dom/bindings/conversions.rs index 161354479b6..442648fb9c8 100644 --- a/components/script/dom/bindings/conversions.rs +++ b/components/script/dom/bindings/conversions.rs @@ -69,10 +69,7 @@ pub trait IDLInterface { } /// A trait to mark an IDL interface as deriving from another one. -#[cfg_attr( - feature = "unstable", - rustc_on_unimplemented(message = "The IDL interface `{Self}` is not derived from `{T}`.") -)] +#[rustc_on_unimplemented(message = "The IDL interface `{Self}` is not derived from `{T}`.")] pub trait DerivedFrom<T: Castable>: Castable {} impl<T: Float + ToJSValConvertible> ToJSValConvertible for Finite<T> { diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs index 228015b1275..c87c83a2469 100644 --- a/components/script/dom/bindings/root.rs +++ b/components/script/dom/bindings/root.rs @@ -330,13 +330,13 @@ impl<T: DomObject> Deref for Dom<T> { unsafe impl<T: DomObject> JSTraceable for Dom<T> { unsafe fn trace(&self, trc: *mut JSTracer) { - #[cfg(all(feature = "unstable", debug_assertions))] - let trace_str = format!("for {} on heap", ::std::intrinsics::type_name::<T>()); - #[cfg(all(feature = "unstable", debug_assertions))] - let trace_info = &trace_str[..]; - #[cfg(not(all(feature = "unstable", debug_assertions)))] - let trace_info = "for DOM object on heap"; - + let trace_string; + let trace_info = if cfg!(debug_assertions) { + trace_string = format!("for {} on heap", ::std::intrinsics::type_name::<T>()); + &trace_string[..] + } else { + "for DOM object on heap" + }; trace_reflector(trc, trace_info, (*self.ptr.as_ptr()).reflector()); } } diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs index a1afdc34a82..596fd711599 100644 --- a/components/script/dom/window.rs +++ b/components/script/dom/window.rs @@ -938,10 +938,7 @@ impl WindowMethods for Window { #[allow(unsafe_code)] fn Trap(&self) { - #[cfg(feature = "unstable")] - unsafe { - ::std::intrinsics::breakpoint() - } + unsafe { ::std::intrinsics::breakpoint() } } #[allow(unsafe_code)] diff --git a/components/script/lib.rs b/components/script/lib.rs index 9bc2d929b13..1be386dfd1c 100644 --- a/components/script/lib.rs +++ b/components/script/lib.rs @@ -2,11 +2,11 @@ * 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/. */ -#![cfg_attr(feature = "unstable", feature(core_intrinsics))] -#![cfg_attr(feature = "unstable", feature(on_unimplemented))] #![feature(const_fn)] +#![feature(core_intrinsics)] #![feature(drain_filter)] #![feature(inner_deref)] +#![feature(on_unimplemented)] #![feature(plugin)] #![feature(type_alias_enum_variants)] #![deny(unsafe_code)] diff --git a/components/script/task.rs b/components/script/task.rs index c8b4b438deb..61f9bf436dd 100644 --- a/components/script/task.rs +++ b/components/script/task.rs @@ -32,14 +32,7 @@ macro_rules! task { pub trait TaskOnce: Send { #[allow(unsafe_code)] fn name(&self) -> &'static str { - #[cfg(feature = "unstable")] - unsafe { - ::std::intrinsics::type_name::<Self>() - } - #[cfg(not(feature = "unstable"))] - { - "(task name unknown)" - } + unsafe { ::std::intrinsics::type_name::<Self>() } } fn run_once(self); diff --git a/components/servo/Cargo.toml b/components/servo/Cargo.toml index 7d03959d767..de870ef2e0f 100644 --- a/components/servo/Cargo.toml +++ b/components/servo/Cargo.toml @@ -12,7 +12,8 @@ path = "lib.rs" crate-type = ["rlib"] [features] -azure_backend = ["canvas/azure_backend"] +canvas2d-azure = ["canvas/canvas2d-azure"] +canvas2d-raqote = ["canvas/canvas2d-raqote"] debugmozjs = ["script/debugmozjs"] energy-profiling = ["profile_traits/energy-profiling"] profilemozjs = ["script/profilemozjs"] @@ -21,16 +22,10 @@ js_backtrace = ["script/js_backtrace"] 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"] -unstable = [ - "euclid/unstable", - "profile/unstable", - "script/unstable", -] webdriver = ["webdriver_server"] webgl_backtrace = [ "script/webgl_backtrace", diff --git a/etc/taskcluster/decision_task.py b/etc/taskcluster/decision_task.py index e8e6479c052..3bcd1db3658 100644 --- a/etc/taskcluster/decision_task.py +++ b/etc/taskcluster/decision_task.py @@ -183,9 +183,8 @@ def linux_tidy_unit_docs(): ./mach build --dev ./mach test-unit ./mach package --dev - ./mach build --dev --features raqote_backend + ./mach build --dev --features canvas2d-raqote ./mach build --dev --libsimpleservo - ./mach build --dev --no-default-features --features default-except-unstable ./mach test-tidy --no-progress --self-test ./etc/memory_reports_over_time.py --test @@ -194,12 +193,24 @@ def linux_tidy_unit_docs(): ./etc/ci/check_no_panic.sh RUSTDOCFLAGS="--disable-minification" ./mach doc - cd target/doc - git init - time git add . - git -c user.name="Taskcluster" -c user.email="" \ - commit -q -m "Rebuild Servo documentation" - git bundle create docs.bundle HEAD + ( + cd target/doc + git init + git add . + git -c user.name="Taskcluster" -c user.email="" \ + commit -q -m "Rebuild Servo documentation" + git bundle create docs.bundle HEAD + ) + + """ + # Because `rustdoc` needs metadata of dependency crates, + # `cargo doc` does almost all of the work that `cargo check` does. + # Therefore, when running them in this order the second command does very little + # and should finish quickly. + # The reverse order would not increase the total amount of work to do, + # but would reduce the amount of parallelism available. + """ + ./mach check """) .with_artifacts("/repo/target/doc/docs.bundle") .find_or_create("docs." + CONFIG.task_id()) diff --git a/ports/glutin/Cargo.toml b/ports/glutin/Cargo.toml index 54ddcb769cb..a75452b2660 100644 --- a/ports/glutin/Cargo.toml +++ b/ports/glutin/Cargo.toml @@ -27,17 +27,15 @@ OriginalFilename = "servo.exe" ProductName = "Servo" [features] -azure_backend = ["libservo/azure_backend"] -default = ["unstable", "default-except-unstable"] -default-except-unstable = ["webdriver", "max_log_level"] +canvas2d-azure = ["libservo/canvas2d-azure"] +canvas2d-raqote = ["libservo/canvas2d-raqote"] +default = ["webdriver", "max_log_level"] energy-profiling = ["libservo/energy-profiling"] debugmozjs = ["libservo/debugmozjs"] js_backtrace = ["libservo/js_backtrace"] max_log_level = ["log/release_max_level_info"] native-bluetooth = ["libservo/native-bluetooth"] profilemozjs = ["libservo/profilemozjs"] -raqote_backend = ["libservo/raqote_backend"] -unstable = ["libservo/unstable"] webdriver = ["libservo/webdriver"] webgl_backtrace = ["libservo/webgl_backtrace"] webrender_debugger = ["libservo/webrender_debugger"] diff --git a/ports/glutin/main.rs b/ports/glutin/main.rs index 23be648bad8..50da58121bc 100644 --- a/ports/glutin/main.rs +++ b/ports/glutin/main.rs @@ -15,7 +15,7 @@ //! //! [glutin]: https://github.com/tomaka/glutin -#![cfg_attr(feature = "unstable", feature(core_intrinsics))] +#![feature(core_intrinsics)] #[cfg(not(target_os = "android"))] include!("main2.rs"); diff --git a/ports/glutin/main2.rs b/ports/glutin/main2.rs index 496c0515e19..579c97d3a23 100644 --- a/ports/glutin/main2.rs +++ b/ports/glutin/main2.rs @@ -6,7 +6,7 @@ extern crate lazy_static; #[macro_use] extern crate log; -#[cfg(all(feature = "unstable", any(target_os = "macos", target_os = "linux")))] +#[cfg(any(target_os = "macos", target_os = "linux"))] #[macro_use] extern crate sig; @@ -42,13 +42,10 @@ pub mod platform { pub fn deinit() {} } -#[cfg(any( - not(feature = "unstable"), - not(any(target_os = "macos", target_os = "linux")) -))] +#[cfg(not(any(target_os = "macos", target_os = "linux")))] fn install_crash_handler() {} -#[cfg(all(feature = "unstable", any(target_os = "macos", target_os = "linux")))] +#[cfg(any(target_os = "macos", target_os = "linux"))] fn install_crash_handler() { use backtrace::Backtrace; use libc::_exit; diff --git a/ports/libmlservo/Cargo.toml b/ports/libmlservo/Cargo.toml index ac04dc44c0f..0c8389269c3 100644 --- a/ports/libmlservo/Cargo.toml +++ b/ports/libmlservo/Cargo.toml @@ -13,8 +13,8 @@ test = false bench = false [features] -azure_backend = ["simpleservo/azure_backend"] -raqote_backend = ["simpleservo/raqote_backend"] +canvas2d-azure = ["simpleservo/canvas2d-azure"] +canvas2d-raqote = ["simpleservo/canvas2d-raqote"] [dependencies] libservo = { path = "../../components/servo", features = ["no_static_freetype"] } diff --git a/ports/libsimpleservo/api/Cargo.toml b/ports/libsimpleservo/api/Cargo.toml index 8e1726a8b02..68f0b7f1816 100644 --- a/ports/libsimpleservo/api/Cargo.toml +++ b/ports/libsimpleservo/api/Cargo.toml @@ -26,9 +26,9 @@ libloading = "0.5" gl_generator = "0.11" [features] -azure_backend = ["libservo/azure_backend"] -default = ["unstable", "default-except-unstable"] -default-except-unstable = ["webdriver", "max_log_level"] +canvas2d-azure = ["libservo/canvas2d-azure"] +canvas2d-raqote = ["libservo/canvas2d-raqote"] +default = ["webdriver", "max_log_level"] debugmozjs = ["libservo/debugmozjs"] energy-profiling = ["libservo/energy-profiling"] googlevr = ["libservo/googlevr"] @@ -38,8 +38,6 @@ native-bluetooth = ["libservo/native-bluetooth"] no_static_freetype = ["libservo/no_static_freetype"] no_wgl = ["libservo/no_wgl"] oculusvr = ["libservo/oculusvr"] -raqote_backend = ["libservo/raqote_backend"] webdriver = ["libservo/webdriver"] -unstable = ["libservo/unstable"] uwp = ["libservo/uwp"] webgl_backtrace = ["libservo/webgl_backtrace"] diff --git a/ports/libsimpleservo/capi/Cargo.toml b/ports/libsimpleservo/capi/Cargo.toml index 1ca469d82c0..8bcf34aad0b 100644 --- a/ports/libsimpleservo/capi/Cargo.toml +++ b/ports/libsimpleservo/capi/Cargo.toml @@ -21,10 +21,10 @@ env_logger = "0.6" cbindgen = "0.8" [features] -azure_backend = ["simpleservo/azure_backend"] +canvas2d-azure = ["simpleservo/canvas2d-azure"] +canvas2d-raqote = ["simpleservo/canvas2d-raqote"] debugmozjs = ["simpleservo/debugmozjs"] -default = ["unstable", "default-except-unstable"] -default-except-unstable = ["webdriver", "max_log_level"] +default = ["webdriver", "max_log_level"] energy-profiling = ["simpleservo/energy-profiling"] googlevr = ["simpleservo/googlevr"] js_backtrace = ["simpleservo/js_backtrace"] @@ -32,8 +32,6 @@ max_log_level = ["simpleservo/max_log_level"] native-bluetooth = ["simpleservo/native-bluetooth"] 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"] diff --git a/ports/libsimpleservo/jniapi/Cargo.toml b/ports/libsimpleservo/jniapi/Cargo.toml index 95a841770a0..98838fafcb3 100644 --- a/ports/libsimpleservo/jniapi/Cargo.toml +++ b/ports/libsimpleservo/jniapi/Cargo.toml @@ -26,17 +26,15 @@ simpleservo = { path = "../api" } cc = "1.0" [features] -azure_backend = ["simpleservo/azure_backend"] +canvas2d-azure = ["simpleservo/canvas2d-azure"] +canvas2d-raqote = ["simpleservo/canvas2d-raqote"] debugmozjs = ["simpleservo/debugmozjs"] -default = ["unstable", "default-except-unstable"] -default-except-unstable = ["webdriver", "max_log_level"] +default = ["webdriver", "max_log_level"] energy-profiling = ["simpleservo/energy-profiling"] googlevr = ["simpleservo/googlevr"] js_backtrace = ["simpleservo/js_backtrace"] max_log_level = ["simpleservo/max_log_level"] native-bluetooth = ["simpleservo/native-bluetooth"] oculusvr = ["simpleservo/oculusvr"] -raqote_backend = ["simpleservo/raqote_backend"] -unstable = ["simpleservo/unstable"] webdriver = ["simpleservo/webdriver"] webgl_backtrace = ["simpleservo/webgl_backtrace"] diff --git a/python/servo/bootstrap_commands.py b/python/servo/bootstrap_commands.py index a2df3aaef33..605b78362d8 100644 --- a/python/servo/bootstrap_commands.py +++ b/python/servo/bootstrap_commands.py @@ -34,18 +34,6 @@ from servo.util import delete, download_bytes, download_file, extract, check_has @CommandProvider class MachCommands(CommandBase): - @Command('env', - description='Print environment setup commands', - category='bootstrap') - def env(self): - env = self.build_env() - print("export RUSTFLAGS=%s" % env.get("RUSTFLAGS", "")) - print("export PATH=%s" % env.get("PATH", "")) - if sys.platform == "darwin": - print("export DYLD_LIBRARY_PATH=%s" % env.get("DYLD_LIBRARY_PATH", "")) - else: - print("export LD_LIBRARY_PATH=%s" % env.get("LD_LIBRARY_PATH", "")) - @Command('bootstrap', description='Install required packages for building.', category='bootstrap') diff --git a/python/servo/build_commands.py b/python/servo/build_commands.py index 2010bfbce9b..3937b73efd0 100644 --- a/python/servo/build_commands.py +++ b/python/servo/build_commands.py @@ -146,9 +146,6 @@ class MachCommands(CommandBase): @Command('build', description='Build Servo', category='build') - @CommandArgument('--target', '-t', - default=None, - help='Cross compile for given target platform') @CommandArgument('--release', '-r', action='store_true', help='Build in release mode') @@ -158,25 +155,9 @@ class MachCommands(CommandBase): @CommandArgument('--jobs', '-j', default=None, help='Number of jobs to run in parallel') - @CommandArgument('--features', - default=None, - help='Space-separated list of features to also build', - nargs='+') - @CommandArgument('--android', - default=None, - action='store_true', - help='Build for Android') - @CommandArgument('--magicleap', - default=None, - action='store_true', - help='Build for Magic Leap') @CommandArgument('--no-package', action='store_true', help='For Android, disable packaging into a .apk after building') - @CommandArgument('--debug-mozjs', - default=None, - action='store_true', - help='Enable debug assertions in mozjs') @CommandArgument('--verbose', '-v', action='store_true', help='Print verbose output') @@ -185,46 +166,14 @@ class MachCommands(CommandBase): help='Print very verbose output') @CommandArgument('params', nargs='...', help="Command-line arguments to be passed through to Cargo") - @CommandArgument('--with-debug-assertions', - default=None, - action='store_true', - help='Enable debug assertions in release') - @CommandArgument('--libsimpleservo', - default=None, - action='store_true', - help='Build the libsimpleservo library instead of the servo executable') - @CommandArgument('--with-frame-pointer', - default=None, - action='store_true', - help='Build with frame pointer enabled, used by the background hang monitor.') - @CommandArgument('--with-raqote', default=None, action='store_true') - @CommandArgument('--without-wgl', default=None, action='store_true') - def build(self, target=None, release=False, dev=False, jobs=None, - features=None, android=None, magicleap=None, no_package=False, verbose=False, very_verbose=False, - debug_mozjs=False, params=None, with_debug_assertions=False, - libsimpleservo=False, with_frame_pointer=False, with_raqote=False, without_wgl=False): - + @CommandBase.build_like_command_arguments + def build(self, release=False, dev=False, jobs=None, params=None, + no_package=False, verbose=False, very_verbose=False, + target=None, android=False, magicleap=False, libsimpleservo=False, + features=None, **kwargs): opts = params or [] - - if android is None: - android = self.config["build"]["android"] - features = features or self.servo_features() - - if target and android: - print("Please specify either --target or --android.") - sys.exit(1) - - if android: - target = self.config["android"]["target"] - - if not magicleap: - features += ["native-bluetooth"] - - if magicleap and not target: - target = "aarch64-linux-android" - - if target and not android and not magicleap: - android = self.handle_android_target(target) + features = features or [] + target, android = self.pick_target_triple(target, android, magicleap) target_path = base_path = self.get_target_dir() if android: @@ -278,44 +227,13 @@ class MachCommands(CommandBase): check_call(["rustup" + BIN_SUFFIX, "target", "add", "--toolchain", self.toolchain(), target]) - opts += ["--target", target] - env = self.build_env(target=target, is_build=True) self.ensure_bootstrapped(target=target) self.ensure_clobbered() - self.add_manifest_path(opts, android, libsimpleservo) - - if debug_mozjs: - features += ["debugmozjs"] - - if with_frame_pointer: - env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C force-frame-pointers=yes" - features += ["profilemozjs"] - - if with_raqote: - features += ["raqote_backend"] - - if without_wgl: - features += ["no_wgl"] - - if self.config["build"]["webgl-backtrace"]: - features += ["webgl-backtrace"] - if self.config["build"]["dom-backtrace"]: - features += ["dom-backtrace"] - - if "raqote_backend" not in features: - features += ["azure_backend"] - - if features: - opts += ["--features", "%s" % ' '.join(features)] - build_start = time() env["CARGO_TARGET_DIR"] = target_path - if with_debug_assertions: - env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions" - host = host_triple() if 'apple-darwin' in host and (not target or target == host): if 'CXXFLAGS' not in env: @@ -612,7 +530,13 @@ class MachCommands(CommandBase): env.setdefault("CC", "clang") env.setdefault("CXX", "clang++") - status = self.call_rustup_run(["cargo", "build"] + opts, env=env, verbose=verbose) + status = self.run_cargo_build_like_command( + "build", opts, env=env, verbose=verbose, + target=target, android=android, magicleap=magicleap, libsimpleservo=libsimpleservo, + features=features, **kwargs + ) + status = 0 + elapsed = time() - build_start # Do some additional things if the build succeeded @@ -712,14 +636,11 @@ class MachCommands(CommandBase): print('Removing virtualenv directory: %s' % virtualenv_path) shutil.rmtree(virtualenv_path) - opts = [] - if manifest_path: - opts += ["--manifest-path", manifest_path] + opts = ["--manifest-path", manifest_path or path.join(self.context.topdir, "Cargo.toml")] if verbose: opts += ["-v"] opts += params - return check_call(["cargo", "clean"] + opts, - env=self.build_env(), cwd=self.ports_glutin_crate(), verbose=verbose) + return check_call(["cargo", "clean"] + opts, env=self.build_env(), verbose=verbose) def package_gstreamer_dlls(servo_exe_dir, target): diff --git a/python/servo/command_base.py b/python/servo/command_base.py index 0b7ed2cf50b..838e03f910c 100644 --- a/python/servo/command_base.py +++ b/python/servo/command_base.py @@ -28,6 +28,7 @@ from servo.util import download_file import urllib2 from bootstrap import check_gstreamer_lib +from mach.decorators import CommandArgument from mach.registrar import Registrar import toml @@ -731,34 +732,130 @@ install them, let us know by filing a bug!") return env - def ports_glutin_crate(self): - return path.join(self.context.topdir, "ports", "glutin") - - def add_manifest_path(self, args, android=False, libsimpleservo=False): + @staticmethod + def build_like_command_arguments(decorated_function): + decorators = [ + CommandArgument( + '--target', '-t', + default=None, + help='Cross compile for given target platform', + ), + CommandArgument( + '--android', + default=None, + action='store_true', + help='Build for Android', + ), + CommandArgument( + '--magicleap', + default=None, + action='store_true', + help='Build for Magic Leap', + ), + CommandArgument( + '--libsimpleservo', + default=None, + action='store_true', + help='Build the libsimpleservo library instead of the servo executable', + ), + CommandArgument( + '--features', + default=None, + help='Space-separated list of features to also build', + nargs='+', + ), + CommandArgument( + '--debug-mozjs', + default=None, + action='store_true', + help='Enable debug assertions in mozjs', + ), + CommandArgument( + '--with-debug-assertions', + default=None, + action='store_true', + help='Enable debug assertions in release', + ), + CommandArgument( + '--with-frame-pointer', + default=None, + action='store_true', + help='Build with frame pointer enabled, used by the background hang monitor.', + ), + CommandArgument('--with-raqote', default=None, action='store_true'), + CommandArgument('--without-wgl', default=None, action='store_true'), + ] + + for decorator in decorators: + decorated_function = decorator(decorated_function) + return decorated_function + + def pick_target_triple(self, target, android, magicleap): + if android is None: + android = self.config["build"]["android"] + if target and android: + assert self.handle_android_target(target) + if android and not target: + target = self.config["android"]["target"] + if magicleap and not target: + target = "aarch64-linux-android" + if target and not android and not magicleap: + android = self.handle_android_target(target) + return target, android + + def run_cargo_build_like_command( + self, command, cargo_args, + env=None, verbose=False, + target=None, android=False, magicleap=False, libsimpleservo=False, + features=None, debug_mozjs=False, with_debug_assertions=False, + with_frame_pointer=False, with_raqote=False, without_wgl=False, + ): + env = env or self.build_env() + target, android = self.pick_target_triple(target, android, magicleap) + + args = [] if "--manifest-path" not in args: if libsimpleservo or android: - manifest = self.ports_libsimpleservo_manifest(android) + if android: + api = "jniapi" + else: + api = "capi" + port = path.join("libsimpleservo", api) else: - manifest = self.ports_glutin_manifest() - args.append("--manifest-path") - args.append(manifest) - - def ports_glutin_manifest(self): - return path.join(self.context.topdir, "ports", "glutin", "Cargo.toml") - - def ports_libsimpleservo_manifest(self, android=False): - if android: - api = "jniapi" - else: - api = "capi" - return path.join(self.context.topdir, "ports", "libsimpleservo", api, "Cargo.toml") - - def servo_features(self): - """Return a list of optional features to enable for the Servo crate""" - features = [] - if self.config["build"]["debug-mozjs"]: - features += ["debugmozjs"] - return features + port = "glutin" + args += [ + "--manifest-path", + path.join(self.context.topdir, "ports", port, "Cargo.toml"), + ] + if target: + args += ["--target", target] + + if features is None: # If we're passed a list, mutate it even if it's empty + features = [] + if self.config["build"]["debug-mozjs"] or debug_mozjs: + features.append("debugmozjs") + if not magicleap: + features.append("native-bluetooth") + if with_raqote and "canvas2d-azure" not in features: + features.append("canvas2d-raqote") + elif "canvas2d-raqote" not in features: + features.append("canvas2d-azure") + if with_frame_pointer: + env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C force-frame-pointers=yes" + features.append("profilemozjs") + if without_wgl: + features.append("no_wgl") + if self.config["build"]["webgl-backtrace"]: + features.append("webgl-backtrace") + if self.config["build"]["dom-backtrace"]: + features.append("dom-backtrace") + if with_debug_assertions: + env['RUSTFLAGS'] = env.get('RUSTFLAGS', "") + " -C debug_assertions" + + assert "--features" not in cargo_args + args += ["--features", " ".join(features)] + + return self.call_rustup_run(["cargo", command] + args + cargo_args, env=env, verbose=verbose) def android_support_dir(self): return path.join(self.context.topdir, "support", "android") diff --git a/python/servo/devenv_commands.py b/python/servo/devenv_commands.py index b298bf48fd1..ad5a02c270d 100644 --- a/python/servo/devenv_commands.py +++ b/python/servo/devenv_commands.py @@ -31,7 +31,14 @@ from servo.util import get_static_rust_lang_org_dist, get_urlopen_kwargs @CommandProvider class MachCommands(CommandBase): - def run_cargo(self, params, check=False): + @Command('check', + description='Run "cargo check"', + category='devenv') + @CommandArgument( + 'params', default=None, nargs='...', + help="Command-line arguments to be passed through to cargo check") + @CommandBase.build_like_command_arguments + def check(self, params, **kwargs): if not params: params = [] @@ -39,40 +46,17 @@ class MachCommands(CommandBase): self.ensure_clobbered() env = self.build_env() - if check: - params = ['check'] + params - - self.add_manifest_path(params) - build_start = time() - status = self.call_rustup_run(["cargo"] + params, env=env) + status = self.run_cargo_build_like_command("check", params, env=env, **kwargs) elapsed = time() - build_start notify_build_done(self.config, elapsed, status == 0) - if check and status == 0: + if status == 0: print('Finished checking, binary NOT updated. Consider ./mach build before ./mach run') return status - @Command('cargo', - description='Run Cargo', - category='devenv') - @CommandArgument( - 'params', default=None, nargs='...', - help="Command-line arguments to be passed through to Cargo") - def cargo(self, params): - return self.run_cargo(params) - - @Command('check', - description='Run "cargo check"', - category='devenv') - @CommandArgument( - 'params', default=None, nargs='...', - help="Command-line arguments to be passed through to cargo check") - def check(self, params): - return self.run_cargo(params, check=True) - @Command('cargo-update', description='Same as update-cargo', category='devenv') diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index 42e2ad84cb4..b9dc9b080ef 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -236,7 +236,8 @@ class PostBuildCommands(CommandBase): @CommandArgument( 'params', nargs='...', help="Command-line arguments to be passed through to cargo doc") - def doc(self, params): + @CommandBase.build_like_command_arguments + def doc(self, params, **kwargs): env = os.environ.copy() env["RUSTUP_TOOLCHAIN"] = self.toolchain() rustc_path = check_output(["rustup" + BIN_SUFFIX, "which", "rustc"], env=env) @@ -264,11 +265,7 @@ class PostBuildCommands(CommandBase): else: copy2(full_name, destination) - params += ["--features", "azure_backend"] - - returncode = self.call_rustup_run( - ["cargo", "doc", "--manifest-path", self.ports_glutin_manifest()] + params, - env=self.build_env()) + returncode = self.run_cargo_build_like_command("doc", params, **kwargs) if returncode: return returncode diff --git a/python/servo/testing_commands.py b/python/servo/testing_commands.py index 8696f02f8dc..d1880f6385e 100644 --- a/python/servo/testing_commands.py +++ b/python/servo/testing_commands.py @@ -214,7 +214,8 @@ class MachCommands(CommandBase): help="Run in bench mode") @CommandArgument('--nocapture', default=False, action="store_true", help="Run tests with nocapture ( show test stdout )") - def test_unit(self, test_name=None, package=None, bench=False, nocapture=False): + @CommandBase.build_like_command_arguments + def test_unit(self, test_name=None, package=None, bench=False, nocapture=False, **kwargs): if test_name is None: test_name = [] @@ -277,22 +278,18 @@ class MachCommands(CommandBase): # in to the servo.exe build dir, so just point PATH to that. env["PATH"] = "%s%s%s" % (path.dirname(self.get_binary_path(False, False)), os.pathsep, env["PATH"]) - features = self.servo_features() if len(packages) > 0 or len(in_crate_packages) > 0: - args = ["cargo", "bench" if bench else "test", "--manifest-path", self.ports_glutin_manifest()] + args = [] for crate in packages: args += ["-p", "%s_tests" % crate] for crate in in_crate_packages: args += ["-p", crate] args += test_patterns - if features: - args += ["--features", "%s" % ' '.join(features)] - if nocapture: args += ["--", "--nocapture"] - err = self.call_rustup_run(args, env=env) + err = self.run_cargo_build_like_command("bench" if bench else "test", args, env=env, **kwargs) if err is not 0: return err |