env_setup: enable host build in Windows

This change fixes pw_exec to work with Windows GOPATHs and enables ANSI
color codes in cmd.exe. This should be the final change required to run
host builds within Windows, so it is added back into the env_setup
steps.

Fixes: 97
Change-Id: I389e9374ec685f2b94de8d7651733207e7b1ecf8
diff --git a/env_setup/env_setup.py b/env_setup/env_setup.py
index aba8d37..44aa41b 100755
--- a/env_setup/env_setup.py
+++ b/env_setup/env_setup.py
@@ -194,11 +194,10 @@
         steps = [
             ('cipd', self.cipd),
             ('python', self.virtualenv),
+            ('host_tools', self.host_build),
         ]
 
         if os.name != 'nt':
-            # TODO(pwbug/97): Fix the boostrap host build in Windows.
-            steps.append(('host_tools', self.host_build))
             # TODO(pwbug/63): Add a Windows version of cargo to CIPD.
             steps.append(('cargo', self.cargo))
 
diff --git a/pw_build/py/exec.py b/pw_build/py/exec.py
index e05330e..f9c5439 100644
--- a/pw_build/py/exec.py
+++ b/pw_build/py/exec.py
@@ -75,7 +75,7 @@
     return parser
 
 
-_ENV_REGEX = re.compile(r'(\w+)(\+)?=([\w/.]+)')
+_ENV_REGEX = re.compile(r'(\w+)(\+)?=(.+)')
 
 
 def apply_env_var(string: str, env: Dict[str, str]) -> None:
diff --git a/pw_cli/py/pw_cli/color.py b/pw_cli/py/pw_cli/color.py
index bfd0544..b5ca84b 100644
--- a/pw_cli/py/pw_cli/color.py
+++ b/pw_cli/py/pw_cli/color.py
@@ -13,6 +13,8 @@
 # the License.
 """Color codes for use by rest of pw_cli."""
 
+import ctypes
+import os
 import sys
 from typing import Optional, Union
 
@@ -62,4 +64,9 @@
         enabled = env.PW_USE_COLOR or (sys.stdout.isatty()
                                        and sys.stderr.isatty())
 
+    if enabled and os.name == 'nt':
+        # Enable ANSI color codes in Windows cmd.exe.
+        kernel32 = ctypes.windll.kernel32
+        kernel32.SetConsoleMode(kernel32.GetStdHandle(-11), 7)
+
     return _Color() if enabled else _NoColor()