ament / uncrustify_vendor

CMake shim over the uncrustify library: https://github.com/uncrustify/uncrustify
Apache License 2.0
0 stars 9 forks source link

Patch does not apply on rebuild #17

Closed cottsay closed 3 years ago

cottsay commented 3 years ago

I don't know if it was #15 or #16, but rebuilding the package after a successful build results in an error now.

error: patch failed: CMakeLists.txt:440
error: CMakeLists.txt: patch does not apply
gmake[2]: *** [CMakeFiles/uncrustify-0.68.1.dir/build.make:119: uncrustify-0.68.1-prefix/src/uncrustify-0.68.1-stamp/uncrustify-0.68.1-patch] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/uncrustify-0.68.1.dir/all] Error 2
gmake: *** [Makefile:160: all] Error 2
clalancette commented 3 years ago

So in the nominal case where there are no changes to the package, this works. Where this fails is when you make changes to the CMakeLists.txt of the package and it thinks it needs to redownload and repatch things; that always fails, and I actually think that will fail with any other vendor package where we patch as well. While I've seen this before, I am actually struggling to replicate it now; do you happen to have a series of steps to make it happen?

cottsay commented 3 years ago

do you happen to have a series of steps to make it happen?

Yeah, just build twice:

$ colcon build --event-handler console_start_end- console_stderr- --packages-up-to uncrustify_vendor

Summary: 17 packages finished [16.7s]
  1 package had stderr output: uncrustify_vendor
$ colcon build --event-handler console_start_end- --packages-select uncrustify_vendor
--- stderr: uncrustify_vendor
error: patch failed: CMakeLists.txt:440
error: CMakeLists.txt: patch does not apply
gmake[2]: *** [CMakeFiles/uncrustify-0.68.1.dir/build.make:119: uncrustify-0.68.1-prefix/src/uncrustify-0.68.1-stamp/uncrustify-0.68.1-patch] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:97: CMakeFiles/uncrustify-0.68.1.dir/all] Error 2
gmake: *** [Makefile:160: all] Error 2
---

Summary: 0 packages finished [1.29s]
  1 package failed: uncrustify_vendor
  1 package had stderr output: uncrustify_vendor
ivanpauno commented 3 years ago

From cmake docs:

Specifies a custom command to patch the sources after an update. By default, no patch command is defined. Note that it can be quite difficult to define an appropriate patch command that performs robustly, especially for download methods such as git where changing the GIT_TAG will not discard changes from a previous patch, but the patch command will be called again after updating to the new tag.

ivanpauno commented 3 years ago

My 2 cents: Maybe the patch command could create a "patch already installed" marker file, and the beginning of the patch command is to test for the existence of that file. That's a bit of a hack, but it would work.