pw_env_setup: More windows fixes

Paths are hard. %~dp0 ends with a backslash, which apparently DOES break
things! adds a "." afterwards to ensure paths remain valid. Also makes
it so the windows env-setup banner shows on bootstrap runs.

Change-Id: Id062566ef883468996f26093bcdb66ab77b53f4d
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/23752
Commit-Queue: Armando Montanez <amontanez@google.com>
Reviewed-by: Rob Mohr <mohrr@google.com>
diff --git a/bootstrap.bat b/bootstrap.bat
index ca68f5d..57f89fe 100644
--- a/bootstrap.bat
+++ b/bootstrap.bat
@@ -50,7 +50,7 @@
 
 :: ~dp0 is the batchism for the directory in which a .bat file resides.
 if "%PW_CHECKOUT_ROOT%"=="" ^
-set "PW_ROOT=%~dp0" &^
+set "PW_ROOT=%~dp0." &^
 goto select_python
 
 :: Since PW_CHECKOUT_ROOT is set, use it.
@@ -108,10 +108,11 @@
 :: Without the trailing slash in %PW_ROOT%/, batch combines that token with
 :: the --shell-file argument.
 call "%python%" "%PW_ROOT%\pw_env_setup\py\pw_env_setup\env_setup.py" ^
-    --pw-root "%PW_ROOT%/" ^
+    --pw-root "%PW_ROOT%" ^
     --shell-file "%shell_file%" ^
     --install-dir "%_PW_ACTUAL_ENVIRONMENT_ROOT%" ^
-    --use-pigweed-defaults
+    --use-pigweed-defaults ^
+    --project-root "%PW_PROJECT_ROOT%"
 goto activate_shell
 
 :skip_bootstrap
diff --git a/pw_env_setup/py/pw_env_setup/env_setup.py b/pw_env_setup/py/pw_env_setup/env_setup.py
index 328e8c4..c03bd43 100755
--- a/pw_env_setup/py/pw_env_setup/env_setup.py
+++ b/pw_env_setup/py/pw_env_setup/env_setup.py
@@ -73,6 +73,7 @@
 from pw_env_setup import environment
 from pw_env_setup import spinner
 from pw_env_setup import virtualenv_setup
+from pw_env_setup import windows_env_start
 
 
 # TODO(pwbug/67, pwbug/68) switch to shutil.which().
@@ -251,7 +252,10 @@
     def setup(self):
         """Runs each of the env_setup steps."""
 
-        enable_colors()
+        if os.name == 'nt':
+            windows_env_start.print_banner(bootstrap=True, no_shell_file=False)
+        else:
+            enable_colors()
 
         steps = [
             ('CIPD package manager', self.cipd),
diff --git a/pw_env_setup/py/pw_env_setup/windows_env_start.py b/pw_env_setup/py/pw_env_setup/windows_env_start.py
index dc8c8f1..62770a8 100644
--- a/pw_env_setup/py/pw_env_setup/windows_env_start.py
+++ b/pw_env_setup/py/pw_env_setup/windows_env_start.py
@@ -37,22 +37,14 @@
 '''
 
 
-def main():
-    """Script entry point."""
-    if os.name != 'nt':
-        return 1
-
-    parser = argparse.ArgumentParser()
-    parser.add_argument('--bootstrap', action='store_true')
-    parser.add_argument('--no-shell-file', action='store_true')
-    args = parser.parse_args()
-
+def print_banner(bootstrap, no_shell_file):
+    """Print the Pigweed or project-specific banner"""
     enable_colors()
 
     print(Color.green('\n  WELCOME TO...'))
     print(Color.magenta(_PIGWEED_BANNER))
 
-    if args.bootstrap:
+    if bootstrap:
         print(
             Color.green('\n  BOOTSTRAP! Bootstrap may take a few minutes; '
                         'please be patient'))
@@ -65,7 +57,7 @@
                 '\n  ACTIVATOR! This sets your console environment variables.\n'
             ))
 
-        if args.no_shell_file:
+        if no_shell_file:
             print(Color.bold_red('Error!\n'))
             print(
                 Color.red('  Your Pigweed environment does not seem to be'
@@ -75,5 +67,20 @@
     return 0
 
 
+def parse():
+    """Parse command-line arguments."""
+    parser = argparse.ArgumentParser()
+    parser.add_argument('--bootstrap', action='store_true')
+    parser.add_argument('--no-shell-file', action='store_true')
+    return parser.parse_args()
+
+
+def main():
+    """Script entry point."""
+    if os.name != 'nt':
+        return 1
+    return print_banner(**vars(parse()))
+
+
 if __name__ == '__main__':
     sys.exit(main())