pw_toolchain: Fix copying on Windows

Currently copying is broken on Windows:

 cp -af ../third_party/openthread/repo/etc/cmake/openthread-config-generic.h.in gen/include/openthread-config-generic.h
  CreateProcess failed: The system cannot find the file specified.

Fix it with a python one liner.

Bug: 302
Change-Id: Ie046acb71757c90232eb1067c4b779dfcd59857f
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/30201
Reviewed-by: Wyatt Hepler <hepler@google.com>
Commit-Queue: Michael Spang <spang@google.com>
diff --git a/BUILD.gn b/BUILD.gn
index e50f2d7..c2c9796 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -139,6 +139,7 @@
     "$dir_pw_rpc/py",
     "$dir_pw_status/py",
     "$dir_pw_tokenizer/py",
+    "$dir_pw_toolchain/py",
     "$dir_pw_trace/py",
     "$dir_pw_trace_tokenized/py",
     "$dir_pw_unit_test/py",
diff --git a/pw_toolchain/py/BUILD.gn b/pw_toolchain/py/BUILD.gn
new file mode 100644
index 0000000..f2db3c3
--- /dev/null
+++ b/pw_toolchain/py/BUILD.gn
@@ -0,0 +1,26 @@
+# Copyright 2021 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+
+import("//build_overrides/pigweed.gni")
+
+import("$dir_pw_build/python.gni")
+
+pw_python_script("copy_file") {
+  sources = [ "copy_file.py" ]
+  pylintrc = "$dir_pigweed/.pylintrc"
+}
+
+pw_python_group("py") {
+  python_deps = [ ":copy_file" ]
+}
diff --git a/pw_toolchain/py/copy_file.py b/pw_toolchain/py/copy_file.py
new file mode 100644
index 0000000..dda3fef
--- /dev/null
+++ b/pw_toolchain/py/copy_file.py
@@ -0,0 +1,20 @@
+# Copyright 2021 The Pigweed Authors
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may not
+# use this file except in compliance with the License. You may obtain a copy of
+# the License at
+#
+#     https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations under
+# the License.
+"""Copies a file."""
+
+import sys
+import shutil
+
+if __name__ == "__main__":
+    shutil.copyfile(sys.argv[1], sys.argv[2])
diff --git a/pw_toolchain/universal_tools.gni b/pw_toolchain/universal_tools.gni
index 8fcc062..19717ba 100644
--- a/pw_toolchain/universal_tools.gni
+++ b/pw_toolchain/universal_tools.gni
@@ -12,9 +12,17 @@
 # License for the specific language governing permissions and limitations under
 # the License.
 
+import("//build_overrides/pigweed.gni")
+
 pw_universal_copy = {
   if (host_os == "win") {
-    command = "cp -af {{source}} {{output}}"
+    command = string_join(" ",
+                          [
+                            python_path,
+                            rebase_path("$dir_pw_toolchain/copy_file.py"),
+                            "{{source}}",
+                            "{{output}}",
+                          ])
   } else {
     # Use a hard link if possible as this is faster. Also, Mac doesn't
     # preserve timestamps properly with cp -af.