path: root/scripts
diff options
authorDiana Picus <diana.picus@linaro.org>2017-05-05 22:26:49 +0200
committerDiana Picus <diana.picus@linaro.org>2017-05-12 12:41:30 +0200
commit81089dbdf90268900305b3dd0cb5997879fd7c1f (patch)
tree61d9c9fd02880f844d80d0ea62c1aff9f5652015 /scripts
parent3d1a30130a581e68afdbc027c82c5b1cd662ea6e (diff)
Separate the repos from the environments
Before this patch, we had an LLVM_ROOT directory which contained the repos and a series of environments (worktrees + build dicretories). However, there is no good reason to have such a rigid layout, and in fact it prevents us from sharing the repos in any meaningful way. This patch removes LLVM_ROOT and instead introduces two command line parameters, repos and env, which represent the path to the directory containing the LLVM repositories and respectively the path to the environment that we intend to modify. The two paths may be completely independent. A side effect of this is that we can now also have different environments in different, unrelated locations (whereas previously they had to be siblings in LLVM_ROOT). For the time being, both parameters are compulsory (not only for llvm-projects, but for all subcommands). There may be situations where we can get away with only one of them (e.g. `llvm-projs <env>`, which just lists the projects enabled in the given <env> - it does not need to know where the repos are in order to do this). There may also be situations where one of them doesn't make any sense at all (e.g. `llvm-prepare`, which is not implemented yet in python, only needs the path to the repos and it would not know what to do with an environment). Making them optional would require some additional validation logic as well as more tests, and it feels a bit early on to introduce all that. It would be nice to have at least one or 2 more subcommands implemented before we invest time in it. Change-Id: Ibc1321d18476c2c4a65b5b05ca3fce3467d72fc3
Diffstat (limited to 'scripts')
1 files changed, 10 insertions, 18 deletions
diff --git a/scripts/llvm.py b/scripts/llvm.py
index 13e5de6..829c720 100644
--- a/scripts/llvm.py
+++ b/scripts/llvm.py
@@ -20,24 +20,9 @@ def die(message, config_to_dump=None):
-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(get_llvm_root(), "repos")
+ """Get the path to the LLVM worktree corresponding to env."""
+ return os.path.join(env, "llvm")
def dump_config(config):
@@ -58,6 +43,7 @@ def projects(args):
proj = Proj()
llvm_worktree_root = get_worktree_root(args.env)
+ llvm_repos_root = args.repos
config = LLVMSourceConfig(proj, llvm_worktree_root)
if not args.add and not args.remove:
@@ -87,7 +73,13 @@ 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.")
+ '--env',
+ required=True,
+ help="Path to the environment to update.")
+ '--repos', required=True,
+ help="Path to the directory containing the repositories for all LLVM subprojects.")
subcommands = options.add_subparsers()