aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2016-04-16 00:42:04 +0530
committerbors-servo <lbergstrom+bors@mozilla.com>2016-04-16 00:42:04 +0530
commit7c615233d88967f79efbf78618eda3f3a8479e88 (patch)
tree8d82d23a64d37bc21d6345176bdec67598a48e1c
parent44d7657487797575bb47aa295a13b496dd2cd69c (diff)
parent739410e52d4ee70f02b2a32db27e6402ef5cbce9 (diff)
downloadservo-7c615233d88967f79efbf78618eda3f3a8479e88.tar.gz
servo-7c615233d88967f79efbf78618eda3f3a8479e88.zip
Auto merge of #10616 - autrilla:10614, r=edunham
<!-- Reviewable:start --> This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10616) <!-- Reviewable:end -->
-rw-r--r--python/servo/command_base.py14
-rw-r--r--python/servo/post_build_commands.py21
2 files changed, 27 insertions, 8 deletions
diff --git a/python/servo/command_base.py b/python/servo/command_base.py
index cf25bc41927..877fb51180a 100644
--- a/python/servo/command_base.py
+++ b/python/servo/command_base.py
@@ -103,6 +103,14 @@ def check_call(*args, **kwargs):
return subprocess.check_call(*args, shell=sys.platform == 'win32', **kwargs)
+class BuildNotFound(Exception):
+ def __init__(self, message):
+ self.message = message
+
+ def __str__(self):
+ return self.message
+
+
class CommandBase(object):
"""Base class for mach command providers.
@@ -203,6 +211,8 @@ class CommandBase(object):
return path.join(self.context.topdir, "target")
def get_binary_path(self, release, dev, android=False):
+ # TODO(autrilla): this function could still use work - it shouldn't
+ # handle quitting, or printing. It should return the path, or an error.
base_path = self.get_target_dir()
if android:
@@ -220,8 +230,8 @@ class CommandBase(object):
dev_exists = path.exists(dev_path)
if not release_exists and not dev_exists:
- print("No Servo binary found. Please run './mach build' and try again.")
- sys.exit()
+ raise BuildNotFound('No Servo binary found.'
+ ' Perhaps you forgot to run `./mach build`?')
if release and release_exists:
return release_path
diff --git a/python/servo/post_build_commands.py b/python/servo/post_build_commands.py
index c9891cd7986..7bbb8c03ed5 100644
--- a/python/servo/post_build_commands.py
+++ b/python/servo/post_build_commands.py
@@ -23,7 +23,7 @@ from mach.decorators import (
Command,
)
-from servo.command_base import CommandBase, cd, call, check_call
+from servo.command_base import CommandBase, cd, call, check_call, BuildNotFound
def read_file(filename, if_exists=False):
@@ -263,11 +263,20 @@ class PostBuildCommands(CommandBase):
@CommandArgument('--dev', '-d', action='store_true',
help='Package the dev build')
def install(self, release=False, dev=False):
- binary_path = self.get_binary_path(release, dev, android=True)
- if not path.exists(binary_path):
- # TODO: Run the build command automatically?
- print("Servo build not found. Please run `./mach build` to compile Servo.")
- return 1
+ try:
+ binary_path = self.get_binary_path(release, dev, android=True)
+ except BuildNotFound:
+ print("Servo build not found. Building servo...")
+ result = Registrar.dispatch(
+ "build", context=self.context, release=release, dev=dev
+ )
+ if result:
+ return result
+ try:
+ binary_path = self.get_binary_path(release, dev, android=True)
+ except BuildNotFound:
+ print("Rebuilding Servo did not solve the missing build problem.")
+ return 1
apk_path = binary_path + ".apk"
if not path.exists(apk_path):