OLD | NEW |
(Empty) | |
| 1 #!/usr/bin/env python |
| 2 # |
| 3 # Copyright 2016 Google Inc. |
| 4 # |
| 5 # Use of this source code is governed by a BSD-style license that can be |
| 6 # found in the LICENSE file. |
| 7 |
| 8 |
| 9 """Create a Clang toolchain for Linux hosts.""" |
| 10 |
| 11 |
| 12 import argparse |
| 13 import os |
| 14 import subprocess |
| 15 import tempfile |
| 16 |
| 17 REPO = "https://llvm.googlesource.com/" |
| 18 BRANCH = "release_39" |
| 19 |
| 20 def create_asset(target_dir): |
| 21 os.chdir(tempfile.mkdtemp()) |
| 22 subprocess.check_call(["git", "clone", "-b", BRANCH, REPO + "llvm"]) |
| 23 os.chdir("llvm/tools") |
| 24 subprocess.check_call(["git", "clone", "-b", BRANCH, REPO + "clang"]) |
| 25 os.chdir("../projects") |
| 26 subprocess.check_call(["git", "clone", "-b", BRANCH, REPO + "compiler-rt"]) |
| 27 subprocess.check_call(["git", "clone", "-b", BRANCH, REPO + "libcxx"]) |
| 28 subprocess.check_call(["git", "clone", "-b", BRANCH, REPO + "libcxxabi"]) |
| 29 os.chdir("..") |
| 30 os.mkdir("out") |
| 31 os.chdir("out") |
| 32 subprocess.check_call(["cmake", "..", "-G", "Ninja", |
| 33 "-DCMAKE_BUILD_TYPE=MinSizeRel", |
| 34 "-DCMAKE_INSTALL_PREFIX=" + target_dir, |
| 35 "-DLLVM_INSTALL_TOOLCHAIN_ONLY=ON", |
| 36 "-DLLVM_ENABLE_TERMINFO=OFF"]) |
| 37 subprocess.check_call(["cmake", "--build", "."]) |
| 38 subprocess.check_call(["cmake", "--build", ".", "--target", "install"]) |
| 39 subprocess.check_call(["cp", "bin/llvm-symbolizer", target_dir + "/bin"]) |
| 40 |
| 41 libstdcpp = subprocess.check_output(["c++", |
| 42 "-print-file-name=libstdc++.so.6"]) |
| 43 subprocess.check_call(["cp", libstdcpp.strip(), target_dir + "/lib"]) |
| 44 |
| 45 |
| 46 def main(): |
| 47 parser = argparse.ArgumentParser() |
| 48 parser.add_argument('--target_dir', '-t', required=True) |
| 49 args = parser.parse_args() |
| 50 create_asset(args.target_dir) |
| 51 |
| 52 |
| 53 if __name__ == '__main__': |
| 54 main() |
OLD | NEW |