aedi: split dependency module

fix #30
This commit is contained in:
alexey.lysiuk 2021-05-01 11:54:52 +03:00
parent 5f1fc05fe2
commit d2bf8673d9
5 changed files with 533 additions and 490 deletions

View file

@ -16,9 +16,11 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from .dependency import *
from .library_tier1 import *
from .library_tier2 import *
from .main import *
from .special import *
from .tools import *
def targets():
@ -42,33 +44,35 @@ def targets():
NBloodTarget(),
QuakespasmTarget(),
# Dependencies
# Libraries needed for GZDoom and Raze
Bzip2Target(),
DumbTarget(),
FfiTarget(),
FlacTarget(),
FluidSynthTarget(),
FreeTypeTarget(),
GlibTarget(),
GmakeTarget(),
IconvTarget(),
InstPatchTarget(),
IntlTarget(),
JpegTurboTarget(),
MadTarget(),
MesonTarget(),
MikmodTarget(),
ModPlugTarget(),
MoltenVKTarget(),
Mpg123Target(),
NasmTarget(),
NinjaTarget(),
OggTarget(),
OpenALTarget(),
OpusTarget(),
OpusFileTarget(),
PcreTarget(),
PkgConfigTarget(),
SndFileTarget(),
VorbisTarget(),
VpxTarget(),
ZlibNgTarget(),
ZMusicTarget(),
# Libraries needed for other targets
DumbTarget(),
FreeTypeTarget(),
MadTarget(),
MikmodTarget(),
ModPlugTarget(),
OpusFileTarget(),
PngTarget(),
PortMidiTarget(),
SamplerateTarget(),
@ -77,14 +81,16 @@ def targets():
Sdl2MixerTarget(),
Sdl2NetTarget(),
Sdl2TtfTarget(),
SndFileTarget(),
SodiumTarget(),
VorbisTarget(),
VpxTarget(),
WebpTarget(),
# Tools
GmakeTarget(),
MesonTarget(),
NasmTarget(),
NinjaTarget(),
PkgConfigTarget(),
YasmTarget(),
ZlibNgTarget(),
ZMusicTarget(),
# Special
CleanAllTarget(),

View file

@ -413,3 +413,32 @@ class CMakeTarget(BuildTarget):
args.append('VERBOSE=1')
subprocess.check_call(args, cwd=state.build_path, env=self.environment)
class ConfigureMakeDependencyTarget(ConfigureMakeTarget):
def __init__(self, name=None):
super().__init__(name)
def post_build(self, state: BuildState):
self.install(state)
class ConfigureMakeStaticDependencyTarget(ConfigureMakeDependencyTarget):
def __init__(self, name=None):
super().__init__(name)
self.options['--enable-shared'] = 'no'
class CMakeStaticDependencyTarget(CMakeTarget):
def __init__(self, name=None):
super().__init__(name)
# Set commonly used variables for static libraries
opts = self.options
opts['BUILD_SHARED_LIBS'] = 'NO'
opts['ENABLE_SHARED'] = 'NO'
opts['LIBTYPE'] = 'STATIC'
def post_build(self, state: BuildState):
self.install(state)

View file

