From 28bd024169964979db449dcea396a6927e365ea5 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 8 Jun 2016 15:33:38 -0500 Subject: [PATCH] servo: Merge #11646 - servo: Add an `Info.plist` on the Mac and opt into integrated graphics (from pcwalton:real-info-plist); r=metajack Discrete GPUs cause power use problems and tend to perform badly with WebRender. See: * https://developer.apple.com/library/mac/qa/qa1734/_index.html * https://reverse.put.as/2013/05/28/gimmedebugah-how-to-embedded-a-info-plist-into-arbitrary-binaries/ r? @metajack Source-Repo: https://github.com/servo/servo Source-Revision: e51ce5d1bac31afdadc9a4c86175fac00677b31a --- servo/components/servo/Cargo.lock | 20 ++++++++--------- servo/components/servo/main.rs | 13 +++++++++++ .../servo/platform/macos/Info.plist | 21 ++++++++++++++++++ servo/components/servo/platform/macos/mod.rs | 19 ++++++++++++++++ servo/ports/cef/Cargo.lock | 22 +++++++++---------- servo/python/servo/build_commands.py | 18 +++++++++++++++ servo/python/tidy/servo_tidy/tidy.py | 3 +++ 7 files changed, 95 insertions(+), 21 deletions(-) create mode 100644 servo/components/servo/platform/macos/Info.plist create mode 100644 servo/components/servo/platform/macos/mod.rs diff --git a/servo/components/servo/Cargo.lock b/servo/components/servo/Cargo.lock index 4c9bc35de3e0..ae10f5351157 100644 --- a/servo/components/servo/Cargo.lock +++ b/servo/components/servo/Cargo.lock @@ -99,7 +99,7 @@ version = "0.4.5" source = "git+https://github.com/servo/rust-azure#a7177c8df81554352bc51de2f5b77cbb47ec2635" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", @@ -273,11 +273,11 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -403,7 +403,7 @@ dependencies = [ [[package]] name = "core-graphics" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -417,7 +417,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -756,7 +756,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2056,9 +2056,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_glue 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cocoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2525,7 +2525,7 @@ source = "git+https://github.com/servo/webrender#3a6db793d0a2a1c0e55f78ba2ee8ec2 dependencies = [ "app_units 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2548,7 +2548,7 @@ source = "git+https://github.com/servo/webrender_traits#e4cbde9880d118e50de425d3 dependencies = [ "app_units 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)", diff --git a/servo/components/servo/main.rs b/servo/components/servo/main.rs index 361e0f01a750..4622040fa446 100644 --- a/servo/components/servo/main.rs +++ b/servo/components/servo/main.rs @@ -37,6 +37,17 @@ use servo::util::opts::{self, ArgumentParsingResult}; use servo::util::panicking::initiate_panic_hook; use std::rc::Rc; +pub mod platform { + #[cfg(target_os = "macos")] + pub use platform::macos::deinit; + + #[cfg(target_os = "macos")] + pub mod macos; + + #[cfg(not(target_os = "macos"))] + pub fn deinit() {} +} + fn main() { // Parse the command line options and store them globally let opts_result = opts::from_cmdline_args(&*args()); @@ -82,6 +93,8 @@ fn main() { }; unregister_glutin_resize_handler(&window); + + platform::deinit() } fn register_glutin_resize_handler(window: &Rc, diff --git a/servo/components/servo/platform/macos/Info.plist b/servo/components/servo/platform/macos/Info.plist new file mode 100644 index 000000000000..c2855eb82b4e --- /dev/null +++ b/servo/components/servo/platform/macos/Info.plist @@ -0,0 +1,21 @@ + + + + + NSSupportsAutomaticGraphicsSwitching + + CFBundleDisplayName + Servo + CFBundlePackageType + APPL + CFBundleName + Servo + NSHumanReadableCopyright + Copyright © 2016 The Servo Authors + CFBundleVersion + 0.0.1 + CFBundleIdentifier + org.servo.servo + + + diff --git a/servo/components/servo/platform/macos/mod.rs b/servo/components/servo/platform/macos/mod.rs new file mode 100644 index 000000000000..b980b83f5fb8 --- /dev/null +++ b/servo/components/servo/platform/macos/mod.rs @@ -0,0 +1,19 @@ +/* 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 http://mozilla.org/MPL/2.0/. */ + +use std::ptr; + +pub fn deinit() { + // An unfortunate hack to make sure the linker's dead code stripping doesn't strip our + // `Info.plist`. + unsafe { + ptr::read_volatile(&INFO_PLIST[0]); + } +} + +#[cfg(target_os = "macos")] +#[link_section = "__TEXT,__info_plist"] +#[no_mangle] +pub static INFO_PLIST: [u8; 619] = *include_bytes!("Info.plist"); + diff --git a/servo/ports/cef/Cargo.lock b/servo/ports/cef/Cargo.lock index 194d9667567e..4eb9f80b4a63 100644 --- a/servo/ports/cef/Cargo.lock +++ b/servo/ports/cef/Cargo.lock @@ -2,7 +2,7 @@ name = "embedding" version = "0.0.1" dependencies = [ - "cocoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cocoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "compositing 0.0.1", "devtools 0.0.1", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", @@ -77,7 +77,7 @@ version = "0.4.5" source = "git+https://github.com/servo/rust-azure#a7177c8df81554352bc51de2f5b77cbb47ec2635" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "freetype 0.1.0 (git+https://github.com/servo/rust-freetype)", @@ -251,11 +251,11 @@ dependencies = [ [[package]] name = "cocoa" -version = "0.4.2" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", "objc 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -366,7 +366,7 @@ dependencies = [ [[package]] name = "core-graphics" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -380,7 +380,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -678,7 +678,7 @@ dependencies = [ "bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -1941,9 +1941,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "android_glue 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", "cgl 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cocoa 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", + "cocoa 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)", "core-foundation 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "dwmapi-sys 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "gdi32-sys 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", "gl_generator 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2387,7 +2387,7 @@ source = "git+https://github.com/servo/webrender#3a6db793d0a2a1c0e55f78ba2ee8ec2 dependencies = [ "app_units 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "core-text 1.1.1 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "fnv 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2410,7 +2410,7 @@ source = "git+https://github.com/servo/webrender_traits#e4cbde9880d118e50de425d3 dependencies = [ "app_units 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)", "byteorder 0.5.3 (registry+https://github.com/rust-lang/crates.io-index)", - "core-graphics 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)", + "core-graphics 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)", "euclid 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "gleam 0.2.19 (registry+https://github.com/rust-lang/crates.io-index)", "ipc-channel 0.2.3 (git+https://github.com/servo/ipc-channel)", diff --git a/servo/python/servo/build_commands.py b/servo/python/servo/build_commands.py index 7e2845b598ff..1d4931dc78c2 100644 --- a/servo/python/servo/build_commands.py +++ b/servo/python/servo/build_commands.py @@ -186,6 +186,10 @@ class MachCommands(CommandBase): if release: opts += ["--release"] + servo_path = release_path + else: + servo_path = dev_path + if jobs is not None: opts += ["-j", jobs] if verbose: @@ -241,6 +245,20 @@ class MachCommands(CommandBase): shutil.copy(path.join(self.get_top_dir(), "components", "servo", "servo.exe.manifest"), path.join(base_path, "debug" if dev else "release")) + # On the Mac, set a lovely icon. This makes it easier to pick out the Servo binary in tools + # like Instruments.app. + if sys.platform == "darwin": + try: + import Cocoa + icon_path = path.join(self.get_top_dir(), "resources", "servo.png") + icon = Cocoa.NSImage.alloc().initWithContentsOfFile_(icon_path) + if icon is not None: + Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(icon, + servo_path, + 0) + except ImportError: + pass + # Generate Desktop Notification if elapsed-time > some threshold value notify_build_done(elapsed) diff --git a/servo/python/tidy/servo_tidy/tidy.py b/servo/python/tidy/servo_tidy/tidy.py index fcf51dbf3cb1..5bc64956a150 100644 --- a/servo/python/tidy/servo_tidy/tidy.py +++ b/servo/python/tidy/servo_tidy/tidy.py @@ -41,6 +41,9 @@ ignored_files = [ os.path.join(".", "tests", "wpt", "metadata", "MANIFEST.json"), os.path.join(".", "tests", "wpt", "metadata-css", "MANIFEST.json"), os.path.join(".", "components", "script", "dom", "webidls", "ForceTouchEvent.webidl"), + # FIXME(pcwalton, #11679): This is a workaround for a tidy error on the quoted string + # `"__TEXT,_info_plist"` inside an attribute. + os.path.join(".", "components", "servo", "platform", "macos", "mod.rs"), # Hidden files os.path.join(".", "."), ]