diff options
author | Sean Callanan <scallanan@apple.com> | 2017-02-22 22:57:59 +0000 |
---|---|---|
committer | Sean Callanan <scallanan@apple.com> | 2017-02-22 22:57:59 +0000 |
commit | ff1fb7f846829a20a4d8242925686effb8cbbaf1 (patch) | |
tree | c8bb3963c6d1991b0b9c3df76312e01aedc5be28 /lldb/scripts/Xcode/repo.py | |
parent | 63efdd9e1e0a44a1f7c4e31954167857703d16b4 (diff) | |
download | bcm5719-llvm-ff1fb7f846829a20a4d8242925686effb8cbbaf1.tar.gz bcm5719-llvm-ff1fb7f846829a20a4d8242925686effb8cbbaf1.zip |
Changed builld-llvm.py to use .json files
LLDB has many branches in a variety of repositories.
The build-script.py file is subtly different for each set.
This is unnecessary and causes merge headaches.
This patch makes build-llvm.py consult a directory full
of .json files, each one of which matches a particular
branch using a regular expression.
Differential revision: https://reviews.llvm.org/D30275
llvm-svn: 295897
Diffstat (limited to 'lldb/scripts/Xcode/repo.py')
-rw-r--r-- | lldb/scripts/Xcode/repo.py | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lldb/scripts/Xcode/repo.py b/lldb/scripts/Xcode/repo.py new file mode 100644 index 00000000000..2f737b5186c --- /dev/null +++ b/lldb/scripts/Xcode/repo.py @@ -0,0 +1,33 @@ +import json +import os +import re +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.json") + if os.path.isfile(override_path): + override_set = json.load(open(override_path)) + return override_set["repos"] + for set in [json.load(open(os.path.join(repos_dir, f))) for f in filter(json_regex.match, os.listdir(repos_dir))]: + if re.match(set["regexp"], identifier): + return set["repos"] + return None |