@ -16,44 +16,10 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import os
import shutil
import subprocess
import zipapp
from .base import BuildTarget, MakeTarget, ConfigureMakeTarget, CMakeTarget
from .base import *
from ..state import BuildState
class ConfigureMakeDependencyTarget(ConfigureMakeTarget):
def __init__(self, name=None):
super().__init__(name)
def post_build(self, state: BuildState):
self.install(state)
class ConfigureMakeStaticDependencyTarget(ConfigureMakeDependencyTarget):
def __init__(self, name=None):
super().__init__(name)
self.options['--enable-shared'] = 'no'
class CMakeStaticDependencyTarget(CMakeTarget):
def __init__(self, name=None):
super().__init__(name)
# Set commonly used variables for static libraries
opts = self.options
opts['BUILD_SHARED_LIBS'] = 'NO'
opts['ENABLE_SHARED'] = 'NO'
opts['LIBTYPE'] = 'STATIC'
def post_build(self, state: BuildState):
self.install(state)
class Bzip2Target(MakeTarget):
def __init__(self, name='bzip2'):
super().__init__(name)
@ -84,34 +50,6 @@ class Bzip2Target(MakeTarget):
self.write_pc_file(state, description='bzip2 compression library', version='1.0.8', libs='-lbz2')
class DumbTarget(CMakeStaticDependencyTarget):
def __init__(self, name='dumb'):
super().__init__(name)
opts = self.options
opts['BUILD_ALLEGRO4'] = 'NO'
opts['BUILD_EXAMPLES'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/kode54/dumb/archive/2.0.3.tar.gz',
'99bfac926aeb8d476562303312d9f47fd05b43803050cd889b44da34a9b2a4f9')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'include/dumb.h')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
if line.startswith('libdir='):
return 'libdir=${exec_prefix}/lib\n'
elif line.startswith('includedir='):
return 'includedir=${prefix}/include\n'
elif line.startswith('Libs:'):
return 'Libs: -L${libdir} -ldumb\n'
return line
class FfiTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='ffi'):
super().__init__(name)
@ -180,19 +118,6 @@ class FluidSynthTarget(CMakeStaticDependencyTarget):
return line
class FreeTypeTarget(CMakeStaticDependencyTarget):
def __init__(self, name='freetype'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/freetype/freetype2/2.10.4/freetype-2.10.4.tar.xz',
'86a854d8905b19698bbc8f23b860bc104246ce4854dcea8e3b0fb21284f75784')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'include/freetype/freetype.h')
class GettextTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='gettext'):
super().__init__(name)
@ -268,22 +193,6 @@ endian = 'little'
self.install(state, tool='ninja')
class GmakeTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='gmake'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://ftp.gnu.org/gnu/make/make-4.3.tar.lz',
'de1a441c4edf952521db30bfca80baae86a0ff1acd0a00402999344f04c45e82')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'doc/make.1')
def post_build(self, state: BuildState):
self.copy_to_bin(state, 'make', self.name)
class IconvTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='iconv'):
super().__init__(name)
@ -352,92 +261,6 @@ class JpegTurboTarget(CMakeStaticDependencyTarget):
return line
class MadTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='mad'):
super().__init__(name)
self.options['--enable-fpm'] = '64bit'
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')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'mad.h')
def post_build(self, state: BuildState):
super().post_build(state)
self.write_pc_file(state, description='MPEG Audio Decoder', version='0.15.1b')
class MesonTarget(BuildTarget):
def __init__(self, name='meson'):
super().__init__(name)
self.multi_platform = False
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/mesonbuild/meson/releases/download/0.56.0/meson-0.56.0.tar.gz',
'291dd38ff1cd55fcfca8fc985181dd39be0d3e5826e5f0013bf867be40117213')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'meson.py')
def post_build(self, state: BuildState):
script = '__main__.py'
shutil.copy(state.source + script, state.build_path)
module = 'mesonbuild'
module_path = state.build_path + module
if os.path.exists(module_path):
shutil.rmtree(module_path)
shutil.copytree(state.source + module, module_path)
dest_path = state.install_path + 'bin' + os.sep
os.makedirs(dest_path, exist_ok=True)
zipapp.create_archive(state.build_path, dest_path + self.name, '/usr/bin/env python3', compressed=True)
class MikmodTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='mikmod'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/mikmod/libmikmod/3.3.11.1/libmikmod-3.3.11.1.tar.gz',
'ad9d64dfc8f83684876419ea7cd4ff4a41d8bcd8c23ef37ecb3a200a16b46d19')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libmikmod.pc.in')
def post_build(self, state: BuildState):
super().post_build(state)
self.update_prefix_shell_script(state.install_path + '/bin/libmikmod-config')
class ModPlugTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='modplug'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/modplug-xmms/libmodplug/0.8.9.0/libmodplug-0.8.9.0.tar.gz',
'457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libmodplug.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
libs_private = 'Libs.private:'
if line.startswith(libs_private):
return libs_private + ' -lc++\n'
return line
class MoltenVKTarget(MakeTarget):
def __init__(self, name='moltenvk'):
super().__init__(name)
@ -495,44 +318,6 @@ class Mpg123Target(ConfigureMakeStaticDependencyTarget):
return os.path.exists(state.source + 'libmpg123.pc.in')
class NasmTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='nasm'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz',
'3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'nasm.txt')
class NinjaTarget(MakeTarget):
def __init__(self, name='ninja'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/ninja-build/ninja/archive/v1.10.2.tar.gz',
'ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'src/ninja.cc')
def build(self, state: BuildState):
cmdlines = (
('python3', './configure.py', '--verbose'),
('ninja', '--verbose'),
)
for args in cmdlines:
subprocess.run(args, check=True, cwd=state.build_path, env=self.environment)
def post_build(self, state: BuildState):
self.copy_to_bin(state)
class OggTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='ogg'):
super().__init__(name)
@ -588,20 +373,6 @@ class OpusTarget(ConfigureMakeStaticDependencyTarget):
return os.path.exists(state.source + 'opus.pc.in')
class OpusFileTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='opusfile'):
super().__init__(name)
self.options['--enable-http'] = 'no'
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.xiph.org/releases/opus/opusfile-0.12.tar.gz',
'118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'opusfile.pc.in')
class PcreTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='pcre'):
super().__init__(name)
@ -619,198 +390,6 @@ class PcreTarget(ConfigureMakeStaticDependencyTarget):
return os.path.exists(state.source + 'pcre.h.in')
class PkgConfigTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='pkg-config'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz',
'6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'pkg-config.1')
def post_build(self, state: BuildState):
self.copy_to_bin(state, new_filename=self.name + '.exe')
class PngTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='png'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz',
'505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libpng.pc.in')
def post_build(self, state: BuildState):
super().post_build(state)
self.update_prefix_shell_script(state.install_path + '/bin/libpng16-config')
class PortMidiTarget(CMakeTarget):
def __init__(self, name='portmidi'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/portmedia/portmidi/217/portmidi-src-217.zip',
'08e9a892bd80bdb1115213fb72dc29a7bf2ff108b378180586aa65f3cfd42e0f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'pm_common/portmidi.h')
def post_build(self, state: BuildState):
if os.path.exists(state.install_path):
shutil.rmtree(state.install_path)
include_path = state.install_path + os.sep + 'include'
os.makedirs(include_path)
shutil.copy(state.source + 'pm_common/portmidi.h', include_path)
shutil.copy(state.source + 'porttime/porttime.h', include_path)
lib_path = state.install_path + os.sep + 'lib' + os.sep
os.makedirs(lib_path)
shutil.copy(state.build_path + 'libportmidi_s.a', lib_path + 'libportmidi.a')
class SamplerateTarget(CMakeStaticDependencyTarget):
def __init__(self, name='samplerate'):
super().__init__(name)
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')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'samplerate.pc.in')
class Sdl2Target(CMakeStaticDependencyTarget):
def __init__(self, name='sdl2'):
super().__init__(name)
# Need to have uniform settings for x86_64 and arm64 because of linking with Metal framework
# TODO: Remove this when default target for x64 will become 10.11+
opts = self.options
opts['VIDEO_VULKAN'] = 'NO'
opts['VIDEO_METAL'] = 'NO'
opts['RENDER_METAL'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://libsdl.org/release/SDL2-2.0.14.tar.gz',
'd8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'sdl2.pc.in')
LINKER_FLAGS = ' -L${libdir} -lSDL2'\
' -framework AudioToolbox -framework AVFoundation -framework Carbon -framework Cocoa'\
' -framework CoreAudio -framework CoreFoundation -framework CoreVideo'\
' -framework ForceFeedback -framework Foundation -framework IOKit\n'
def post_build(self, state: BuildState):
super().post_build(state)
def update_libs(line: str):
if line.startswith(' echo -L${exec_prefix}/lib'):
return ' echo' + Sdl2Target.LINKER_FLAGS
return line
self.update_prefix_shell_script(state.install_path + '/bin/sdl2-config', update_libs)
self.make_platform_header(state, 'SDL2/SDL_config.h')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
libs = 'Libs:'
if line.startswith(libs):
return libs + Sdl2Target.LINKER_FLAGS
return line
class Sdl2ImageTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_image'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz',
'bdd5f6e026682f7d7e1be0b6051b209da2f402a2dd8bd1c4bd9c25ad263108d0')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_image.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
return line + 'Requires.private: libwebp\n' if line.startswith('Requires:') else line
class Sdl2MixerTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_mixer'):
super().__init__(name)
self.options['--enable-music-mod-mikmod'] = 'yes'
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')
def configure(self, state: BuildState):
# Set LDFLAGS explicitly to help with FluidSynth and FLAC detection
self.environment['LDFLAGS'] = state.run_pkg_config('--libs', 'fluidsynth')
super().configure(state)
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_mixer.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
if line.startswith('Requires:'):
return line + 'Requires.private: fluidsynth libmikmod libmodplug libmpg123 opusfile vorbisfile\n'
return line
class Sdl2NetTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_net'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz',
'15ce8a7e5a23dafe8177c8df6e6c79b6749a03fff1e8196742d3571657609d21')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_net.pc.in')
class Sdl2TtfTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_ttf'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz',
'a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_ttf.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
return line + 'Requires.private: freetype2\n' if line.startswith('Requires:') else line
class SndFileTarget(CMakeStaticDependencyTarget):
def __init__(self, name='sndfile'):
super().__init__(name)
@ -828,19 +407,6 @@ class SndFileTarget(CMakeStaticDependencyTarget):
return os.path.exists(state.source + 'sndfile.pc.in')
class SodiumTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sodium'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz',
'6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libsodium.pc.in')
class VorbisTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='vorbis'):
super().__init__(name)
@ -880,43 +446,6 @@ class VpxTarget(ConfigureMakeDependencyTarget):
return os.path.exists(state.source + 'vpxstats.h')
class WebpTarget(CMakeStaticDependencyTarget):
def __init__(self, name='webp'):
super().__init__(name)
opts = self.options
opts['WEBP_BUILD_ANIM_UTILS'] = 'NO'
opts['WEBP_BUILD_CWEBP'] = 'NO'
opts['WEBP_BUILD_DWEBP'] = 'NO'
opts['WEBP_BUILD_GIF2WEBP'] = 'NO'
opts['WEBP_BUILD_IMG2WEBP'] = 'NO'
opts['WEBP_BUILD_VWEBP'] = 'NO'
opts['WEBP_BUILD_WEBPINFO'] = 'NO'
opts['WEBP_BUILD_WEBPMUX'] = 'NO'
opts['WEBP_BUILD_EXTRAS'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz',
'98a052268cc4d5ece27f76572a7f50293f439c17a98e67c4ea0c7ed6f50ef043')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'src/libwebp.pc.in')
class YasmTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='yasm'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz',
'3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libyasm.h')
class ZlibNgTarget(CMakeStaticDependencyTarget):
def __init__(self, name='zlib-ng'):
super().__init__(name)

