pw_env_setup: Don't clear out args.gn
pwrev/33125 causes args.gn to be cleared out when running bootstrap.
Update it to only set dir_pigweed when the build directory has not yet
been created.
Change-Id: Ib6f34005c1093771d126bda9bef48196b2f27a0d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/42800
Reviewed-by: Paul Mathieu <paulmathieu@google.com>
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py b/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
index d6036fe..555f462 100644
--- a/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
+++ b/pw_env_setup/py/pw_env_setup/virtualenv_setup/install.py
@@ -203,12 +203,13 @@
gn_log_path = os.path.join(venv_path, gn_log)
try:
with open(gn_log_path, 'w') as outs:
- gn_cmd = (
- 'gn',
- 'gen',
- build_dir,
- '--args=dir_pigweed="{}"'.format(pw_root),
- )
+ gn_cmd = ['gn', 'gen', build_dir]
+
+ # Only set dir_pigweed if we don't have an existing build
+ # directory.
+ if not os.path.isdir(build_dir):
+ gn_cmd.append('--args=dir_pigweed="{}"'.format(pw_root))
+
print(gn_cmd, file=outs)
subprocess.check_call(gn_cmd,
cwd=os.path.join(project_root,