2024-04-27 22:42:42 -07: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-04-27 22:42:42 -07: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, has_prefix, walk_cwd_and_copy_if
|
2024-04-27 22:42:42 -07: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
|
|
|
def copy_upstream_src(wpilib_root: Path):
|
|
|
|
|
wpimath = wpilib_root / "wpimath"
|
2024-04-27 22:42:42 -07:00
|
|
|
|
|
|
|
|
# Delete old install
|
|
|
|
|
for d in [
|
|
|
|
|
"src/main/native/thirdparty/sleipnir/src",
|
|
|
|
|
"src/main/native/thirdparty/sleipnir/include",
|
|
|
|
|
]:
|
[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
|
|
|
shutil.rmtree(wpimath / d, ignore_errors=True)
|
|
|
|
|
|
|
|
|
|
# Copy Sleipnir files into allwpilib
|
|
|
|
|
walk_cwd_and_copy_if(
|
2025-12-01 12:51:28 -08:00
|
|
|
lambda dp, f: (has_prefix(dp, Path("include")) or has_prefix(dp, Path("src"))),
|
[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
|
|
|
wpimath / "src/main/native/thirdparty/sleipnir",
|
2024-04-27 22:42:42 -07:00
|
|
|
)
|
|
|
|
|
|
2025-05-27 07:24:15 -07:00
|
|
|
# Write shim for wpi::SmallVector
|
[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
|
|
|
(wpimath / "src/main/native/thirdparty/sleipnir/include/gch").mkdir()
|
2025-05-27 07:24:15 -07:00
|
|
|
with open(
|
[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
|
|
|
wpimath / "src/main/native/thirdparty/sleipnir/include/gch/small_vector.hpp",
|
2025-05-27 07:24:15 -07:00
|
|
|
"w",
|
|
|
|
|
) as f:
|
2026-03-13 13:15:01 -07:00
|
|
|
f.write("""// Copyright (c) Sleipnir contributors
|
2025-05-27 07:24:15 -07:00
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2025-11-07 19:57:55 -05:00
|
|
|
#include <wpi/util/SmallVector.hpp>
|
2025-05-27 07:24:15 -07:00
|
|
|
|
|
|
|
|
namespace gch {
|
|
|
|
|
|
|
|
|
|
template <typename T>
|
2025-11-07 19:58:22 -05:00
|
|
|
using small_vector = wpi::util::SmallVector<T>;
|
2025-05-27 07:24:15 -07:00
|
|
|
|
|
|
|
|
} // namespace gch
|
2026-03-13 13:15:01 -07:00
|
|
|
""")
|
2025-05-27 07:24:15 -07:00
|
|
|
|
2024-04-27 22:42:42 -07:00
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def main():
|
|
|
|
|
name = "sleipnir"
|
|
|
|
|
url = "https://github.com/SleipnirGroup/Sleipnir"
|
2026-05-29 14:59:39 -07:00
|
|
|
tag = "v0.6.1"
|
2024-07-16 17:20:07 -07:00
|
|
|
|
2024-07-23 15:58:15 -07:00
|
|
|
sleipnir = Lib(name, url, tag, copy_upstream_src)
|
2024-07-16 17:20:07 -07:00
|
|
|
sleipnir.main()
|
|
|
|
|
|
|
|
|
|
|
2024-04-27 22:42:42 -07:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|