View file

@ -0,0 +1,345 @@
#
# Helper module to build macOS version of various source ports
# Copyright (C) 2020-2021 Alexey Lysiuk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
from .base import *
from ..state import BuildState
class DumbTarget(CMakeStaticDependencyTarget):
def __init__(self, name='dumb'):
super().__init__(name)
opts = self.options
opts['BUILD_ALLEGRO4'] = 'NO'
opts['BUILD_EXAMPLES'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/kode54/dumb/archive/2.0.3.tar.gz',
'99bfac926aeb8d476562303312d9f47fd05b43803050cd889b44da34a9b2a4f9')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'include/dumb.h')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
if line.startswith('libdir='):
return 'libdir=${exec_prefix}/lib\n'
elif line.startswith('includedir='):
return 'includedir=${prefix}/include\n'
elif line.startswith('Libs:'):
return 'Libs: -L${libdir} -ldumb\n'
return line
class FreeTypeTarget(CMakeStaticDependencyTarget):
def __init__(self, name='freetype'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/freetype/freetype2/2.10.4/freetype-2.10.4.tar.xz',
'86a854d8905b19698bbc8f23b860bc104246ce4854dcea8e3b0fb21284f75784')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'include/freetype/freetype.h')
class MadTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='mad'):
super().__init__(name)
self.options['--enable-fpm'] = '64bit'
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')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'mad.h')
def post_build(self, state: BuildState):
super().post_build(state)
self.write_pc_file(state, description='MPEG Audio Decoder', version='0.15.1b')
class MikmodTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='mikmod'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/mikmod/libmikmod/3.3.11.1/libmikmod-3.3.11.1.tar.gz',
'ad9d64dfc8f83684876419ea7cd4ff4a41d8bcd8c23ef37ecb3a200a16b46d19')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libmikmod.pc.in')
def post_build(self, state: BuildState):
super().post_build(state)
self.update_prefix_shell_script(state.install_path + '/bin/libmikmod-config')
class ModPlugTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='modplug'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/modplug-xmms/libmodplug/0.8.9.0/libmodplug-0.8.9.0.tar.gz',
'457ca5a6c179656d66c01505c0d95fafaead4329b9dbaa0f997d00a3508ad9de')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libmodplug.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
libs_private = 'Libs.private:'
if line.startswith(libs_private):
return libs_private + ' -lc++\n'
return line
class OpusFileTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='opusfile'):
super().__init__(name)
self.options['--enable-http'] = 'no'
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.xiph.org/releases/opus/opusfile-0.12.tar.gz',
'118d8601c12dd6a44f52423e68ca9083cc9f2bfe72da7a8c1acb22a80ae3550b')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'opusfile.pc.in')
class PngTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='png'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/libpng/libpng-1.6.37.tar.xz',
'505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libpng.pc.in')
def post_build(self, state: BuildState):
super().post_build(state)
self.update_prefix_shell_script(state.install_path + '/bin/libpng16-config')
class PortMidiTarget(CMakeTarget):
def __init__(self, name='portmidi'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://downloads.sourceforge.net/project/portmedia/portmidi/217/portmidi-src-217.zip',
'08e9a892bd80bdb1115213fb72dc29a7bf2ff108b378180586aa65f3cfd42e0f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'pm_common/portmidi.h')
def post_build(self, state: BuildState):
if os.path.exists(state.install_path):
shutil.rmtree(state.install_path)
include_path = state.install_path + os.sep + 'include'
os.makedirs(include_path)
shutil.copy(state.source + 'pm_common/portmidi.h', include_path)
shutil.copy(state.source + 'porttime/porttime.h', include_path)
lib_path = state.install_path + os.sep + 'lib' + os.sep
os.makedirs(lib_path)
shutil.copy(state.build_path + 'libportmidi_s.a', lib_path + 'libportmidi.a')
class SamplerateTarget(CMakeStaticDependencyTarget):
def __init__(self, name='samplerate'):
super().__init__(name)
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')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'samplerate.pc.in')
class Sdl2Target(CMakeStaticDependencyTarget):
def __init__(self, name='sdl2'):
super().__init__(name)
# Need to have uniform settings for x86_64 and arm64 because of linking with Metal framework
# TODO: Remove this when default target for x64 will become 10.11+
opts = self.options
opts['VIDEO_VULKAN'] = 'NO'
opts['VIDEO_METAL'] = 'NO'
opts['RENDER_METAL'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://libsdl.org/release/SDL2-2.0.14.tar.gz',
'd8215b571a581be1332d2106f8036fcb03d12a70bae01e20f424976d275432bc')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'sdl2.pc.in')
LINKER_FLAGS = ' -L${libdir} -lSDL2'\
' -framework AudioToolbox -framework AVFoundation -framework Carbon -framework Cocoa'\
' -framework CoreAudio -framework CoreFoundation -framework CoreVideo'\
' -framework ForceFeedback -framework Foundation -framework IOKit\n'
def post_build(self, state: BuildState):
super().post_build(state)
def update_libs(line: str):
if line.startswith(' echo -L${exec_prefix}/lib'):
return ' echo' + Sdl2Target.LINKER_FLAGS
return line
self.update_prefix_shell_script(state.install_path + '/bin/sdl2-config', update_libs)
self.make_platform_header(state, 'SDL2/SDL_config.h')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
libs = 'Libs:'
if line.startswith(libs):
return libs + Sdl2Target.LINKER_FLAGS
return line
class Sdl2ImageTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_image'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_image/release/SDL2_image-2.0.5.tar.gz',
'bdd5f6e026682f7d7e1be0b6051b209da2f402a2dd8bd1c4bd9c25ad263108d0')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_image.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
return line + 'Requires.private: libwebp\n' if line.startswith('Requires:') else line
class Sdl2MixerTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_mixer'):
super().__init__(name)
self.options['--enable-music-mod-mikmod'] = 'yes'
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')
def configure(self, state: BuildState):
# Set LDFLAGS explicitly to help with FluidSynth and FLAC detection
self.environment['LDFLAGS'] = state.run_pkg_config('--libs', 'fluidsynth')
super().configure(state)
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_mixer.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
if line.startswith('Requires:'):
return line + 'Requires.private: fluidsynth libmikmod libmodplug libmpg123 opusfile vorbisfile\n'
return line
class Sdl2NetTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_net'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_net/release/SDL2_net-2.0.1.tar.gz',
'15ce8a7e5a23dafe8177c8df6e6c79b6749a03fff1e8196742d3571657609d21')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_net.pc.in')
class Sdl2TtfTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sdl2_ttf'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.libsdl.org/projects/SDL_ttf/release/SDL2_ttf-2.0.15.tar.gz',
'a9eceb1ad88c1f1545cd7bd28e7cbc0b2c14191d40238f531a15b01b1b22cd33')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'SDL2_ttf.pc.in')
@staticmethod
def _process_pkg_config(pcfile: str, line: str) -> str:
return line + 'Requires.private: freetype2\n' if line.startswith('Requires:') else line
class SodiumTarget(ConfigureMakeStaticDependencyTarget):
def __init__(self, name='sodium'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://download.libsodium.org/libsodium/releases/libsodium-1.0.18.tar.gz',
'6f504490b342a4f8a4c4a02fc9b866cbef8622d5df4e5452b46be121e46636c1')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libsodium.pc.in')
class WebpTarget(CMakeStaticDependencyTarget):
def __init__(self, name='webp'):
super().__init__(name)
opts = self.options
opts['WEBP_BUILD_ANIM_UTILS'] = 'NO'
opts['WEBP_BUILD_CWEBP'] = 'NO'
opts['WEBP_BUILD_DWEBP'] = 'NO'
opts['WEBP_BUILD_GIF2WEBP'] = 'NO'
opts['WEBP_BUILD_IMG2WEBP'] = 'NO'
opts['WEBP_BUILD_VWEBP'] = 'NO'
opts['WEBP_BUILD_WEBPINFO'] = 'NO'
opts['WEBP_BUILD_WEBPMUX'] = 'NO'
opts['WEBP_BUILD_EXTRAS'] = 'NO'
def prepare_source(self, state: BuildState):
state.download_source(
'https://storage.googleapis.com/downloads.webmproject.org/releases/webp/libwebp-1.1.0.tar.gz',
'98a052268cc4d5ece27f76572a7f50293f439c17a98e67c4ea0c7ed6f50ef043')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'src/libwebp.pc.in')

