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

[feature] Add tools (conan.tools) to apply patches #8650

Merged
merged 2 commits into from Mar 18, 2021

Conversation

jgsogo
Copy link
Contributor

@jgsogo jgsogo commented Mar 15, 2021

Changelog: Feature: Added conan.tools.files.patch to apply a single patch (new interface for legacy conans.tools.patch function.
Changelog: Feature: Added conan.tools.files.apply_conandata_patches to apply patches defined in conandata.yml.
Docs: conan-io/docs#2062

  • conan.tools.files.patch: this is the replacement of conans.tools.patch, accepting more fields to offer better output to the user.

  • conan.tools.files.apply_conandata_patches: a helper to apply patches that are declared in conandata.yml. Example:

    patches:
      "1.11.0":
        - patch_file: "patches/0001-buildflatbuffers-cmake.patch"
          base_path: "source_subfolder"
        - patch_file: "patches/0002-implicit-copy-constructor.patch"
          base_path: "source_subfolder"
          patch_type: backport
          patch_source: https://github.com/google/flatbuffers/pull/5650
          patch_description: Needed to build with modern clang compilers (adapted to 1.11.0 tagged sources).
      "1.12.0":
        - patch_file: "patches/0001-buildflatbuffers-cmake.patch"
          base_path: "source_subfolder"

Example conanfile.py:

     from conans import ConanFile
     from conan.tools.files import apply_conandata_patches

     class Pkg(ConanFile):
         name = "mypkg"
         version = "1.11.0"

         def build(self):
             apply_conandata_patches(self)

@jgsogo jgsogo added this to the 1.35 milestone Mar 15, 2021
@jgsogo jgsogo requested a review from SSE4 March 15, 2021 18:47
@jgsogo jgsogo marked this pull request as ready for review March 15, 2021 18:47
conan/tools/files/patches.py Outdated Show resolved Hide resolved
Co-authored-by: SSE4 <tomskside@gmail.com>
@memsharded memsharded merged commit c336856 into conan-io:develop Mar 18, 2021
@a4z
Copy link
Contributor

a4z commented Mar 27, 2021

Awesome, every simplification is welcome!

Looking at the example, does this also automatically export the patch files?
Because I think so far patches needed to be in export_sources, or ?

@memsharded
Copy link
Member

Yes, patches need to be exported in exports_sources, this is not automatic yet.

@prince-chrismc
Copy link
Contributor

❤️ 🎉 Amazing addition!

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

Successfully merging this pull request may close these issues.

None yet

6 participants