mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
[upstream_utils] Refactor upstream_utils scripts (#4367)
* Root folder variable names are now more descriptive * clone_repo() now restores the current working directory * Removed setup_upstream_repo() since it's now identical to clone_repo() * Moved am_patches()'s for loop into user scripts so the filename prefix doesn't need to be included in every patch filename * Renamed am_patches() to git_am() since its only job now is to run "git am" * Removed unused apply_patches() function * Fixed typo in git_am()'s ignore_whitespace arg name
This commit is contained in:
@@ -5,12 +5,11 @@ import shutil
|
||||
import subprocess
|
||||
|
||||
from upstream_utils import (
|
||||
setup_upstream_repo,
|
||||
get_repo_root,
|
||||
clone_repo,
|
||||
comment_out_invalid_includes,
|
||||
walk_cwd_and_copy_if,
|
||||
am_patches,
|
||||
walk_if,
|
||||
copy_to,
|
||||
git_am,
|
||||
)
|
||||
|
||||
|
||||
@@ -29,32 +28,36 @@ def crlf_to_lf(stackwalker_dir):
|
||||
with open(filename, "wb") as f:
|
||||
f.write(content)
|
||||
|
||||
cwd = os.getcwd()
|
||||
os.chdir(stackwalker_dir)
|
||||
subprocess.check_call(["git", "add", "-A"])
|
||||
subprocess.check_call(["git", "commit", "-m", "Fix line endings"])
|
||||
os.chdir(cwd)
|
||||
|
||||
|
||||
def main():
|
||||
root, repo = setup_upstream_repo(
|
||||
upstream_root = clone_repo(
|
||||
"https://github.com/JochenKalmbach/StackWalker",
|
||||
"42e7a6e056a9e7aca911a7e9e54e2e4f90bc2652",
|
||||
shallow=False,
|
||||
)
|
||||
wpiutil = os.path.join(root, "wpiutil")
|
||||
wpilib_root = get_repo_root()
|
||||
wpiutil = os.path.join(wpilib_root, "wpiutil")
|
||||
|
||||
# Run CRLF -> LF before trying any patches
|
||||
crlf_to_lf(repo)
|
||||
crlf_to_lf(upstream_root)
|
||||
|
||||
# Apply patches to original git repo
|
||||
patch_dir = os.path.join(root, "upstream_utils/stack_walker_patches")
|
||||
am_patches(
|
||||
repo,
|
||||
[
|
||||
os.path.join(patch_dir, "0001-Apply-PR-35.patch"),
|
||||
os.path.join(patch_dir, "0002-Remove-_M_IX86-checks.patch"),
|
||||
os.path.join(patch_dir, "0003-Add-advapi-pragma.patch"),
|
||||
],
|
||||
ignore_whitespce=True,
|
||||
)
|
||||
# Apply patches to upstream Git repo
|
||||
os.chdir(upstream_root)
|
||||
for f in [
|
||||
"0001-Apply-PR-35.patch",
|
||||
"0002-Remove-_M_IX86-checks.patch",
|
||||
"0003-Add-advapi-pragma.patch",
|
||||
]:
|
||||
git_am(
|
||||
os.path.join(wpilib_root, "upstream_utils/stack_walker_patches", f),
|
||||
ignore_whitespace=True,
|
||||
)
|
||||
|
||||
shutil.copy(
|
||||
os.path.join("Main", "StackWalker", "StackWalker.h"),
|
||||
|
||||
Reference in New Issue
Block a user