diff options
-rw-r--r-- | lldb/INSTALL.txt | 5 | ||||
-rwxr-xr-x | lldb/scripts/Xcode/build-llvm.py | 57 | ||||
-rw-r--r-- | lldb/scripts/Xcode/repo.py | 42 | ||||
-rw-r--r-- | lldb/scripts/Xcode/repos/FALLBACK | 19 | ||||
-rw-r--r-- | lldb/scripts/Xcode/repos/svn-trunk.json | 19 |
5 files changed, 111 insertions, 31 deletions
diff --git a/lldb/INSTALL.txt b/lldb/INSTALL.txt index 0f05823b6e4..ef7126994f4 100644 --- a/lldb/INSTALL.txt +++ b/lldb/INSTALL.txt @@ -7,6 +7,11 @@ On Mac OS X, in addition to using Xcode you'll need to enable code signing on your system to either build lldb or debug using lldb. Please see the code signing documentation in docs/code-signing.txt for more detailed directions. +If you are building on Mac OS X and LLVM is not present in llvm/, then LLDB +will check it out automatically. The files in scripts/Xcode/repos determine +which branches of LLVM/Clang are checked out, depending on the current +LLDB branch, according to the algorithm in scripts/Xcode/repo.py. + For instructions to build LLDB on Linux, or more details about supported compiler versions, other dependencies, and build flags, see: diff --git a/lldb/scripts/Xcode/build-llvm.py b/lldb/scripts/Xcode/build-llvm.py index 792f92558b4..36e491ebf06 100755 --- a/lldb/scripts/Xcode/build-llvm.py +++ b/lldb/scripts/Xcode/build-llvm.py @@ -6,6 +6,7 @@ import fnmatch import os import platform import re +import repo import subprocess import sys @@ -17,42 +18,36 @@ from lldbbuild import * def LLVM_HASH_INCLUDES_DIFFS(): return False -# The use of "x = "..."; return x" here is important because tooling looks for -# it with regexps. Only change how this works if you know what you are doing. - - -def LLVM_REF(): - llvm_ref = "master" - return llvm_ref - +# For use with Xcode-style builds -def CLANG_REF(): - clang_ref = "master" - return clang_ref +def process_vcs(vcs): + return { + "svn": VCS.svn, + "git": VCS.git + }[vcs] -# For use with Xcode-style builds +def process_root(name): + return { + "llvm": llvm_source_path(), + "clang": clang_source_path(), + "ninja": ninja_source_path() + }[name] +def process_repo(r): + return { + 'name': r["name"], + 'vcs': process_vcs(r["vcs"]), + 'root': process_root(r["name"]), + 'url': r["url"], + 'ref': r["ref"] + } def XCODE_REPOSITORIES(): - return [ - {'name': "llvm", - 'vcs': VCS.git, - 'root': llvm_source_path(), - 'url': "http://llvm.org/git/llvm.git", - 'ref': LLVM_REF()}, - - {'name': "clang", - 'vcs': VCS.git, - 'root': clang_source_path(), - 'url': "http://llvm.org/git/clang.git", - 'ref': CLANG_REF()}, - - {'name': "ninja", - 'vcs': VCS.git, - 'root': ninja_source_path(), - 'url': "https://github.com/ninja-build/ninja.git", - 'ref': "master"} - ] + identifier = repo.identifier() + if identifier == None: + identifier = "<invalid>" # repo.find will just use the fallback file + set = repo.find(identifier) + return [process_repo(r) for r in set] def get_c_compiler(): diff --git a/lldb/scripts/Xcode/repo.py b/lldb/scripts/Xcode/repo.py new file mode 100644 index 00000000000..d6e1aeef873 --- /dev/null +++ b/lldb/scripts/Xcode/repo.py @@ -0,0 +1,42 @@ +import json +import os +import re +import shutil +import subprocess + +def identifier(): + try: + svn_output = subprocess.check_output(["svn", "info", "--show-item", "url"], stderr=subprocess.STDOUT).rstrip() + return svn_output + except: + pass + try: + git_remote_and_branch = subprocess.check_output(["git", "rev-parse", "--abbrev-ref", "--symbolic-full-name", "@{u}"]).rstrip() + git_remote = git_remote_and_branch.split("/")[0] + git_branch = "/".join(git_remote_and_branch.split("/")[1:]) + git_url = subprocess.check_output(["git", "remote", "get-url", git_remote]).rstrip() + return git_url + ":" + git_branch + except: + pass + return None + +def find(identifier): + dir = os.path.dirname(os.path.realpath(__file__)) + repos_dir = os.path.join(dir, "repos") + json_regex = re.compile(r"^.*.json$") + override_path = os.path.join(repos_dir, "OVERRIDE") + if os.path.isfile(override_path): + override_set = json.load(open(override_path)) + return override_set["repos"] + fallback_path = os.path.join(repos_dir, "FALLBACK") + for path in [os.path.join(repos_dir, f) for f in filter(json_regex.match, os.listdir(repos_dir))]: + fd = open(path) + set = json.load(fd) + fd.close() + if any(re.match(set_regex, identifier) for set_regex in set["regexs"]): + shutil.copyfile(path, fallback_path) + return set["repos"] + if os.path.isfile(fallback_path): + fallback_set = json.load(open(fallback_path)) + return fallback_set["repos"] + sys.exit("Couldn't find a branch configuration for " + identifier + " and there was no " + fallback_path) diff --git a/lldb/scripts/Xcode/repos/FALLBACK b/lldb/scripts/Xcode/repos/FALLBACK new file mode 100644 index 00000000000..a3bd72424aa --- /dev/null +++ b/lldb/scripts/Xcode/repos/FALLBACK @@ -0,0 +1,19 @@ +{ + "regexs" : [".*llvm\\.org.*"], + "repos" : [ + {"name": "llvm", + "vcs": "git", + "url": "http://llvm.org/git/llvm.git", + "ref": "master"}, + + {"name": "clang", + "vcs": "git", + "url": "http://llvm.org/git/clang.git", + "ref": "master"}, + + {"name": "ninja", + "vcs": "git", + "url": "https://github.com/ninja-build/ninja.git", + "ref": "master"} + ] +} diff --git a/lldb/scripts/Xcode/repos/svn-trunk.json b/lldb/scripts/Xcode/repos/svn-trunk.json new file mode 100644 index 00000000000..a3bd72424aa --- /dev/null +++ b/lldb/scripts/Xcode/repos/svn-trunk.json @@ -0,0 +1,19 @@ +{ + "regexs" : [".*llvm\\.org.*"], + "repos" : [ + {"name": "llvm", + "vcs": "git", + "url": "http://llvm.org/git/llvm.git", + "ref": "master"}, + + {"name": "clang", + "vcs": "git", + "url": "http://llvm.org/git/clang.git", + "ref": "master"}, + + {"name": "ninja", + "vcs": "git", + "url": "https://github.com/ninja-build/ninja.git", + "ref": "master"} + ] +} |