Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions qualcomm-software/cmake/patch_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():
"--method",
choices=["am", "apply"],
default="apply",
help="Git command to use. git am will add each patch as a commit, whereas git apply will leave patched changes staged.",
help="Git command to use. git am will add each patch as a commit, whereas git apply will leave patched changes staged and skip patches that are already applied.",
)
parser.add_argument(
"--reset",
Expand Down Expand Up @@ -114,7 +114,9 @@ def main():
if args.three_way:
apply_check_args.append("--3way")
apply_check_args.append(str(current_patch))
p_check = subprocess.run(apply_check_args)
p_check = subprocess.run(
apply_check_args, capture_output=True, text=True
)

if p_check.returncode == 0:
# Patch will apply.
Expand All @@ -129,7 +131,23 @@ def main():
p = subprocess.run(apply_args, check=True)
applied_patches.append(current_patch)
else:
# Patch won't apply.
# Patch does not apply cleanly. Check if it is already applied
# by attempting a reverse check.
reverse_check_args = git_cmd + [
"apply",
"--ignore-whitespace",
"--reverse",
"--check",
str(current_patch),
]
p_rev = subprocess.run(
reverse_check_args, capture_output=True, text=True
)
if p_rev.returncode == 0:
print(f"Skipping {current_patch.name} (already applied).")
continue

# Patch is not already applied and cannot be applied cleanly.
print(f"Unable to apply {current_patch.name}")
if args.restore_on_fail:
# Remove any patches that have already been applied.
Expand Down
11 changes: 5 additions & 6 deletions qualcomm-software/docs/developing.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,12 @@ and libc++/libc++abi/libunwind libraries for the variant.
### Re-running CMake
Unless you have manually checked out and patched CPULLVM's various dependencies (see "Manually checking out
and patching dependencies" below), CPULLVM's CMake will automatically checkout and patch the dependencies'
Git repositories. Note that it will *always* try to patch these repos, even if the patches have already been
applied. So, if you rerun CMake (either by manually invoking it or by modifying a file in some way that CMake
automatically reruns when rebuilding), you'll likely encounter errors.
Git repositories. The patching script will skip patches that have already been applied,
so re-running CMake is safe in the common case.

To work around this, after the first time you invoke CMake, you can include `-DFETCHCONTENT_FULLY_DISCONNECTED=ON`
in your CMake command to tell it to stop updating and patching. Worst case, you can also manually remove the
cloned repostories (located in `<build>/_deps`).
If you encounter issues with re-running CMake (for example, after a failed or partial patch application),
you can include `-DFETCHCONTENT_FULLY_DISCONNECTED=ON` in your CMake command to tell it to stop updating
and patching. Worst case, you can also manually remove the cloned repositories (located in `<build>/_deps`).

### Manually checking out and patching dependencies
It is also possible to manually checkout CPULLVM's dependencies. If you do so, you must ensure the
Expand Down
Loading