Bug 1182727 - Part 2: Run cmake through ninja to enable resumable builds; r=rail
authorEhsan Akhgari <ehsan@mozilla.com>
Fri, 10 Jul 2015 21:43:37 -0400
changeset 299158 5fb1820cd5df284a1a8760375cc10f7c2169e856
parent 299157 ba1bb553ce697e15aca57cf8ee2350bee70bf89c
child 299159 4cafc18743d0edad6ffb638b4496787ac6e753bf
push id5392
push userraliiev@mozilla.com
push dateMon, 14 Dec 2015 20:08:23 +0000
treeherdermozilla-beta@16ce8562a975 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrail
bugs1182727
milestone44.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1182727 - Part 2: Run cmake through ninja to enable resumable builds; r=rail Since CMake generated build systems can run cmake if necessary, this will make it possible to pick up changes from the source directory if any and resume as much of the build as possible. This builds the foundation for removing the need to blow away any of the work done by the previous runs of the script.
build/unix/build-clang/build-clang.py
--- a/build/unix/build-clang/build-clang.py
+++ b/build/unix/build-clang/build-clang.py
@@ -31,20 +31,21 @@ def run_in(path, args):
 
 
 def patch(patch, srcdir):
     patch = os.path.realpath(patch)
     check_run(['patch', '-d', srcdir, '-p1', '-i', patch, '--fuzz=0',
                '-s'])
 
 
-def build_package(package_build_dir, cmake_args):
+def build_package(package_build_dir, run_cmake, cmake_args):
     if not os.path.exists(package_build_dir):
         os.mkdir(package_build_dir)
-    run_in(package_build_dir, ["cmake"] + cmake_args)
+    if run_cmake:
+        run_in(package_build_dir, ["cmake"] + cmake_args)
     run_in(package_build_dir, ["ninja", "install"])
 
 
 @contextmanager
 def updated_env(env):
     old_env = os.environ.copy()
     os.environ.update(env)
     yield
@@ -130,36 +131,41 @@ def get_platform():
         raise NotImplementedError("Not supported platform")
 
 
 def is_darwin():
     return platform.system() == "Darwin"
 
 
 def build_one_stage_aux(src_dir, stage_dir, build_libcxx):
-    os.mkdir(stage_dir)
+    if not os.path.exists(stage_dir):
+        os.mkdir(stage_dir)
 
     build_dir = stage_dir + "/build"
     inst_dir = stage_dir + "/clang"
 
     global centOS6
     if centOS6:
         python_path = "/usr/bin/python2.7"
     else:
         python_path = "/usr/local/bin/python2.7"
 
+    run_cmake = True
+    if os.path.exists(build_dir):
+        run_cmake = False
+
     cmake_args = ["-GNinja",
                   "-DCMAKE_BUILD_TYPE=Release",
                   "-DLLVM_TARGETS_TO_BUILD=X86;ARM",
                   "-DLLVM_ENABLE_ASSERTIONS=OFF",
                   "-DPYTHON_EXECUTABLE=%s" % python_path,
                   "-DCMAKE_INSTALL_PREFIX=%s" % inst_dir,
                   "-DLLVM_TOOL_LIBCXX_BUILD=%s" % ("ON" if build_libcxx else "OFF"),
                   src_dir];
-    build_package(build_dir, cmake_args)
+    build_package(build_dir, run_cmake, cmake_args)
 
 if __name__ == "__main__":
     # The directories end up in the debug info, so the easy way of getting
     # a reproducible build is to run it in a know absolute directory.
     # We use a directory in /builds/slave because the mozilla infrastructure
     # cleans it up automatically.
     base_dir = "/builds/slave/moz-toolchain"
 
@@ -202,19 +208,18 @@ if __name__ == "__main__":
         os.symlink("../../clang", llvm_source_dir + "/tools/clang")
         os.symlink("../../compiler-rt",
                    llvm_source_dir + "/projects/compiler-rt")
         os.symlink("../../libcxx",
                    llvm_source_dir + "/projects/libcxx")
         for p in config.get("patches", {}).get(get_platform(), []):
             patch(p, source_dir)
 
-    if os.path.exists(build_dir):
-        shutil.rmtree(build_dir)
-    os.makedirs(build_dir)
+    if not os.path.exists(build_dir):
+        os.makedirs(build_dir)
 
     stage1_dir = build_dir + '/stage1'
     stage1_inst_dir = stage1_dir + '/clang'
 
     if is_darwin():
         extra_cflags = ""
         extra_cxxflags = "-stdlib=libc++"
         extra_cflags2 = ""