pw_env_setup: Reduce PW_ENVIRONMENT_ROOT errors
PW_ENVIRONMENT_ROOT is now only set by developers and not by
bootstrap.sh. bootstrap.sh now sets _PW_ACTUAL_ENVIRONMENT_ROOT and
that's what the rest of Pigweed uses. This means that if
PW_ENVIRONMENT_ROOT is set it was always set directly by a user.
Change-Id: I782b4e8dd5168facdf0ad8c333f2c0cf8ec18468
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/14880
Reviewed-by: Keir Mierle <keir@google.com>
Commit-Queue: Rob Mohr <mohrr@google.com>
diff --git a/bootstrap.sh b/bootstrap.sh
index cf56121..11e44e1 100644
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -165,11 +165,19 @@
export PW_ROOT
+# PW_ENVIRONMENT_ROOT allows developers to specify where the environment should
+# be installed. _PW_ACTUAL_ENVIRONMENT_ROOT is where Pigweed keeps that
+# information. This separation allows Pigweed to assume PW_ENVIRONMENT_ROOT
+# came from the developer and not from a previous bootstrap possibly from
+# another workspace.
if [ -z "$PW_ENVIRONMENT_ROOT" ]; then
- PW_ENVIRONMENT_ROOT="$PW_ROOT/.environment"
- export PW_ENVIRONMENT_ROOT
+ _PW_ACTUAL_ENVIRONMENT_ROOT="$PW_ROOT/.environment"
+ export _PW_ACTUAL_ENVIRONMENT_ROOT
+else
+ _PW_ACTUAL_ENVIRONMENT_ROOT="$PW_ENVIRONMENT_ROOT"
+ export _PW_ACTUAL_ENVIRONMENT_ROOT
fi
-SETUP_SH="$PW_ENVIRONMENT_ROOT/activate.sh"
+SETUP_SH="$_PW_ACTUAL_ENVIRONMENT_ROOT/activate.sh"
if [ -z "$PW_ENVSETUP_QUIET" ] && [ -z "$PW_ENVSETUP_NO_BANNER" ]; then
_pw_green "\n WELCOME TO...\n"
@@ -223,9 +231,9 @@
fi
if [ -n "$_PW_ENV_SETUP" ]; then
- "$_PW_ENV_SETUP" --shell-file "$SETUP_SH" --install-dir "$PW_ENVIRONMENT_ROOT"
+ "$_PW_ENV_SETUP" --shell-file "$SETUP_SH" --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT"
else
- "$PYTHON" "$PW_ROOT/pw_env_setup/py/pw_env_setup/env_setup.py" --shell-file "$SETUP_SH" --install-dir "$PW_ENVIRONMENT_ROOT"
+ "$PYTHON" "$PW_ROOT/pw_env_setup/py/pw_env_setup/env_setup.py" --shell-file "$SETUP_SH" --install-dir "$_PW_ACTUAL_ENVIRONMENT_ROOT"
fi
PW_CIPD_PACKAGE_FILES="$_PW_OLD_CIPD_PACKAGE_FILES"