servo: Merge #6038 - Add --dev option to mach build (from mbrubeck:jinankjain-Bug#5933); r=mbrubeck
authorJinank Jain <ug201210017@iitj.ac.in>
Thu, 14 May 2015 11:26:18 -0500
changeset 336372 8898638c645eb2f411b9accfa9e93b3ead6b7fa8
parent 336371 0377da0d1cf5d8328bce9202e484cdd741462360
child 336373 3bd9f7b72884b186b998cdab0dff3169cb8adbfa
push id31307
push usergszorc@mozilla.com
push dateSat, 04 Feb 2017 00:59:06 +0000
treeherdermozilla-central@94079d43835f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmbrubeck
bugs5933
servo: Merge #6038 - Add --dev option to mach build (from mbrubeck:jinankjain-Bug#5933); r=mbrubeck Require either `--dev` or `--release`, unless a default build.mode is set in `.servobuild`. This is @jinankjain's patch from #5965, rebased onto master. It is already reviewed, and only waiting for servo/saltfs#28 to be deployed. Source-Repo: https://github.com/servo/servo Source-Revision: c0d8488b719ea72e73e435618e015c2f705853cc
servo/README.md
servo/python/servo/build_commands.py
servo/python/servo/command_base.py
servo/servobuild.example
--- a/servo/README.md
+++ b/servo/README.md
@@ -69,25 +69,28 @@ two. If you'd like to know the snapshot 
 
 ## Building
 
 Servo is built with Cargo, the Rust package manager. We also use Mozilla's
 Mach tools to orchestrate the build and other tasks.
 
 ### Normal build
 
+
+To build Servo in development mode.  This is useful for development, but
+the resulting binary is very slow.
+
 ``` sh
 git clone https://github.com/servo/servo
 cd servo
-./mach build
+./mach build --dev
 ./mach run tests/html/about-mozilla.html
 ```
 
-By default, Servo builds in debug mode.  This is useful for development, but
-the resulting binary is very slow.  For benchmarking, performance testing, or
+For benchmarking, performance testing, or
 real-world use, add the `--release` flag to create an optimized build:
 
 ``` sh
 ./mach build --release
 ./mach run --release tests/html/about-mozilla.html
 ```
 
 ### Building for Android target
--- a/servo/python/servo/build_commands.py
+++ b/servo/python/servo/build_commands.py
@@ -132,16 +132,30 @@ class MachCommands(CommandBase):
         self.ensure_bootstrapped()
 
         if android is None:
             android = self.config["build"]["android"]
 
         opts = params or []
         features = []
 
+        if not (release or dev):
+            if self.config["build"]["mode"] == "dev":
+                dev = True
+            elif self.config["build"]["mode"] == "release":
+                release = True 
+            else:
+                print("Please specify either --dev (-d) for a development")
+                print("  build, or --release (-r) for an optimized build.")
+                sys.exit(1)
+
+        if release and dev:
+            print("Please specify either --dev or --release.")
+            sys.exit(1)
+
         if release:
             opts += ["--release"]
         if target:
             opts += ["--target", target]
         if jobs is not None:
             opts += ["-j", jobs]
         if verbose:
             opts += ["-v"]
--- a/servo/python/servo/command_base.py
+++ b/servo/python/servo/command_base.py
@@ -88,17 +88,17 @@ class CommandBase(object):
             self.config["tools"]["rust-root"] = path.join(
                 context.sharedir, "rust", *self.rust_snapshot_path().split("/"))
         if not self.config["tools"]["system-cargo"]:
             self.config["tools"]["cargo-root"] = path.join(
                 context.sharedir, "cargo", self.cargo_build_id())
 
         self.config.setdefault("build", {})
         self.config["build"].setdefault("android", False)
-
+        self.config["build"].setdefault("mode", "")
         self.config["build"].setdefault("debug-mozjs", False)
 
         self.config.setdefault("android", {})
         self.config["android"].setdefault("sdk", "")
         self.config["android"].setdefault("ndk", "")
         self.config["android"].setdefault("toolchain", "")
 
         self.config.setdefault("gonk", {})
--- a/servo/servobuild.example
+++ b/servo/servobuild.example
@@ -18,16 +18,19 @@ cargo-home-dir = "./.cargo"
 # when building. Similarly for Cargo. This takes care of PATH as well as
 # [DY]LD_LIBRARY_PATH.
 system-rust = false
 rust-root = "/path/to/rust"
 system-cargo = false
 cargo-root = "/path/to/cargo"
 
 [build]
+# Set "mode = dev" or use `mach build --dev` to build the project with warning.
+# or Set "mode = release" or use `mach build --release` for optimized build.
+mode = "dev"
 # Set "android = true" or use `mach build --android` to build the Android app.
 android = false
 # Set "debug-mozjs" or use `mach build --debug-mozjs` to build a debug spidermonkey.
 debug-mozjs = false
 
 # Android information
 [android]
 sdk = "/opt/android-sdk"