summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Xcode/repo.py
diff options
context:
space:
mode:
authorSean Callanan <scallanan@apple.com>2017-02-23 02:21:34 +0000
committerSean Callanan <scallanan@apple.com>2017-02-23 02:21:34 +0000
commitefe5d5fe9d7f3c774748af7db1e484719b007fbf (patch)
treef6ffefcc0bba641aab7efa904f35f0f81237df63 /lldb/scripts/Xcode/repo.py
parent73c3c21fae2fc8728d6cd8526ee4a43ee8d98d35 (diff)
downloadbcm5719-llvm-efe5d5fe9d7f3c774748af7db1e484719b007fbf.tar.gz
bcm5719-llvm-efe5d5fe9d7f3c774748af7db1e484719b007fbf.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. This update to the patch introduces a FALLBACK file whose contents take precedence if the current branch could not be identified. If the current branch could be identified, FALLBACK is updated, allowing the user to e.g. cut branches off of known branches and still have the automatic checkout mechanism work. It also documents all of this. Differential revision: https://reviews.llvm.org/D30275 llvm-svn: 295922
Diffstat (limited to 'lldb/scripts/Xcode/repo.py')
-rw-r--r--lldb/scripts/Xcode/repo.py42
1 files changed, 42 insertions, 0 deletions
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)
OpenPOWER on IntegriCloud