Skip to content

Commit

Permalink
upstream utils: use os path separator when matching path
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Aug 23, 2024
1 parent 7a2604b commit 912fb36
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion upstream_utils/apriltag.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ def copy_upstream_src(wpilib_root):
# Copy apriltag source files into allwpilib
src_files = walk_cwd_and_copy_if(
lambda dp, f: (f.endswith(".c") or f.endswith(".cpp"))
and not dp.startswith("./example")
and not dp.startswith(os.path.join(".","example"))
and not dp.startswith(os.path.join(".","test"))
and not f.endswith("getopt.c")
and not "py" in f
and not remove_tag(f),
Expand Down
4 changes: 2 additions & 2 deletions upstream_utils/eigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def eigen_inclusions(dp, f):
dp -- directory path
f -- filename
"""
if not dp.startswith("./Eigen"):
if not dp.startswith(os.path.join(".", "Eigen")):
return False

abspath = os.path.join(dp, f)
Expand Down Expand Up @@ -79,7 +79,7 @@ def unsupported_inclusions(dp, f):
dp -- directory path
f -- filename
"""
if not dp.startswith("./unsupported"):
if not dp.startswith(os.path.join(".", "unsupported")):
return False

abspath = os.path.join(dp, f)
Expand Down
4 changes: 2 additions & 2 deletions upstream_utils/fmt.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ def copy_upstream_src(wpilib_root):

# Copy fmt source files into allwpilib
walk_cwd_and_copy_if(
lambda dp, f: dp.startswith("./src") and f.endswith(".cc") and f != "fmt.cc",
lambda dp, f: dp.startswith(os.path.join(".","src")) and f.endswith(".cc") and f != "fmt.cc",
os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
)

# Copy fmt header files into allwpilib
walk_cwd_and_copy_if(
lambda dp, f: dp.startswith("./include/fmt"),
lambda dp, f: dp.startswith(os.path.join(".", "include", "fmt")),
os.path.join(wpiutil, "src/main/native/thirdparty/fmtlib"),
)

Expand Down
2 changes: 1 addition & 1 deletion upstream_utils/gcem.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def copy_upstream_src(wpilib_root):

# Copy gcem include files into allwpilib
walk_cwd_and_copy_if(
lambda dp, f: dp.startswith("./include"),
lambda dp, f: dp.startswith(os.path.join(".", "include")),
os.path.join(wpimath, "src/main/native/thirdparty/gcem"),
)

Expand Down
4 changes: 2 additions & 2 deletions upstream_utils/glfw.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def src_filter(dp, f):
if f.endswith("CMakeLists.txt"):
return False

if dp.startswith("./src"):
if dp.startswith(os.path.join(".", "src")):
return True

return False
Expand All @@ -50,7 +50,7 @@ def src_filter(dp, f):
)

def cmake_filter(dp, f):
if dp.startswith("./CMake"):
if dp.startswith(os.path.join(".", "CMake")):
return True

path = os.path.join(dp, f)
Expand Down
4 changes: 2 additions & 2 deletions upstream_utils/libuv.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def copy_upstream_src(wpilib_root):
]

walk_cwd_and_copy_if(
lambda dp, f: dp.startswith("./include") and f not in include_ignorelist,
lambda dp, f: dp.startswith(os.path.join(".", "include")) and f not in include_ignorelist,
os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
)

Expand All @@ -45,7 +45,7 @@ def copy_upstream_src(wpilib_root):
"sysinfo-memory.c",
]
walk_cwd_and_copy_if(
lambda dp, f: dp.startswith("./src") and f not in src_ignorelist,
lambda dp, f: dp.startswith(os.path.join(".", "src")) and f not in src_ignorelist,
os.path.join(wpinet, "src/main/native/thirdparty/libuv"),
rename_c_to_cpp=True,
)
Expand Down
2 changes: 1 addition & 1 deletion upstream_utils/protobuf.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@


def matches(dp, f, files):
if not dp.startswith("./src/"):
if not dp.startswith(os.path.join(".", "src")):
return False
p = dp[6:] + "/" + f
return p in files
Expand Down

0 comments on commit 912fb36

Please sign in to comment.