Created
September 10, 2015 13:26
-
-
Save rail/550db1c4936af29ab6c0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/build/unix/build-clang/build-clang.py b/build/unix/build-clang/build-clang.py | |
--- a/build/unix/build-clang/build-clang.py | |
+++ b/build/unix/build-clang/build-clang.py | |
@@ -1,9 +1,9 @@ | |
-#!/usr/bin/python2.7 | |
+#!/usr/bin/env python2.7 | |
# This Source Code Form is subject to the terms of the Mozilla Public | |
# License, v. 2.0. If a copy of the MPL was not distributed with this | |
# file, You can obtain one at http://mozilla.org/MPL/2.0/. | |
import os | |
import os.path | |
import shutil | |
import subprocess | |
@@ -52,19 +52,21 @@ def build_tar_package(tar, name, base, d | |
name = os.path.realpath(name) | |
run_in(base, [tar, "-cjf", name, directory]) | |
def svn_co(url, directory, revision): | |
check_run(["svn", "co", "-r", revision, url, directory]) | |
-def build_one_stage(env, stage_dir, llvm_source_dir, gcc_toolchain_dir): | |
+def build_one_stage(env, stage_dir, llvm_source_dir, gcc_toolchain_dir, | |
+ python_path): | |
def f(): | |
- build_one_stage_aux(stage_dir, llvm_source_dir, gcc_toolchain_dir) | |
+ build_one_stage_aux(stage_dir, llvm_source_dir, gcc_toolchain_dir, | |
+ python_path) | |
with_env(env, f) | |
def get_platform(): | |
p = platform.system() | |
if p == "Darwin": | |
return "macosx64" | |
elif p == "Linux": | |
@@ -75,17 +77,18 @@ def get_platform(): | |
else: | |
raise NotImplementedError("Not supported platform") | |
def is_darwin(): | |
return platform.system() == "Darwin" | |
-def build_one_stage_aux(stage_dir, llvm_source_dir, gcc_toolchain_dir): | |
+def build_one_stage_aux(stage_dir, llvm_source_dir, gcc_toolchain_dir, | |
+ python_path): | |
os.mkdir(stage_dir) | |
build_dir = stage_dir + "/build" | |
inst_dir = stage_dir + "/clang" | |
targets = ["x86", "x86_64"] | |
# The Darwin equivalents of binutils appear to have intermittent problems | |
# with objects in compiler-rt that are compiled for arm. Since the arm | |
@@ -93,17 +96,17 @@ def build_one_stage_aux(stage_dir, llvm_ | |
# arm support on Linux. | |
if not is_darwin(): | |
targets.append("arm") | |
configure_opts = ["--enable-optimized", | |
"--enable-targets=" + ",".join(targets), | |
"--disable-assertions", | |
"--disable-libedit", | |
- "--with-python=/usr/local/bin/python2.7", | |
+ "--with-python=%s" % python_path, | |
"--prefix=%s" % inst_dir, | |
"--with-gcc-toolchain=%s" % gcc_toolchain_dir, | |
"--disable-compiler-version-checks"] | |
build_package(llvm_source_dir, build_dir, configure_opts, []) | |
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. | |
@@ -114,33 +117,33 @@ if __name__ == "__main__": | |
source_dir = base_dir + "/src" | |
build_dir = base_dir + "/build" | |
llvm_source_dir = source_dir + "/llvm" | |
clang_source_dir = source_dir + "/clang" | |
compiler_rt_source_dir = source_dir + "/compiler-rt" | |
libcxx_source_dir = source_dir + "/libcxx" | |
- gcc_dir = "/tools/gcc-4.7.3-0moz1" | |
- | |
if is_darwin(): | |
os.environ['MACOSX_DEPLOYMENT_TARGET'] = '10.7' | |
parser = argparse.ArgumentParser() | |
parser.add_argument('-c', '--config', required=True, | |
type=argparse.FileType('r'), | |
help="Clang configuration file") | |
args = parser.parse_args() | |
config = json.load(args.config) | |
llvm_revision = config["llvm_revision"] | |
llvm_repo = config["llvm_repo"] | |
clang_repo = config["clang_repo"] | |
compiler_repo = config["compiler_repo"] | |
libcxx_repo = config["libcxx_repo"] | |
+ gcc_dir = config.get("gcc_dir", "/tools/gcc-4.7.3-0moz1") | |
+ python_path = config.get("python_path", "/usr/local/bin/python2.7") | |
if not os.path.exists(source_dir): | |
os.makedirs(source_dir) | |
svn_co(llvm_repo, llvm_source_dir, llvm_revision) | |
svn_co(clang_repo, clang_source_dir, llvm_revision) | |
svn_co(compiler_repo, compiler_rt_source_dir, llvm_revision) | |
svn_co(libcxx_repo, libcxx_source_dir, llvm_revision) | |
os.symlink("../../clang", llvm_source_dir + "/tools/clang") | |
@@ -176,17 +179,17 @@ if __name__ == "__main__": | |
if os.environ.has_key('LD_LIBRARY_PATH'): | |
os.environ['LD_LIBRARY_PATH'] = '%s/lib64/:%s' % (gcc_dir, os.environ['LD_LIBRARY_PATH']); | |
else: | |
os.environ['LD_LIBRARY_PATH'] = '%s/lib64/' % gcc_dir | |
build_one_stage( | |
{"CC": cc + " %s" % extra_cflags, | |
"CXX": cxx + " %s" % extra_cxxflags}, | |
- stage1_dir, llvm_source_dir, gcc_dir) | |
+ stage1_dir, llvm_source_dir, gcc_dir, python_path) | |
stage2_dir = build_dir + '/stage2' | |
build_one_stage( | |
{"CC": stage1_inst_dir + "/bin/clang %s" % extra_cflags2, | |
"CXX": stage1_inst_dir + "/bin/clang++ %s" % extra_cxxflags2}, | |
- stage2_dir, llvm_source_dir, gcc_dir) | |
+ stage2_dir, llvm_source_dir, gcc_dir, python_path) | |
build_tar_package("tar", "clang.tar.bz2", stage2_dir, "clang") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment