From f6f6aa13edd56e0f2779b0fc58370387da1a15aa Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Tue, 1 Jun 2021 10:18:38 +0300 Subject: [PATCH] aedi: make patching explicit --- aedi/builder.py | 4 ---- aedi/state.py | 23 ++++++++++++------- aedi/target/library_tier1.py | 3 ++- aedi/target/library_tier2.py | 12 ++++++---- patch/{mad.patch => mad-support-arm64.diff} | 0 patch/{ogg.patch => ogg-fix-compile.diff} | 0 ...di.patch => portmidi-modernize-cmake.diff} | 0 ...te.patch => samplerate-support-arm64.diff} | 0 ...r.patch => sdl2_mixer-fix-fluidsynth.diff} | 0 9 files changed, 25 insertions(+), 17 deletions(-) rename patch/{mad.patch => mad-support-arm64.diff} (100%) rename patch/{ogg.patch => ogg-fix-compile.diff} (100%) rename patch/{portmidi.patch => portmidi-modernize-cmake.diff} (100%) rename patch/{samplerate.patch => samplerate-support-arm64.diff} (100%) rename patch/{sdl2_mixer.patch => sdl2_mixer-fix-fluidsynth.diff} (100%) diff --git a/aedi/builder.py b/aedi/builder.py index 63af2fe6..85ff5ef0 100644 --- a/aedi/builder.py +++ b/aedi/builder.py @@ -59,10 +59,6 @@ class Builder(object): del self._targets - patch_path = f'{state.root_path}patch/{self._target.name}.patch' - if os.path.exists(patch_path): - state.patch_path = patch_path - if arguments.build_path: state.build_path = os.path.abspath(arguments.build_path) else: diff --git a/aedi/state.py b/aedi/state.py index c7649ff8..e025825b 100644 --- a/aedi/state.py +++ b/aedi/state.py @@ -36,7 +36,6 @@ class BuildState: self.source = None self.external_source = True - self.patch_path = None self.build_path = None self.native_build_path = None @@ -78,7 +77,7 @@ class BuildState: args = ('git', 'checkout', '-b', branch, 'origin/' + branch) subprocess.run(args, cwd=self.source, check=True) - def download_source(self, url: str, checksum: str): + def download_source(self, url: str, checksum: str, patches: [tuple, list, str] = None): if self.external_source: return @@ -88,7 +87,16 @@ class BuildState: self._verify_checksum(checksum, data, filepath) first_path_component, extract_path = self._unpack_source_package(filepath) - self._apply_source_patch(extract_path) + + if not patches: + pass + elif isinstance(patches, str): + self._apply_source_patch(extract_path, patches) + elif isinstance(patches, (tuple, list)): + for patch in patches: + self._apply_source_patch(extract_path, patch) + else: + assert False # Adjust source and build paths according to extracted source code self.source = extract_path @@ -154,15 +162,14 @@ class BuildState: return first_path_component, extract_path - def _apply_source_patch(self, extract_path: str): - if not self.patch_path: - return + def _apply_source_patch(self, extract_path: str, patch: str): + patch_path = f'{self.root_path}patch/{patch}.diff' - assert os.path.exists(self.patch_path) + assert os.path.exists(patch_path) # Check if patch is already applied test_arg = '--dry-run' - args = ['patch', test_arg, '--strip=1', '--input=' + self.patch_path] + args = ['patch', test_arg, '--strip=1', '--input=' + patch_path] if subprocess.call(args, cwd=extract_path) == 0: # Patch wasn't applied yet, do it now diff --git a/aedi/target/library_tier1.py b/aedi/target/library_tier1.py index 611c73a2..94a4f613 100644 --- a/aedi/target/library_tier1.py +++ b/aedi/target/library_tier1.py @@ -325,7 +325,8 @@ class OggTarget(CMakeStaticDependencyTarget): def prepare_source(self, state: BuildState): state.download_source( 'https://ftp.osuosl.org/pub/xiph/releases/ogg/libogg-1.3.4.tar.gz', - 'fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e') + 'fe5670640bd49e828d64d2879c31cb4dde9758681bb664f9bdbf159a01b0c76e', + patches='ogg-fix-compile') def detect(self, state: BuildState) -> bool: return os.path.exists(state.source + 'ogg.pc.in') diff --git a/aedi/target/library_tier2.py b/aedi/target/library_tier2.py index e3393807..ddbdd776 100644 --- a/aedi/target/library_tier2.py +++ b/aedi/target/library_tier2.py @@ -69,7 +69,8 @@ class MadTarget(ConfigureMakeStaticDependencyTarget): def prepare_source(self, state: BuildState): state.download_source( 'https://downloads.sourceforge.net/project/mad/libmad/0.15.1b/libmad-0.15.1b.tar.gz', - 'bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690') + 'bbfac3ed6bfbc2823d3775ebb931087371e142bb0e9bb1bee51a76a6e0078690', + patches='mad-support-arm64') def detect(self, state: BuildState) -> bool: return os.path.exists(state.source + 'mad.h') @@ -156,7 +157,8 @@ class PortMidiTarget(CMakeTarget): def prepare_source(self, state: BuildState): state.download_source( 'https://downloads.sourceforge.net/project/portmedia/portmidi/217/portmidi-src-217.zip', - '08e9a892bd80bdb1115213fb72dc29a7bf2ff108b378180586aa65f3cfd42e0f') + '08e9a892bd80bdb1115213fb72dc29a7bf2ff108b378180586aa65f3cfd42e0f', + patches='portmidi-modernize-cmake') def detect(self, state: BuildState) -> bool: return os.path.exists(state.source + 'pm_common/portmidi.h') @@ -182,7 +184,8 @@ class SamplerateTarget(CMakeStaticDependencyTarget): def prepare_source(self, state: BuildState): state.download_source( 'https://github.com/libsndfile/libsamplerate/releases/download/0.2.1/libsamplerate-0.2.1.tar.bz2', - 'f6323b5e234753579d70a0af27796dde4ebeddf58aae4be598e39b3cee00c90a') + 'f6323b5e234753579d70a0af27796dde4ebeddf58aae4be598e39b3cee00c90a', + patches='samplerate-support-arm64') def detect(self, state: BuildState) -> bool: return os.path.exists(state.source + 'samplerate.pc.in') @@ -259,7 +262,8 @@ class Sdl2MixerTarget(ConfigureMakeStaticDependencyTarget): def prepare_source(self, state: BuildState): state.download_source( 'https://www.libsdl.org/projects/SDL_mixer/release/SDL2_mixer-2.0.4.tar.gz', - 'b4cf5a382c061cd75081cf246c2aa2f9df8db04bdda8dcdc6b6cca55bede2419') + 'b4cf5a382c061cd75081cf246c2aa2f9df8db04bdda8dcdc6b6cca55bede2419', + patches='sdl2_mixer-fix-fluidsynth') def configure(self, state: BuildState): # Set LDFLAGS explicitly to help with FluidSynth and FLAC detection diff --git a/patch/mad.patch b/patch/mad-support-arm64.diff similarity index 100% rename from patch/mad.patch rename to patch/mad-support-arm64.diff diff --git a/patch/ogg.patch b/patch/ogg-fix-compile.diff similarity index 100% rename from patch/ogg.patch rename to patch/ogg-fix-compile.diff diff --git a/patch/portmidi.patch b/patch/portmidi-modernize-cmake.diff similarity index 100% rename from patch/portmidi.patch rename to patch/portmidi-modernize-cmake.diff diff --git a/patch/samplerate.patch b/patch/samplerate-support-arm64.diff similarity index 100% rename from patch/samplerate.patch rename to patch/samplerate-support-arm64.diff diff --git a/patch/sdl2_mixer.patch b/patch/sdl2_mixer-fix-fluidsynth.diff similarity index 100% rename from patch/sdl2_mixer.patch rename to patch/sdl2_mixer-fix-fluidsynth.diff