2022-05-20 18:59:53 -04: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
|
2022-05-20 18:59:53 -04:00
|
|
|
|
2024-07-20 07:01:06 -07:00
|
|
|
from upstream_utils import Lib
|
2022-05-20 18:59:53 -04: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 run_global_replacements(wpiutil_llvm_files: list[Path]):
|
2022-05-20 18:59:53 -04:00
|
|
|
for wpi_file in wpiutil_llvm_files:
|
|
|
|
|
with open(wpi_file) as f:
|
|
|
|
|
content = f.read()
|
|
|
|
|
|
|
|
|
|
# Rename namespace from llvm to wpi
|
|
|
|
|
content = content.replace("namespace llvm", "namespace wpi")
|
2024-12-24 17:40:31 -08:00
|
|
|
content = content.replace("llvm:", "wpi:")
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
# Fix #includes
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace('include "llvm/ADT', 'include "wpi')
|
|
|
|
|
content = content.replace('include "llvm/Config', 'include "wpi')
|
|
|
|
|
content = content.replace('include "llvm/Support', 'include "wpi')
|
2022-05-20 18:59:53 -04:00
|
|
|
|
2022-10-15 16:33:14 -07:00
|
|
|
# Fix uses of span
|
|
|
|
|
content = content.replace("span", "std::span")
|
2023-07-12 22:50:13 -07:00
|
|
|
content = content.replace("include <std::span>", "include <span>")
|
[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
|
|
|
if wpi_file.name == "ConvertUTFWrapper.cpp":
|
2022-10-15 16:33:14 -07:00
|
|
|
content = content.replace(
|
|
|
|
|
"const UTF16 *Src = reinterpret_cast<const UTF16 *>(SrcBytes.begin());",
|
|
|
|
|
"const UTF16 *Src = reinterpret_cast<const UTF16 *>(&*SrcBytes.begin());",
|
|
|
|
|
)
|
|
|
|
|
content = content.replace(
|
|
|
|
|
"const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(SrcBytes.end());",
|
|
|
|
|
"const UTF16 *SrcEnd = reinterpret_cast<const UTF16 *>(&*SrcBytes.begin() + SrcBytes.size());",
|
|
|
|
|
)
|
2023-07-12 22:50:13 -07:00
|
|
|
content = content.replace(
|
|
|
|
|
"const UTF32 *Src = reinterpret_cast<const UTF32 *>(SrcBytes.begin());",
|
|
|
|
|
"const UTF32 *Src = reinterpret_cast<const UTF32 *>(&*SrcBytes.begin());",
|
|
|
|
|
)
|
|
|
|
|
content = content.replace(
|
|
|
|
|
"const UTF32 *SrcEnd = reinterpret_cast<const UTF32 *>(SrcBytes.end());",
|
|
|
|
|
"const UTF32 *SrcEnd = reinterpret_cast<const UTF32 *>(&*SrcBytes.begin() + SrcBytes.size());",
|
|
|
|
|
)
|
2022-10-15 16:33:14 -07:00
|
|
|
|
2022-05-20 18:59:53 -04:00
|
|
|
# Remove unused headers
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace('#include "llvm-c/ErrorHandling.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Debug.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Error.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Format.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/FormatVariadic.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/NativeFormatting.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Threading.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/DataTypes.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/llvm-config.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/abi-breaking.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/config.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Signals.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Process.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Path.h"\n', "")
|
|
|
|
|
content = content.replace('#include "wpi/Program.h"\n', "")
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
# Fix include guards
|
|
|
|
|
content = content.replace("LLVM_ADT_", "WPIUTIL_WPI_")
|
|
|
|
|
content = content.replace("LLVM_SUPPORT_", "WPIUTIL_WPI_")
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace("LLVM_DEFINED_HAS_FEATURE", "WPI_DEFINED_HAS_FEATURE")
|
2022-05-20 18:59:53 -04:00
|
|
|
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace("const std::string_view &", "std::string_view ")
|
|
|
|
|
content = content.replace("sys::fs::openFileForRead", "fs::OpenFileForRead")
|
2022-05-20 18:59:53 -04:00
|
|
|
content = content.replace("sys::fs::closeFile", "fs::CloseFile")
|
|
|
|
|
content = content.replace("sys::fs::", "fs::")
|
|
|
|
|
|
|
|
|
|
# Replace wpi/FileSystem.h with wpi/fs.h
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace('include "wpi/FileSystem.h"', 'include "wpi/fs.h"')
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
# Replace llvm_unreachable() with wpi_unreachable()
|
|
|
|
|
content = content.replace("llvm_unreachable", "wpi_unreachable")
|
|
|
|
|
|
|
|
|
|
content = content.replace("llvm_is_multithreaded()", "1")
|
|
|
|
|
|
|
|
|
|
# Revert message in copyright header
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace("/// Defines the wpi::", "/// Defines the llvm::")
|
|
|
|
|
content = content.replace("// end llvm namespace", "// end wpi namespace")
|
|
|
|
|
content = content.replace("// end namespace llvm", "// end namespace wpi")
|
|
|
|
|
content = content.replace("// End llvm namespace", "// End wpi namespace")
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
content = content.replace("fs::openFileForRead", "fs::OpenFileForRead")
|
|
|
|
|
|
|
|
|
|
with open(wpi_file, "w") as f:
|
|
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
|
|
|
[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 flattened_llvm_files(llvm: Path, dirs_to_keep: list[Path]):
|
|
|
|
|
file_lookup: dict[str, Path] = {}
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
for dir_to_keep in dirs_to_keep:
|
[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
|
|
|
dir_to_crawl = llvm / dir_to_keep
|
|
|
|
|
for root, _, files in dir_to_crawl.walk():
|
2022-05-20 18:59:53 -04:00
|
|
|
for f in files:
|
[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
|
|
|
file_lookup[f] = root / f
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
return file_lookup
|
|
|
|
|
|
|
|
|
|
|
[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 find_wpiutil_llvm_files(wpiutil_root: Path, subfolder: str):
|
2022-05-20 18:59:53 -04:00
|
|
|
# These files have substantial changes, not worth managing with the patching process
|
|
|
|
|
ignore_list = [
|
2022-07-01 06:41:44 -07:00
|
|
|
"StringExtras.h",
|
|
|
|
|
"StringExtras.cpp",
|
|
|
|
|
"MemoryBuffer.cpp",
|
|
|
|
|
"MemoryBuffer.h",
|
|
|
|
|
"SmallVectorMemoryBuffer.h",
|
2022-05-20 18:59:53 -04: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
|
|
|
wpiutil_files: list[Path] = []
|
|
|
|
|
for root, _, files in (wpiutil_root / subfolder).walk():
|
2022-05-20 18:59:53 -04:00
|
|
|
for f in files:
|
|
|
|
|
if f not in ignore_list:
|
[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
|
|
|
full_file = root / f
|
2022-06-18 11:08:31 -04:00
|
|
|
wpiutil_files.append(full_file)
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
return wpiutil_files
|
|
|
|
|
|
|
|
|
|
|
[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 overwrite_files(wpiutil_files: list[Path], llvm_files: dict[str, Path]):
|
2022-05-20 18:59:53 -04:00
|
|
|
# Very sparse rips from LLVM sources. Not worth tyring to make match upstream
|
|
|
|
|
unmatched_files_whitelist = ["fs.h", "fs.cpp", "function_ref.h"]
|
|
|
|
|
|
|
|
|
|
for wpi_file in wpiutil_files:
|
[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
|
|
|
wpi_base_name = wpi_file.name
|
2022-11-14 10:11:54 +03:00
|
|
|
if wpi_base_name in llvm_files:
|
2022-05-20 18:59:53 -04:00
|
|
|
shutil.copyfile(llvm_files[wpi_base_name], wpi_file)
|
|
|
|
|
|
2022-11-14 10:11:54 +03:00
|
|
|
elif wpi_base_name not in unmatched_files_whitelist:
|
|
|
|
|
print(f"No file match for {wpi_file}, check if LLVM deleted it")
|
|
|
|
|
|
2022-05-20 18:59:53 -04: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 overwrite_source(wpiutil_root: Path, llvm_root: Path):
|
2022-07-01 06:41:44 -07:00
|
|
|
llvm_files = flattened_llvm_files(
|
|
|
|
|
llvm_root,
|
|
|
|
|
[
|
[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
|
|
|
Path("llvm/include/llvm/ADT/"),
|
|
|
|
|
Path("llvm/include/llvm/Config/"),
|
|
|
|
|
Path("llvm/include/llvm/Support/"),
|
|
|
|
|
Path("llvm/lib/Support/"),
|
2022-07-01 06:41:44 -07:00
|
|
|
],
|
|
|
|
|
)
|
2022-05-20 18:59:53 -04:00
|
|
|
wpi_files = find_wpiutil_llvm_files(
|
2022-06-18 11:08:31 -04:00
|
|
|
wpiutil_root, "src/main/native/thirdparty/llvm/include/wpi"
|
2022-07-01 06:41:44 -07:00
|
|
|
) + find_wpiutil_llvm_files(
|
|
|
|
|
wpiutil_root, "src/main/native/thirdparty/llvm/cpp/llvm"
|
|
|
|
|
)
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
overwrite_files(wpi_files, llvm_files)
|
|
|
|
|
run_global_replacements(wpi_files)
|
|
|
|
|
|
|
|
|
|
|
[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 overwrite_tests(wpiutil_root: Path, llvm_root: Path):
|
2022-07-01 06:41:44 -07:00
|
|
|
llvm_files = flattened_llvm_files(
|
|
|
|
|
llvm_root,
|
[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
|
|
|
[
|
|
|
|
|
Path("llvm/unittests/ADT/"),
|
|
|
|
|
Path("llvm/unittests/Config/"),
|
|
|
|
|
Path("llvm/unittests/Support/"),
|
|
|
|
|
],
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
|
|
|
|
wpi_files = find_wpiutil_llvm_files(wpiutil_root, "src/test/native/cpp/llvm")
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
overwrite_files(wpi_files, llvm_files)
|
|
|
|
|
run_global_replacements(wpi_files)
|
|
|
|
|
|
|
|
|
|
|
[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):
|
|
|
|
|
upstream_root = Path(".").absolute()
|
|
|
|
|
wpiutil = wpilib_root / "wpiutil"
|
2022-08-20 07:26:34 -07:00
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
overwrite_source(wpiutil, upstream_root)
|
|
|
|
|
overwrite_tests(wpiutil, upstream_root)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
|
name = "llvm"
|
|
|
|
|
url = "https://github.com/llvm/llvm-project"
|
2024-12-24 17:40:31 -08:00
|
|
|
tag = "llvmorg-19.1.6"
|
2024-07-16 17:20:07 -07:00
|
|
|
|
|
|
|
|
patch_options = {
|
|
|
|
|
"use_threeway": True,
|
|
|
|
|
}
|
2022-08-20 07:26:34 -07:00
|
|
|
|
2024-07-23 15:58:15 -07:00
|
|
|
llvm = Lib(name, url, tag, copy_upstream_src, patch_options)
|
2024-07-16 17:20:07 -07:00
|
|
|
llvm.main()
|
2022-05-20 18:59:53 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|