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

"patch" tool directory where locate the patch files #10875

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion conan/tools/files/patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def patch(conanfile, base_path=None, patch_file=None, patch_string=None, strip=0
if patch_file:
# trick *1: patch_file path could be absolute (e.g. conanfile.build_folder), in that case
# the join does nothing and works.
patch_path = os.path.join(conanfile.source_folder, patch_file)
patch_path = os.path.join(conanfile.base_source_folder, patch_file)
patchset = patch_ng.fromfile(patch_path)
else:
patchset = patch_ng.fromstring(patch_string.encode())
Expand Down
4 changes: 3 additions & 1 deletion conans/test/unittests/tools/files/test_patches.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,15 @@ def test_single_patch_file_from_forced_build(mock_patch_ng):
def test_base_path(mock_patch_ng):
conanfile = ConanFileMock()
conanfile.folders.set_base_source("/my_source")
conanfile.folders.source = "src" # This not applies to find the patch file but for applying it
conanfile.display_name = 'mocked/ref'
patch(conanfile, patch_file='patch-file', base_path="subfolder")
assert mock_patch_ng.filename.replace("\\", "/") == '/my_source/patch-file'
assert mock_patch_ng.string is None
assert mock_patch_ng.apply_args == (os.path.join("/my_source", "subfolder"), 0, False)
assert mock_patch_ng.apply_args == (os.path.join("/my_source", "src", "subfolder"), 0, False)
assert len(str(conanfile.output)) == 0


def test_apply_in_build_from_patch_in_source(mock_patch_ng):
conanfile = ConanFileMock()
conanfile.folders.set_base_source("/my_source")
Expand Down