2024-07-21 13:12:49 +08:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import shutil
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
from pathlib import Path
|
2024-07-21 13:12:49 +08:00
|
|
|
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
from upstream_utils import (
|
|
|
|
|
Lib,
|
|
|
|
|
comment_out_invalid_includes,
|
|
|
|
|
has_prefix,
|
|
|
|
|
walk_cwd_and_copy_if,
|
|
|
|
|
)
|
2024-07-21 13:12:49 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def remove_tag(f: str):
|
|
|
|
|
if "apriltag" in f:
|
|
|
|
|
return False
|
|
|
|
|
if "36h11" in f:
|
|
|
|
|
return False
|
|
|
|
|
if "16h5" in f:
|
|
|
|
|
return False
|
|
|
|
|
if "tag" in f:
|
|
|
|
|
return True
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
def copy_upstream_src(wpilib_root: Path):
|
|
|
|
|
apriltag = wpilib_root / "apriltag"
|
2024-07-21 13:12:49 +08:00
|
|
|
|
|
|
|
|
# Delete old install
|
|
|
|
|
shutil.rmtree(
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
apriltag / "src/main/native/thirdparty/apriltag",
|
2024-07-21 13:12:49 +08:00
|
|
|
ignore_errors=True,
|
|
|
|
|
)
|
|
|
|
|
shutil.rmtree(
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
apriltag / "src/main/include/thirdparty/apriltag",
|
2024-07-21 13:12:49 +08:00
|
|
|
ignore_errors=True,
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy apriltag source files into allwpilib
|
|
|
|
|
src_files = walk_cwd_and_copy_if(
|
|
|
|
|
lambda dp, f: (f.endswith(".c") or f.endswith(".cpp"))
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
and not has_prefix(dp, Path("example"))
|
|
|
|
|
and not has_prefix(dp, Path("test"))
|
|
|
|
|
and not f == "getopt.c"
|
2024-07-21 13:12:49 +08:00
|
|
|
and not "py" in f
|
|
|
|
|
and not remove_tag(f),
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
apriltag / "src/main/native/thirdparty/apriltag/src",
|
2024-07-21 13:12:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# Copy apriltag header files into allwpilib
|
|
|
|
|
walk_cwd_and_copy_if(
|
|
|
|
|
lambda dp, f: f.endswith(".h")
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
and not f == "getopt.h"
|
|
|
|
|
and not f == "postscript_utils.h"
|
2024-07-21 13:12:49 +08:00
|
|
|
and not remove_tag(f),
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
apriltag / "src/main/native/thirdparty/apriltag/include",
|
2024-07-21 13:12:49 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
for f in src_files:
|
|
|
|
|
comment_out_invalid_includes(
|
|
|
|
|
f,
|
|
|
|
|
[
|
[upstream_utils] Use pathlib instead of os.path (#7983)
A noteworthy change is the replacement of the `dp.startswith(os.path.join(".", "subdir"))` pattern. pathlib doesn't offer something with similar semantics besides `match` and `full_match`, so there's now a helper function that replicates the behavior.
Other notable changes include the addition of type annotations to ensure code correctness, using == to check file names instead of `endswith` for clarity (`endswith` is still used to check extensions), manual walking and copying being refactored in googletest, json, memory, nanopb, protobuf, and sleipnir to use `walk_cwd_and_copy_if`, and matching functions being shortened to the point where they can just be inlined into the lambda.
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
Co-authored-by: David Vo <auscompgeek@users.noreply.github.com>
2025-05-29 22:05:22 +00:00
|
|
|
apriltag / "src/main/native/thirdparty/apriltag/include",
|
|
|
|
|
apriltag / "src/main/native/thirdparty/apriltag/include/common",
|
2024-07-21 13:12:49 +08:00
|
|
|
],
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
name = "apriltag"
|
|
|
|
|
url = "https://github.com/AprilRobotics/apriltag.git"
|
2025-07-10 15:01:15 -07:00
|
|
|
# master on 2024-07-07
|
2024-09-04 10:12:51 -04:00
|
|
|
tag = "3806edf38ac4400153677e510c9f9dcb81f472c8"
|
2024-07-21 13:12:49 +08:00
|
|
|
|
|
|
|
|
patch_options = {
|
|
|
|
|
"ignore_whitespace": True,
|
|
|
|
|
}
|
|
|
|
|
|
2024-07-23 15:58:15 -07:00
|
|
|
apriltag = Lib(name, url, tag, copy_upstream_src, patch_options)
|
2024-07-21 13:12:49 +08:00
|
|
|
apriltag.main()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|