2022-05-09 01:21:54 -04:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
import shutil
|
|
|
|
|
import subprocess
|
|
|
|
|
|
2022-07-01 06:41:44 -07:00
|
|
|
from upstream_utils import (
|
2022-08-20 07:26:34 -07:00
|
|
|
get_repo_root,
|
|
|
|
|
clone_repo,
|
2022-07-01 06:41:44 -07:00
|
|
|
comment_out_invalid_includes,
|
|
|
|
|
walk_cwd_and_copy_if,
|
2022-08-20 07:26:34 -07:00
|
|
|
git_am,
|
2024-07-16 17:20:07 -07:00
|
|
|
Lib,
|
2022-07-01 06:41:44 -07:00
|
|
|
)
|
2022-05-09 01:21:54 -04:00
|
|
|
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def crlf_to_lf():
|
|
|
|
|
for root, _, files in os.walk("."):
|
2022-05-25 00:51:32 -04:00
|
|
|
if ".git" in root:
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
for fname in files:
|
|
|
|
|
filename = os.path.join(root, fname)
|
|
|
|
|
print(f"Converting CRLF -> LF for {filename}")
|
2022-07-01 06:41:44 -07:00
|
|
|
with open(filename, "rb") as f:
|
2022-05-25 00:51:32 -04:00
|
|
|
content = f.read()
|
2022-07-01 06:41:44 -07:00
|
|
|
content = content.replace(b"\r\n", b"\n")
|
2022-05-25 00:51:32 -04:00
|
|
|
|
2022-07-01 06:41:44 -07:00
|
|
|
with open(filename, "wb") as f:
|
2022-05-25 00:51:32 -04:00
|
|
|
f.write(content)
|
|
|
|
|
|
|
|
|
|
subprocess.check_call(["git", "add", "-A"])
|
|
|
|
|
subprocess.check_call(["git", "commit", "-m", "Fix line endings"])
|
|
|
|
|
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def copy_upstream_src(wpilib_root):
|
2022-08-20 07:26:34 -07:00
|
|
|
wpiutil = os.path.join(wpilib_root, "wpiutil")
|
2022-05-09 01:21:54 -04:00
|
|
|
|
2022-07-01 06:41:44 -07:00
|
|
|
shutil.copy(
|
|
|
|
|
os.path.join("Main", "StackWalker", "StackWalker.h"),
|
|
|
|
|
os.path.join(wpiutil, "src/main/native/windows/StackWalker.h"),
|
|
|
|
|
)
|
2022-05-09 01:21:54 -04:00
|
|
|
|
|
|
|
|
shutil.copy(
|
|
|
|
|
os.path.join("Main", "StackWalker", "StackWalker.cpp"),
|
2022-07-01 06:41:44 -07:00
|
|
|
os.path.join(wpiutil, "src/main/native/windows/StackWalker.cpp"),
|
|
|
|
|
)
|
2022-05-09 01:21:54 -04:00
|
|
|
|
|
|
|
|
|
2024-07-16 17:20:07 -07:00
|
|
|
def main():
|
|
|
|
|
name = "stack_walker"
|
|
|
|
|
url = "https://github.com/JochenKalmbach/StackWalker"
|
|
|
|
|
tag = "5b0df7a4db8896f6b6dc45d36e383c52577e3c6b"
|
|
|
|
|
|
|
|
|
|
patch_list = [
|
|
|
|
|
"0001-Add-advapi-pragma.patch",
|
|
|
|
|
]
|
|
|
|
|
patch_options = {
|
|
|
|
|
"ignore_whitespace": True,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
stack_walker = Lib(
|
|
|
|
|
name,
|
|
|
|
|
url,
|
|
|
|
|
tag,
|
|
|
|
|
patch_list,
|
|
|
|
|
copy_upstream_src,
|
|
|
|
|
patch_options,
|
|
|
|
|
pre_patch_hook=crlf_to_lf,
|
|
|
|
|
pre_patch_commits=1,
|
|
|
|
|
)
|
|
|
|
|
stack_walker.main()
|
|
|
|
|
|
|
|
|
|
|
2022-05-09 01:21:54 -04:00
|
|
|
if __name__ == "__main__":
|
|
|
|
|
main()
|