pw_stm32cube_build: Windows path fixes

Change-Id: Ica81dd08b40959d09f1938bd315a5195f987fbaa
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/167865
Presubmit-Verified: CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Anthony DiGirolamo <tonymd@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/pw_stm32cube_build/py/pw_stm32cube_build/find_files.py b/pw_stm32cube_build/py/pw_stm32cube_build/find_files.py
index 549ca50..7e69303 100644
--- a/pw_stm32cube_build/py/pw_stm32cube_build/find_files.py
+++ b/pw_stm32cube_build/py/pw_stm32cube_build/find_files.py
@@ -239,7 +239,7 @@
 
 def get_sources_and_headers(
     files: List[str], stm32cube_path: pathlib.Path
-) -> Tuple[List[str], List[str]]:
+) -> Tuple[List[pathlib.Path], List[pathlib.Path]]:
     """Gets list of all sources and headers needed to build the stm32cube hal.
 
     Args:
@@ -265,7 +265,7 @@
         files,
     )
 
-    rebase_path = lambda f: str(stm32cube_path / f)
+    rebase_path = lambda f: pathlib.Path(stm32cube_path / f)
     return list(map(rebase_path, source_files)), list(
         map(rebase_path, header_files)
     )
@@ -304,13 +304,10 @@
     (family, defines, name) = parse_product_str(product_str)
 
     family_header_path = list(
-        filter(lambda p: p.endswith(f'/{family}.h'), headers)
+        filter(lambda p: p.name == f'{family}.h', headers)
     )[0]
 
-    with open(family_header_path, 'rb') as family_header:
-        family_header_str = family_header.read().decode(
-            'utf-8', errors='ignore'
-        )
+    family_header_str = family_header_path.read_text('utf-8', errors='ignore')
 
     define = select_define(defines, family_header_str)
 
diff --git a/pw_stm32cube_build/py/tests/find_files_test.py b/pw_stm32cube_build/py/tests/find_files_test.py
index 364e2b0..7ee6d5c 100644
--- a/pw_stm32cube_build/py/tests/find_files_test.py
+++ b/pw_stm32cube_build/py/tests/find_files_test.py
@@ -319,8 +319,8 @@
         self.assertSetEqual(
             set(
                 [
-                    str(path / 'hal_driver/Src/stm32f4xx_hal_adc.c'),
-                    str(path / 'hal_driver/Src/stm32f4xx_hal_eth.c'),
+                    path / 'hal_driver/Src/stm32f4xx_hal_adc.c',
+                    path / 'hal_driver/Src/stm32f4xx_hal_eth.c',
                 ]
             ),
             set(sources),
@@ -328,11 +328,11 @@
         self.assertSetEqual(
             set(
                 [
-                    str(path / 'cmsis_core/Include/core_cm4.h'),
-                    str(path / 'cmsis_device/Include/stm32f4xx.h'),
-                    str(path / 'cmsis_device/Include/stm32f439xx.h'),
-                    str(path / 'hal_driver/Inc/stm32f4xx_hal_eth.h'),
-                    str(path / 'hal_driver/Inc/stm32f4xx_hal.h'),
+                    path / 'cmsis_core/Include/core_cm4.h',
+                    path / 'cmsis_device/Include/stm32f4xx.h',
+                    path / 'cmsis_device/Include/stm32f439xx.h',
+                    path / 'hal_driver/Inc/stm32f4xx_hal_eth.h',
+                    path / 'hal_driver/Inc/stm32f4xx_hal.h',
                 ]
             ),
             set(headers),