aboutsummaryrefslogtreecommitdiffstats
path: root/python/servo
diff options
context:
space:
mode:
authorJack Moffitt <jack@metajack.im>2016-03-04 10:24:09 -0700
committerJack Moffitt <jack@metajack.im>2016-03-04 15:07:32 -0700
commit96cbe7ac97c7df131f332a33ab2fde4eae518520 (patch)
tree8010374cd146500f6e66bbffde242357ccc97d36 /python/servo
parent1615f173f7264aa5afbe14f6ffdc7d4cee07842f (diff)
downloadservo-96cbe7ac97c7df131f332a33ab2fde4eae518520.tar.gz
servo-96cbe7ac97c7df131f332a33ab2fde4eae518520.zip
Add --browserhtml/-b command to ./mach run
This will run Servo with browser.html. We use the latest package in the dependency tree if there are multiple copies, since there is no way for Cargo to tell us which one is canonical.
Diffstat (limited to 'python/servo')
-rw-r--r--python/servo/post_build_commands.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py
index ea6020de809..c1c3f73dc69 100644
--- a/python/servo/post_build_commands.py
+++ b/python/servo/post_build_commands.py
@@ -9,6 +9,7 @@
from __future__ import print_function, unicode_literals
+from glob import glob
import os
import os.path as path
import subprocess
@@ -32,6 +33,18 @@ def read_file(filename, if_exists=False):
return f.read()
+def find_dep_path_newest(package, bin_path):
+ deps_path = path.join(path.split(bin_path)[0], "build")
+ with cd(deps_path):
+ print(os.getcwd())
+ candidates = glob(package + '-*')
+ candidates = (path.join(deps_path, c) for c in candidates)
+ candidate_times = sorted(((path.getmtime(c), c) for c in candidates), reverse=True)
+ if len(candidate_times) > 0:
+ return candidate_times[0][1]
+ return None
+
+
@CommandProvider
class PostBuildCommands(CommandBase):
@Command('run',
@@ -50,10 +63,12 @@ class PostBuildCommands(CommandBase):
'have no effect without this.')
@CommandArgument('--debugger', default=None, type=str,
help='Name of debugger to use.')
+ @CommandArgument('--browserhtml', '-b', action='store_true',
+ help='Launch with Browser.html')
@CommandArgument(
'params', nargs='...',
help="Command-line arguments to be passed through to Servo")
- def run(self, params, release=False, dev=False, android=None, debug=False, debugger=None):
+ def run(self, params, release=False, dev=False, android=None, debug=False, debugger=None, browserhtml=False):
env = self.build_env()
env["RUST_BACKTRACE"] = "1"
@@ -110,6 +125,13 @@ class PostBuildCommands(CommandBase):
# Prepend the debugger args.
args = ([command] + self.debuggerInfo.args +
args + params)
+ elif browserhtml:
+ browserhtml_path = find_dep_path_newest('browserhtml', args[0])
+ if browserhtml_path is None:
+ print("Could not find browserhtml package; perhaps you haven't built Servo.")
+ return 1
+ args = args + ['-w', '-b', '--pref', 'dom.mozbrowser.enabled',
+ path.join(browserhtml_path, 'out', 'index.html')]
else:
args = args + params