Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix patch step for OCCT and OpenCV dependencies #5966

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jpalazz2
Copy link

The PATCH_COMMAND for OCCT and OpenCV are trying to patch files that don't exist because of the addition of the --directory flag. PATCH_COMMAND runs in the working directory of the downloaded source files per my own testing. Specifying --directory here is causing the patch to try to apply to dep_OpenCV-prefix/src/OpenCV from root of the downloaded source rather than from the root of the downloaded source code. This causes git apply to try to patch files that don't exist which returns nonzero error codes (I can only reproduce this behavior of git apply when the --directory flag is present, without it the patch fails silently). I have a comment going into a bit more depth about this here.

This is leading to the build failures and workaround being discussed in #4158, #4689, #5171.

With these changes I'm able to fully cleanbuild on Arch Linux.

The `PATCH_COMMAND` for OCCT and OpenCV are trying to patch files that
don't exist because of the addition of the `--directory` flag.
`PATCH_COMMAND` runs in the working directory of the downloaded source
files per my own testing. Specifying `--directory` here is causing the
patch to try to apply the patch to `dep_OpenCV-prefix/src/OpenCV` from
root of the downloaded source. `git apply` returns nonzero error codes
when patching non-existent files AND specifying the `--directory`
flag.
@jpalazz2
Copy link
Author

As a follow up, here's the series of commands that cmake generates for the build step when supplying something for PATCH_COMMAND (they're chained but I'll place them on individual lines to improve readability):

cd /home/jpalazz2/Documents/OrcaSlicer/deps/build/dep_OpenCV-prefix/src/dep_OpenCV
git apply --directory deps/build/dep_OpenCV-prefix/src/dep_OpenCV --verbose --ignore-space-change --whitespace=fix /home/jpalazz2/Documents/OrcaSlicer/deps/OpenCV/0001-vs2022.patch
/usr/bin/cmake -E touch /home/jpalazz2/Documents/OrcaSlicer/deps/build/dep_OpenCV-prefix/src/dep_OpenCV-stamp/dep_OpenCV-patch

The first command changes working directory right into sourceDir. Looking at this command, I fully expected it to fail as I assumed that since the working directory was already set as sourceDir, passing a relative path again to --directory suggested to me that the patching would screw up the paths for patched files.

After a bunch of experimentation I found that if the file paths after prepending the value from --directory matches a file from the root of the git repository it just happens to patch properly.

I confirmed this behavior by grabbing an archive of the latest version from https://github.com/SoftFever/OrcaSlicer/archive/refs/tags/v2.2.0.tar.gz and trying to run the build linux script. The downloaded archive doesn't git initialized and the build fails when trying to patch OpenCV and OCCT. If you simply initialize an empty git repository at the root of that archive the patch step suddenly succeeds again!

This seems like it might be a bug in the behavior of git apply --directory. I may follow up with a bug report for git, for the purposes of this project, removing the --directory flag entirely is totally fine and will resolve this weird interaction with git for us folks building from source.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant