diff options
author | bors-servo <metajack+bors@gmail.com> | 2015-02-23 21:09:46 -0700 |
---|---|---|
committer | bors-servo <metajack+bors@gmail.com> | 2015-02-23 21:09:46 -0700 |
commit | 6264e4dcdc75b83c8d08eb6bbbc9ed8412a2115c (patch) | |
tree | 81e49dd83b14614ecddb22e9cf5a8f85c02b19a4 | |
parent | 99617557d40504060d5162739f8ba9b962843099 (diff) | |
parent | 894e58f714de0f3d65aeb943dbf8f569feb8c1d6 (diff) | |
download | servo-6264e4dcdc75b83c8d08eb6bbbc9ed8412a2115c.tar.gz servo-6264e4dcdc75b83c8d08eb6bbbc9ed8412a2115c.zip |
auto merge of #5047 : jdm/servo/rr-mach-commands, r=jdm
These are very basic commands for invoking Servo underneath rr. rr
currently doesn't support all the syscalls that Servo requires, but
that's easy to fix on the rr side.
Fixes #4177. Rebased from #4237.
-rw-r--r-- | python/servo/post_build_commands.py | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py index d427fe1181f..bfa679a795e 100644 --- a/python/servo/post_build_commands.py +++ b/python/servo/post_build_commands.py @@ -30,6 +30,13 @@ def read_file(filename, if_exists=False): @CommandProvider class MachCommands(CommandBase): + + def get_binary_path(self, release): + base_path = path.join("components", "servo", "target") + if release: + return path.join(base_path, "release", "servo") + return path.join(base_path, "servo") + @Command('run', description='Run Servo', category='post-build') @@ -49,10 +56,7 @@ class MachCommands(CommandBase): env = self.build_env() env["RUST_BACKTRACE"] = "1" - if release: - args = [path.join("components", "servo", "target", "release", "servo")] - else: - args = [path.join("components", "servo", "target", "servo")] + args = self.get_binary_path(release) # Borrowed and modified from: # http://hg.mozilla.org/mozilla-central/file/c9cfa9b91dea/python/mozbuild/mozbuild/mach_commands.py#l883 @@ -84,6 +88,40 @@ class MachCommands(CommandBase): else: raise e + @Command('rr-record', + description='Run Servo whilst recording execution with rr', + category='post-build') + @CommandArgument('--release', '-r', action='store_true', + help='Running release builds') + @CommandArgument( + 'params', nargs='...', + help="Command-line arguments to be passed through to Servo") + def rr_record(self, release=False, params=[]): + env = self.build_env() + env["RUST_BACKTRACE"] = "1" + + servo_cmd = [self.get_binary_path(release)] + params + rr_cmd = ['rr', '--fatal-errors', 'record'] + try: + subprocess.check_call(rr_cmd + servo_cmd) + except OSError as e: + if e.errno == 2: + print("rr binary can't be found!") + else: + raise e + + @Command('rr-replay', + description='Replay the most recent execution of Servo that was recorded with rr', + category='post-build') + def rr_replay(self): + try: + subprocess.check_call(['rr', '--fatal-errors', 'replay']) + except OSError as e: + if e.errno == 2: + print("rr binary can't be found!") + else: + raise e + @Command('doc', description='Generate documentation', category='post-build') |