aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorDiana Picus <diana.picus@linaro.org>2017-03-14 17:38:32 +0100
committerDiana Picus <diana.picus@linaro.org>2017-04-24 15:48:56 +0200
commit3d1a30130a581e68afdbc027c82c5b1cd662ea6e (patch)
tree261513090b45c402f25e0f44931fcfca6db082fb /scripts
parentb430760d782ac5a4e1270d49038d0f400a3506c0 (diff)
Remove the need for LLVM_SRC in llvm.py
Add an extra parameter to llvm.py representing the environment that we want the command to refer to. We then compute the path to the LLVM source tree based on that and LLVM_ROOT (which is still an environment variable for the time being). The bash helper keeps its old interface and uses LLVM_SRC to compute the environment that it will pass down to llvm.py. We also perform a small number of drive-by fixes to this helper (e.g. replacing python with python3). Change-Id: Ie7a33103969622294e158f83be8b9f57832ef1dc
Diffstat (limited to 'scripts')
-rw-r--r--scripts/llvm.py28
1 files changed, 20 insertions, 8 deletions
diff --git a/scripts/llvm.py b/scripts/llvm.py
index 706af11..13e5de6 100644
--- a/scripts/llvm.py
+++ b/scripts/llvm.py
@@ -19,17 +19,25 @@ def die(message, config_to_dump=None):
exit(1)
+
+def get_llvm_root():
+ """Get the path to the LLVM root, which contains the repos as well as all
+ the work environments."""
+ return os.environ["LLVM_ROOT"]
+
+
+def get_worktree_root(env):
+ """
+ Get the path to the LLVM worktree corresponding to env. The value will be
+ based on the LLVM root.
+ """
+ return os.path.join(get_llvm_root(), env, "llvm")
+
# Figure out the path to the LLVM repos
if "LLVM_ROOT" not in os.environ:
die("Please, define $LLVM_ROOT to point to the root\n"
"path where the worktree setup should be performed")
-llvm_repos_root = os.path.join(os.environ["LLVM_ROOT"], "repos")
-
-# Figure out the path to the current LLVM tree
-if "LLVM_SRC" not in os.environ:
- die("Please, define $LLVM_SRC to point to the current LLVM\n"
- "worktree directory, or run llvm-env to set it for you")
-llvm_worktree_root = os.environ["LLVM_SRC"]
+llvm_repos_root = os.path.join(get_llvm_root(), "repos")
def dump_config(config):
@@ -48,6 +56,8 @@ def projects(args):
"""Add/remove subprojects based on the values in args."""
proj = Proj()
+
+ llvm_worktree_root = get_worktree_root(args.env)
config = LLVMSourceConfig(proj, llvm_worktree_root)
if not args.add and not args.remove:
@@ -77,10 +87,12 @@ def projects(args):
valid_subprojects = list(LLVMSubproject.get_all_subprojects().keys())
options = ArgumentParser(formatter_class=RawTextHelpFormatter)
+options.add_argument('env', help="The environment to update.")
+
subcommands = options.add_subparsers()
# Subcommand for adding / removing subprojects
-projs = subcommands.add_parser("projects", help="Add/remove LLVM subprojects")
+projs = subcommands.add_parser("projects", help="Add/remove LLVM subprojects.")
projs.set_defaults(run_command=projects)
# TODO: Overwriting previous values is not necessarily what users expect (so for