Replace --env with --source-dir

Remove the --env argument, which was compulsory for all subcommands, and
replace it with a --source-dir argument, only for those subcommands that
need it.

We do this for 2 reasons:
* Not all subcommands care about the source directory (e.g. llvm.py
  build won't need it)
* llvm.py should not have any knowledge about environments - that
  concept only makes sense for the helper scripts. llvm.py should
  instead receive very specific info about where the source and build
  directories are.

Change-Id: Iffaeef95559e8923bd883d5c51fed8c306287280
diff --git a/scripts/llvm.py b/scripts/llvm.py
index 919caf9..d1bf29d 100644
--- a/scripts/llvm.py
+++ b/scripts/llvm.py
@@ -30,11 +30,6 @@
     exit(1)
 
 
-def get_worktree_root(env):
-    """Get the path to the LLVM worktree corresponding to env."""
-    return os.path.join(env, "llvm")
-
-
 def dump_config(config):
     """Dump the list of projects that are enabled in the given config."""
 
@@ -52,7 +47,7 @@
 
     proj = Proj()
 
-    llvm_worktree_root = get_worktree_root(args.env)
+    llvm_worktree_root = args.sources
     llvm_repos_root = args.repos
     config = LLVMSourceConfig(proj, llvm_worktree_root)
 
@@ -80,7 +75,7 @@
 
     proj = Proj()
 
-    llvm_worktree_root = get_worktree_root(args.env)
+    llvm_worktree_root = args.sources
     config = LLVMSourceConfig(proj, llvm_worktree_root)
 
     llvm_worktree = Clone(proj, llvm_worktree_root)
@@ -100,7 +95,7 @@
 
     proj = Proj()
 
-    llvm_worktree_root = get_worktree_root(args.env)
+    llvm_worktree_root = args.sources
     sourceConfig = LLVMSourceConfig(proj, llvm_worktree_root)
 
     buildConfig = LLVMBuildConfig(sourceConfig, args.build)
@@ -130,11 +125,6 @@
 valid_subprojects = list(LLVMSubproject.get_all_subprojects().keys())
 
 options = ArgumentParser(formatter_class=RawTextHelpFormatter)
-options.add_argument(
-    '--env',
-    required=True,
-    help="Path to the environment to update.")
-
 subcommands = options.add_subparsers(dest="subcommand")
 
 # Subcommand for adding / removing subprojects
@@ -169,6 +159,12 @@
     '--repos',
     help="Path to the directory containing the repositories for all LLVM "
          "subprojects.")
+projs.add_argument(
+    '--source-dir',
+    dest='sources',
+    required=True,
+    help="Path to the directory containing the LLVM worktree that we're adding "
+         "or removing subprojects from.")
 
 # Subcommand for pushing the current branch to origin
 push = subcommands.add_parser(
@@ -176,12 +172,22 @@
     help="Push current branch to origin linaro-local/<user>/<branch>, "
          "for all enabled subprojects.")
 push.set_defaults(run_command=push_current_branch)
+push.add_argument(
+    '--source-dir',
+    dest='sources',
+    required=True,
+    help="Path to the directory containing the LLVM worktree.")
 
 # Subcommand for configuring a build directory
 configure = subcommands.add_parser(
     'configure',
     help="Run CMake in the given build directory.")
 configure.add_argument(
+    '--source-dir',
+    dest='sources',
+    required=True,
+    help="Path to the sources directory. It should contain an LLVM worktree.")
+configure.add_argument(
     '--build-dir',
     dest='build',
     required=True,