134
aedi/target/tools.py Normal file
View file

@ -0,0 +1,134 @@
#
# Helper module to build macOS version of various source ports
# Copyright (C) 2020-2021 Alexey Lysiuk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
import zipapp
from .base import *
from ..state import BuildState
class GmakeTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='gmake'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://ftp.gnu.org/gnu/make/make-4.3.tar.lz',
'de1a441c4edf952521db30bfca80baae86a0ff1acd0a00402999344f04c45e82')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'doc/make.1')
def post_build(self, state: BuildState):
self.copy_to_bin(state, 'make', self.name)
class MesonTarget(BuildTarget):
def __init__(self, name='meson'):
super().__init__(name)
self.multi_platform = False
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/mesonbuild/meson/releases/download/0.56.0/meson-0.56.0.tar.gz',
'291dd38ff1cd55fcfca8fc985181dd39be0d3e5826e5f0013bf867be40117213')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'meson.py')
def post_build(self, state: BuildState):
script = '__main__.py'
shutil.copy(state.source + script, state.build_path)
module = 'mesonbuild'
module_path = state.build_path + module
if os.path.exists(module_path):
shutil.rmtree(module_path)
shutil.copytree(state.source + module, module_path)
dest_path = state.install_path + 'bin' + os.sep
os.makedirs(dest_path, exist_ok=True)
zipapp.create_archive(state.build_path, dest_path + self.name, '/usr/bin/env python3', compressed=True)
class NasmTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='nasm'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/nasm-2.15.05.tar.xz',
'3caf6729c1073bf96629b57cee31eeb54f4f8129b01902c73428836550b30a3f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'nasm.txt')
class NinjaTarget(MakeTarget):
def __init__(self, name='ninja'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://github.com/ninja-build/ninja/archive/v1.10.2.tar.gz',
'ce35865411f0490368a8fc383f29071de6690cbadc27704734978221f25e2bed')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'src/ninja.cc')
def build(self, state: BuildState):
cmdlines = (
('python3', './configure.py', '--verbose'),
('ninja', '--verbose'),
)
for args in cmdlines:
subprocess.run(args, check=True, cwd=state.build_path, env=self.environment)
def post_build(self, state: BuildState):
self.copy_to_bin(state)
class PkgConfigTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='pkg-config'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://pkg-config.freedesktop.org/releases/pkg-config-0.29.2.tar.gz',
'6fc69c01688c9458a57eb9a1664c9aba372ccda420a02bf4429fe610e7e7d591')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'pkg-config.1')
def post_build(self, state: BuildState):
self.copy_to_bin(state, new_filename=self.name + '.exe')
class YasmTarget(ConfigureMakeDependencyTarget):
def __init__(self, name='yasm'):
super().__init__(name)
def prepare_source(self, state: BuildState):
state.download_source(
'https://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz',
'3dce6601b495f5b3d45b59f7d2492a340ee7e84b5beca17e48f862502bd5603f')
def detect(self, state: BuildState) -> bool:
return os.path.exists(state.source + 'libyasm.h')