2021-01-14 08:34:20 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
|
|
|
|
2021-06-28 07:55:35 +00:00
|
|
|
from distutils.version import StrictVersion
|
2021-01-14 08:34:20 +00:00
|
|
|
import os
|
|
|
|
from platform import machine
|
|
|
|
import shutil
|
|
|
|
|
|
|
|
from .base import CMakeTarget, MakeTarget
|
|
|
|
from ..state import BuildState
|
|
|
|
|
|
|
|
|
|
|
|
class MakeMainTarget(MakeTarget):
|
|
|
|
def __init__(self, name=None):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
self.destination = self.DESTINATION_OUTPUT
|
|
|
|
|
|
|
|
|
|
|
|
class CMakeMainTarget(CMakeTarget):
|
|
|
|
def __init__(self, name=None):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
self.destination = self.DESTINATION_OUTPUT
|
|
|
|
self.outputs = (self.name + '.app',)
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
if state.xcode:
|
|
|
|
return
|
|
|
|
|
2021-07-22 06:51:13 +00:00
|
|
|
if state.install_path.exists():
|
2021-01-14 08:34:20 +00:00
|
|
|
shutil.rmtree(state.install_path)
|
|
|
|
|
|
|
|
os.makedirs(state.install_path)
|
|
|
|
|
|
|
|
for output in self.outputs:
|
2021-07-22 06:51:13 +00:00
|
|
|
src = state.build_path / output
|
2021-01-14 08:34:20 +00:00
|
|
|
dst_sep_pos = output.rfind(os.sep)
|
2021-07-22 06:51:13 +00:00
|
|
|
dst = state.install_path / (output if dst_sep_pos == -1 else output[dst_sep_pos + 1:])
|
2021-01-14 08:34:20 +00:00
|
|
|
|
2021-08-04 06:40:31 +00:00
|
|
|
if src.is_dir():
|
|
|
|
shutil.copytree(src, dst)
|
|
|
|
else:
|
|
|
|
shutil.copy(src, dst)
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
def _force_cross_compilation(self, state: BuildState):
|
|
|
|
if state.architecture() == machine():
|
|
|
|
return
|
|
|
|
|
|
|
|
opts = self.options
|
|
|
|
opts['FORCE_CROSSCOMPILE'] = 'YES'
|
2021-07-22 06:51:13 +00:00
|
|
|
opts['IMPORT_EXECUTABLES'] = state.native_build_path / 'ImportExecutables.cmake'
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class ZDoomBaseTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name=None):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
opts = self.options
|
|
|
|
opts['CMAKE_EXE_LINKER_FLAGS'] = state.run_pkg_config('--libs', 'fluidsynth', 'libmpg123')
|
|
|
|
opts['PK3_QUIET_ZIPDIR'] = 'YES'
|
|
|
|
opts['DYN_OPENAL'] = 'NO'
|
|
|
|
# Explicit OpenAL configuration to avoid selection of Apple's framework
|
2021-07-22 06:51:13 +00:00
|
|
|
opts['OPENAL_INCLUDE_DIR'] = state.include_path / 'AL'
|
|
|
|
opts['OPENAL_LIBRARY'] = state.lib_path / 'libopenal.a'
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
self._force_cross_compilation(state)
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
|
2021-04-09 19:06:19 +00:00
|
|
|
class ZDoomVulkanBaseTarget(ZDoomBaseTarget):
|
|
|
|
def __init__(self, name=None):
|
2021-01-14 08:34:20 +00:00
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
# Put MoltenVK library into application bundle
|
|
|
|
molten_lib = 'libMoltenVK.dylib'
|
2021-07-22 06:51:13 +00:00
|
|
|
src_path = state.lib_path / molten_lib
|
2021-01-14 08:34:20 +00:00
|
|
|
dst_path = state.build_path
|
|
|
|
|
|
|
|
if state.xcode:
|
|
|
|
# TODO: Support other configurations
|
2021-07-22 06:51:13 +00:00
|
|
|
dst_path /= 'Debug'
|
2021-01-14 08:34:20 +00:00
|
|
|
|
2021-07-22 06:51:13 +00:00
|
|
|
dst_path /= self.name + '.app/Contents/MacOS'
|
2021-01-14 08:34:20 +00:00
|
|
|
os.makedirs(dst_path, exist_ok=True)
|
|
|
|
|
2021-07-22 06:51:13 +00:00
|
|
|
dst_path /= molten_lib
|
2021-01-14 08:34:20 +00:00
|
|
|
|
2021-07-22 06:51:13 +00:00
|
|
|
if not dst_path.exists():
|
2021-01-14 08:34:20 +00:00
|
|
|
copy_func = state.xcode and os.symlink or shutil.copy
|
|
|
|
copy_func(src_path, dst_path)
|
|
|
|
|
|
|
|
super().post_build(state)
|
|
|
|
|
|
|
|
|
2021-04-09 19:06:19 +00:00
|
|
|
class GZDoomTarget(ZDoomVulkanBaseTarget):
|
|
|
|
def __init__(self, name='gzdoom'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/coelckers/gzdoom.git')
|
|
|
|
|
|
|
|
|
|
|
|
class QZDoomTarget(ZDoomVulkanBaseTarget):
|
2021-01-14 08:34:20 +00:00
|
|
|
def __init__(self, name='qzdoom'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/madame-rachelle/qzdoom.git')
|
|
|
|
|
|
|
|
|
2021-08-01 09:43:57 +00:00
|
|
|
class LZDoomTarget(ZDoomBaseTarget):
|
2021-02-01 08:44:38 +00:00
|
|
|
def __init__(self, name='lzdoom'):
|
|
|
|
super().__init__(name)
|
2021-01-14 08:34:20 +00:00
|
|
|
self.unsupported_architectures = ('arm64',)
|
|
|
|
|
2021-06-28 07:50:35 +00:00
|
|
|
opts = self.options
|
|
|
|
opts['DYN_FLUIDSYNTH'] = 'NO'
|
|
|
|
opts['DYN_MPG123'] = 'NO'
|
|
|
|
opts['DYN_SNDFILE'] = 'NO'
|
|
|
|
|
2021-01-14 08:34:20 +00:00
|
|
|
def prepare_source(self, state: BuildState):
|
2021-02-18 11:21:46 +00:00
|
|
|
state.checkout_git('https://github.com/drfrag666/gzdoom.git', branch='g3.3mgw')
|
2021-01-14 08:34:20 +00:00
|
|
|
|
2021-04-10 11:37:34 +00:00
|
|
|
def detect(self, state: BuildState) -> bool:
|
2021-08-01 09:43:57 +00:00
|
|
|
return state.has_source_file('ico_lzdoom.png')
|
2021-04-10 11:37:34 +00:00
|
|
|
|
2021-01-14 08:34:20 +00:00
|
|
|
|
2021-04-09 19:06:48 +00:00
|
|
|
class RazeTarget(ZDoomVulkanBaseTarget):
|
2021-01-14 08:34:20 +00:00
|
|
|
def __init__(self, name='raze'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/coelckers/Raze.git')
|
|
|
|
|
|
|
|
|
|
|
|
class AccTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='acc'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.outputs = ('acc',)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/rheit/acc.git')
|
|
|
|
|
|
|
|
|
2021-06-28 07:55:35 +00:00
|
|
|
class SladeTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='slade'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
# This should match the actual version of WxWidgets
|
|
|
|
self.os_version['x86_64'] = StrictVersion('10.10')
|
|
|
|
self.sdk_version['x86_64'] = StrictVersion('10.11')
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
# TODO: support both stable and master branches
|
|
|
|
state.checkout_git('https://github.com/sirjuddington/SLADE.git', branch='stable')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
2021-07-22 06:51:13 +00:00
|
|
|
return state.has_source_file('SLADE-osx.icns')
|
2021-06-28 07:55:35 +00:00
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
opts = self.options
|
|
|
|
opts['CMAKE_C_FLAGS'] = opts['CMAKE_CXX_FLAGS'] = '-DNOCURL -I' + state.include_path
|
|
|
|
opts['CMAKE_EXE_LINKER_FLAGS'] = \
|
|
|
|
state.run_pkg_config('--libs', 'fluidsynth', 'libtiff-4', 'openal', 'vorbisfile')
|
|
|
|
opts['wxWidgets_USE_STATIC'] = 'YES'
|
|
|
|
opts['WX_GTK3'] = 'NO'
|
|
|
|
opts['SFML_STATIC'] = 'YES'
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
|
2021-01-14 08:34:20 +00:00
|
|
|
class PrBoomPlusTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='prboom-plus'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.src_root = 'prboom2'
|
|
|
|
self.outputs = ('Launcher.app',)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/coelckers/prboom-plus.git')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
opts = self.options
|
|
|
|
opts['CMAKE_C_FLAGS'] = '-D_FILE_OFFSET_BITS=64'
|
|
|
|
opts['CMAKE_EXE_LINKER_FLAGS'] = state.run_pkg_config('--libs', 'SDL2_mixer', 'SDL2_image')
|
|
|
|
opts['CMAKE_POLICY_DEFAULT_CMP0056'] = 'NEW'
|
|
|
|
|
|
|
|
self._force_cross_compilation(state)
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
|
2021-03-10 08:41:10 +00:00
|
|
|
class DsdaDoom(PrBoomPlusTarget):
|
|
|
|
def __init__(self, name='dsda-doom'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/kraflab/dsda-doom.git')
|
|
|
|
|
|
|
|
|
2021-01-14 08:34:20 +00:00
|
|
|
class ChocolateDoomBaseTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name=None):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
self.options['CMAKE_EXE_LINKER_FLAGS'] = state.run_pkg_config('--libs', 'SDL2_mixer')
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
def _fill_outputs(self, exe_prefix: str):
|
|
|
|
self.outputs = (
|
|
|
|
f'src/{exe_prefix}-doom',
|
|
|
|
f'src/{exe_prefix}-heretic',
|
|
|
|
f'src/{exe_prefix}-hexen',
|
|
|
|
f'src/{exe_prefix}-server',
|
|
|
|
f'src/{exe_prefix}-setup',
|
|
|
|
f'src/{exe_prefix}-strife',
|
2021-08-04 06:39:51 +00:00
|
|
|
'src/midiread',
|
|
|
|
'src/mus2mid',
|
2021-01-14 08:34:20 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
class ChocolateDoomTarget(ChocolateDoomBaseTarget):
|
|
|
|
def __init__(self, name='chocolate-doom'):
|
|
|
|
super().__init__(name)
|
|
|
|
self._fill_outputs('chocolate')
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/chocolate-doom/chocolate-doom.git')
|
|
|
|
|
|
|
|
|
|
|
|
class CrispyDoomTarget(ChocolateDoomBaseTarget):
|
|
|
|
def __init__(self, name='crispy-doom'):
|
|
|
|
super().__init__(name)
|
|
|
|
self._fill_outputs('crispy')
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/fabiangreffrath/crispy-doom.git')
|
|
|
|
|
|
|
|
|
|
|
|
class RudeTarget(ChocolateDoomBaseTarget):
|
|
|
|
def __init__(self, name='rude'):
|
|
|
|
super().__init__(name)
|
|
|
|
self._fill_outputs('rude')
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/drfrag666/RUDE.git')
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
super().post_build(state)
|
2021-01-17 10:37:35 +00:00
|
|
|
shutil.copy(state.source + '/data/rude.wad', state.install_path)
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class WoofTarget(ChocolateDoomBaseTarget):
|
|
|
|
def __init__(self, name='woof'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.outputs = ('Source/woof',)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/fabiangreffrath/woof.git')
|
|
|
|
|
|
|
|
|
|
|
|
class DoomRetroTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='doomretro'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/bradharding/doomretro.git')
|
|
|
|
|
|
|
|
|
|
|
|
class Doom64EXTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='doom64ex'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/svkaiser/Doom64EX.git')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
opts = self.options
|
|
|
|
opts['ENABLE_SYSTEM_FLUIDSYNTH'] = 'YES'
|
|
|
|
opts['CMAKE_EXE_LINKER_FLAGS'] = state.run_pkg_config('--libs', 'SDL2', 'fluidsynth')
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
|
|
|
|
class DevilutionXTarget(CMakeMainTarget):
|
|
|
|
def __init__(self, name='devilutionx'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/diasurgical/devilutionX.git')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
self.options['CMAKE_EXE_LINKER_FLAGS'] = state.run_pkg_config('--libs', 'SDL2_mixer', 'SDL2_ttf')
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
2021-06-05 09:59:37 +00:00
|
|
|
# Remove version file that is included erroneously because of case-insensitive file system
|
2021-07-22 06:51:13 +00:00
|
|
|
version_file = state.build_path / '_deps/libzt-src/ext/ZeroTierOne/ext/miniupnpc/VERSION'
|
|
|
|
version_file.unlink(missing_ok=True)
|
2021-06-05 09:59:37 +00:00
|
|
|
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
class EDuke32Target(MakeMainTarget):
|
|
|
|
def __init__(self, name='eduke32'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://voidpoint.io/terminx/eduke32.git')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
def has_bundle(name: str) -> bool:
|
2021-08-04 06:39:51 +00:00
|
|
|
probe_path = state.source / f'platform/Apple/bundles/{name}.app'
|
2021-07-22 06:51:13 +00:00
|
|
|
return probe_path.exists()
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
return has_bundle('EDuke32') and not has_bundle('NBlood')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
# Fix missing definition when building with SDK older than 10.12
|
2021-08-05 06:53:07 +00:00
|
|
|
state.update_environment('CXXFLAGS', '-DCLOCK_MONOTONIC=0')
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class NBloodTarget(EDuke32Target):
|
|
|
|
def __init__(self, name='nblood'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.tool = 'gmake'
|
|
|
|
|
|
|
|
for target in ('duke3d', 'sw', 'blood', 'rr', 'exhumed', 'tools'):
|
|
|
|
self.options[target] = None
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://github.com/nukeykt/NBlood.git')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
2021-07-22 06:51:13 +00:00
|
|
|
return state.has_source_file('nblood.pk3')
|
2021-01-14 08:34:20 +00:00
|
|
|
|
|
|
|
|
|
|
|
class QuakespasmTarget(MakeMainTarget):
|
|
|
|
def __init__(self, name='quakespasm'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
self.src_root = 'Quake'
|
|
|
|
|
|
|
|
# TODO: Use macOS specific Makefile which requires manual application bundle creation
|
|
|
|
opts = self.options
|
|
|
|
opts['USE_SDL2'] = '1'
|
|
|
|
opts['USE_CODEC_FLAC'] = '1'
|
|
|
|
opts['USE_CODEC_OPUS'] = '1'
|
|
|
|
opts['USE_CODEC_MIKMOD'] = '1'
|
|
|
|
opts['USE_CODEC_UMX'] = '1'
|
|
|
|
# Add main() alias to workaround executable linking without macOS launcher
|
|
|
|
opts['COMMON_LIBS'] = '-framework OpenGL -Wl,-alias -Wl,_SDL_main -Wl,_main'
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.checkout_git('https://git.code.sf.net/p/quakespasm/quakespasm')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
2021-07-22 06:51:13 +00:00
|
|
|
return state.has_source_file('Quakespasm.txt')
|