mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Set windows subsystem on MSVC builds with editbin
This commit is contained in:
parent
5bbec7469d
commit
82df8e9399
1 changed files with 33 additions and 24 deletions
|
@ -23,7 +23,7 @@ from mach.decorators import (
|
||||||
Command,
|
Command,
|
||||||
)
|
)
|
||||||
|
|
||||||
from servo.command_base import CommandBase, cd, call, BIN_SUFFIX
|
from servo.command_base import CommandBase, cd, call, BIN_SUFFIX, host_triple
|
||||||
|
|
||||||
|
|
||||||
def format_duration(seconds):
|
def format_duration(seconds):
|
||||||
|
@ -86,11 +86,11 @@ def notify_darwin(title, text):
|
||||||
raise Exception("Optional Python module 'pyobjc' is not installed.")
|
raise Exception("Optional Python module 'pyobjc' is not installed.")
|
||||||
|
|
||||||
|
|
||||||
def notify_build_done(elapsed):
|
def notify_build_done(elapsed, success=True):
|
||||||
"""Generate desktop notification when build is complete and the
|
"""Generate desktop notification when build is complete and the
|
||||||
elapsed build time was longer than 30 seconds."""
|
elapsed build time was longer than 30 seconds."""
|
||||||
if elapsed > 30:
|
if elapsed > 30:
|
||||||
notify("Servo build", "Completed in %s" % format_duration(elapsed))
|
notify("Servo build", "%s in %s" % ("Completed" if success else "FAILED", format_duration(elapsed)))
|
||||||
|
|
||||||
|
|
||||||
def notify(title, text):
|
def notify(title, text):
|
||||||
|
@ -236,36 +236,45 @@ class MachCommands(CommandBase):
|
||||||
|
|
||||||
cargo_binary = "cargo" + BIN_SUFFIX
|
cargo_binary = "cargo" + BIN_SUFFIX
|
||||||
|
|
||||||
if sys.platform == "win32" or sys.platform == "msys":
|
if sys.platform in ("win32", "msys"):
|
||||||
env["RUSTFLAGS"] = "-C link-args=-Wl,--subsystem,windows"
|
if "msvc" not in host_triple():
|
||||||
|
env[b'RUSTFLAGS'] = b'-C link-args=-Wl,--subsystem,windows'
|
||||||
|
|
||||||
status = call(
|
status = call(
|
||||||
[cargo_binary, "build"] + opts,
|
[cargo_binary, "build"] + opts,
|
||||||
env=env, cwd=self.servo_crate(), verbose=verbose)
|
env=env, cwd=self.servo_crate(), verbose=verbose)
|
||||||
elapsed = time() - build_start
|
elapsed = time() - build_start
|
||||||
|
|
||||||
if sys.platform == "win32" or sys.platform == "msys":
|
# Do some additional things if the build succeeded
|
||||||
shutil.copy(path.join(self.get_top_dir(), "components", "servo", "servo.exe.manifest"),
|
if status == 0:
|
||||||
path.join(base_path, "debug" if dev else "release"))
|
if sys.platform in ("win32", "msys"):
|
||||||
|
servo_exe_dir = 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
|
# On windows, copy in our manifest
|
||||||
# like Instruments.app.
|
shutil.copy(path.join(self.get_top_dir(), "components", "servo", "servo.exe.manifest"),
|
||||||
if sys.platform == "darwin":
|
servo_exe_dir)
|
||||||
try:
|
# And on msvc builds, use editbin to change the subsystem to windows
|
||||||
import Cocoa
|
if "msvc" in host_triple():
|
||||||
icon_path = path.join(self.get_top_dir(), "resources", "servo.png")
|
call(["editbin", "/nologo", "/subsystem:windows", path.join(servo_exe_dir, "servo.exe")],
|
||||||
icon = Cocoa.NSImage.alloc().initWithContentsOfFile_(icon_path)
|
verbose=verbose)
|
||||||
if icon is not None:
|
|
||||||
Cocoa.NSWorkspace.sharedWorkspace().setIcon_forFile_options_(icon,
|
elif sys.platform == "darwin":
|
||||||
servo_path,
|
# On the Mac, set a lovely icon. This makes it easier to pick out the Servo binary in tools
|
||||||
0)
|
# like Instruments.app.
|
||||||
except ImportError:
|
try:
|
||||||
pass
|
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
|
# Generate Desktop Notification if elapsed-time > some threshold value
|
||||||
notify_build_done(elapsed)
|
notify_build_done(elapsed, status == 0)
|
||||||
|
|
||||||
print("Build completed in %s" % format_duration(elapsed))
|
print("Build %s in %s" % ("Completed" if status == 0 else "FAILED", format_duration(elapsed)))
|
||||||
return status
|
return status
|
||||||
|
|
||||||
@Command('build-cef',
|
@Command('build-cef',
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue