Index: INSTALL.txt =================================================================== --- INSTALL.txt +++ INSTALL.txt @@ -7,6 +7,11 @@ 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: Index: scripts/Xcode/build-llvm.py =================================================================== --- scripts/Xcode/build-llvm.py +++ scripts/Xcode/build-llvm.py @@ -6,6 +6,7 @@ import os import platform import re +import repo import subprocess import sys @@ -17,44 +18,38 @@ 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. +# For use with Xcode-style builds +def process_vcs(vcs): + return { + "svn": VCS.svn, + "git": VCS.git + }[vcs] -def LLVM_REF(): - llvm_ref = "master" - return llvm_ref +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 CLANG_REF(): - clang_ref = "master" - return clang_ref - -# For use with Xcode-style builds - - def XCODE_REPOSITORIES(): - return [ - {'name': "llvm", - 'vcs': VCS.git, - 'root': llvm_source_path(), - 'url': "http://llvm.org/git/llvm.git", - 'ref': LLVM_REF()}, + identifier = repo.identifier() + if identifier == None: + identifier = "" # repo.find will just use the fallback file + set = repo.find(identifier) + return [process_repo(r) for r in set] - {'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"} - ] - - def get_c_compiler(): return subprocess.check_output([ 'xcrun', Index: scripts/Xcode/repo.py =================================================================== --- scripts/Xcode/repo.py +++ 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) Index: scripts/Xcode/repos/FALLBACK =================================================================== --- scripts/Xcode/repos/FALLBACK +++ 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"} + ] +} Index: scripts/Xcode/repos/svn-trunk.json =================================================================== --- scripts/Xcode/repos/svn-trunk.json +++ 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"} + ] +}