2022-09-23 10:44:07 +00:00
|
|
|
#
|
|
|
|
# Helper module to build macOS version of various source ports
|
2023-01-01 08:46:34 +00:00
|
|
|
# Copyright (C) 2020-2023 Alexey Lysiuk
|
2022-09-23 10:44:07 +00:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
#
|
2022-09-23 11:55:40 +00:00
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
import subprocess
|
2022-09-23 11:55:40 +00:00
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
from ..state import BuildState
|
2023-03-20 11:26:13 +00:00
|
|
|
from . import base
|
2023-03-20 10:39:37 +00:00
|
|
|
|
|
|
|
|
|
|
|
class GlslangTarget(base.CMakeStaticDependencyTarget):
|
2023-01-09 14:04:03 +00:00
|
|
|
def __init__(self, name='glslang'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
2023-03-24 11:23:30 +00:00
|
|
|
'https://github.com/KhronosGroup/glslang/archive/refs/tags/12.1.0.tar.gz',
|
|
|
|
'1515e840881d1128fb6d831308433f731808f818f2103881162f3ffd47b15cd5')
|
2023-01-09 14:04:03 +00:00
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
args = ('python3', 'update_glslang_sources.py')
|
|
|
|
subprocess.run(args, check=True, cwd=state.source, env=state.environment)
|
|
|
|
|
|
|
|
state.options['ENABLE_CTEST'] = 'NO'
|
|
|
|
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class P7ZipTarget(base.CMakeTarget):
|
2022-09-24 07:07:21 +00:00
|
|
|
def __init__(self, name='p7zip'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.src_root = 'CPP/7zip/CMAKE/7za'
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
2023-02-20 08:56:25 +00:00
|
|
|
'https://github.com/p7zip-project/p7zip/archive/refs/tags/v17.04.tar.gz',
|
2022-09-24 07:07:21 +00:00
|
|
|
'ea029a2e21d2d6ad0a156f6679bd66836204aa78148a4c5e498fe682e77127ef')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('CPP/7zip/CMAKE/CMakeLists.txt') \
|
|
|
|
and state.has_source_file('C/fast-lzma2/fast-lzma2.h')
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
self.copy_to_bin(state, '7za')
|
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class PbzxTarget(base.SingleExeCTarget):
|
2022-09-23 11:58:01 +00:00
|
|
|
def __init__(self, name='pbzx'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.options = ('pbzx.c', '-lxar', '-llzma')
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://github.com/nrosenstein-stuff/pbzx/archive/refs/tags/v1.0.2.tar.gz',
|
|
|
|
'33db3cf9dc70ae704e1bbfba52c984f4c6dbfd0cc4449fa16408910e22b4fd90',
|
|
|
|
'pbzx-xar-content')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('pbzx.c')
|
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class QPakManTarget(base.CMakeTarget):
|
2023-02-20 09:50:28 +00:00
|
|
|
def __init__(self, name='qpakman'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://github.com/bunder/qpakman/archive/refs/tags/v0.67.tar.gz',
|
|
|
|
'0b2cfc0e66a6ea3f0e332409254e06f78f5bb9b47f6b134b90681468d701d421')
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
self.copy_to_bin(state)
|
|
|
|
|
|
|
|
|
2023-03-20 11:52:21 +00:00
|
|
|
class Radare2Target(base.MesonTarget):
|
|
|
|
def __init__(self, name='radare2'):
|
|
|
|
super().__init__(name)
|
2023-03-25 10:54:50 +00:00
|
|
|
self.configure_prefix = False
|
2023-03-20 11:52:21 +00:00
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://github.com/radareorg/radare2/archive/refs/tags/5.8.4.tar.gz',
|
|
|
|
'8ea45bd82e5ea37e270ca14ac2a6f947c647a24f9de9e18bf8cebc71c0816dcd')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('man/radare2.1')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
2023-03-25 10:54:50 +00:00
|
|
|
option = state.options
|
|
|
|
option['blob'] = 'true'
|
|
|
|
option['r2_gittip'] = 'ab809417aa6b676922f95cf77861924eb90e7ef2'
|
|
|
|
option['r2_version_commit'] = '1'
|
2023-03-20 13:33:41 +00:00
|
|
|
|
2023-03-25 10:54:50 +00:00
|
|
|
super().configure(state)
|
2023-03-20 13:13:00 +00:00
|
|
|
|
2023-03-25 10:54:50 +00:00
|
|
|
# # Fix absolute paths in r_userconf.h
|
|
|
|
# search_subpath = str(state.install_path)
|
|
|
|
# replace_subpath = '/usr/local'
|
|
|
|
#
|
|
|
|
# def fix_paths(line: str):
|
|
|
|
# return line.replace(search_subpath, replace_subpath) if search_subpath in line else line
|
|
|
|
#
|
|
|
|
# self.update_text_file(state.build_path / 'r_userconf.h', fix_paths)
|
|
|
|
#
|
|
|
|
# # Fix commit in r_version.h
|
|
|
|
# names_values = (
|
|
|
|
# ('R2_GITTIP', '"ab809417aa6b676922f95cf77861924eb90e7ef2"'),
|
|
|
|
# ('R2_VERSION_COMMIT', '1'),
|
|
|
|
# )
|
|
|
|
#
|
|
|
|
# def fix_commit(line: str):
|
|
|
|
# for name, value in names_values:
|
|
|
|
# beginning = f'#define {name} '
|
|
|
|
#
|
|
|
|
# if line.startswith(beginning):
|
|
|
|
# return f'{beginning}{value}\n'
|
|
|
|
#
|
|
|
|
# return line
|
|
|
|
#
|
|
|
|
# self.update_text_file(state.build_path / 'r_version.h', fix_commit)
|
2023-03-20 11:52:21 +00:00
|
|
|
|
|
|
|
|
2023-03-23 09:48:07 +00:00
|
|
|
class RizinTarget(base.MesonTarget):
|
|
|
|
def __init__(self, name='rizin'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://github.com/rizinorg/rizin/releases/download/v0.5.1/rizin-src-v0.5.1.tar.xz',
|
|
|
|
'f7a1338a909de465f56e4a59217669d595153be39ee2de5b86d8466475159859')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('binrz/man/rizin.1')
|
|
|
|
|
2023-03-23 14:13:00 +00:00
|
|
|
def configure(self, state: BuildState):
|
|
|
|
super().configure(state)
|
|
|
|
|
2023-03-25 10:54:50 +00:00
|
|
|
# # Fix absolute paths in r_userconf.h
|
|
|
|
# search_subpath = str(state.install_path)
|
|
|
|
# replace_subpath = '/usr/local'
|
|
|
|
#
|
|
|
|
# def fix_paths(line: str):
|
|
|
|
# return line.replace(search_subpath, replace_subpath) if search_subpath in line else line
|
|
|
|
#
|
|
|
|
# self.update_text_file(state.build_path / 'rz_userconf.h', fix_paths)
|
2023-03-23 09:48:07 +00:00
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class SeverZipTarget(base.MakeTarget):
|
2023-02-20 08:56:25 +00:00
|
|
|
# Build with --os-version-x64=10.13 command line option
|
|
|
|
|
|
|
|
def __init__(self, name='7zip'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.src_root = 'CPP/7zip/Bundles/Alone2'
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://www.7-zip.org/a/7z2201-src.tar.xz',
|
|
|
|
'393098730c70042392af808917e765945dc2437dee7aae3cfcc4966eb920fbc5',
|
|
|
|
patches='7zip-fix-errors')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('CPP/7zip/cmpl_mac_arm64.mak')
|
|
|
|
|
|
|
|
def configure(self, state: BuildState):
|
|
|
|
state.validate_minimum_version('10.13')
|
|
|
|
super().configure(state)
|
|
|
|
|
|
|
|
def build(self, state: BuildState):
|
|
|
|
environment = state.environment
|
|
|
|
mak_suffix = self._arch_suffix(state)
|
|
|
|
|
|
|
|
opts = state.options
|
|
|
|
opts['-f'] = None
|
|
|
|
opts[f'../../cmpl_mac_{mak_suffix}.mak'] = None
|
|
|
|
opts['CFLAGS_BASE_LIST'] = environment['CFLAGS'] + ' -c'
|
|
|
|
opts['LDFLAGS_STATIC_2'] = environment['LDFLAGS']
|
|
|
|
|
|
|
|
super().build(state)
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
build_suffix = self._arch_suffix(state)
|
|
|
|
self.copy_to_bin(state, f'{self.src_root}/b/m_{build_suffix}/7zz', '7zz')
|
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def _arch_suffix(state: BuildState):
|
|
|
|
arch = state.architecture()
|
|
|
|
return 'x64' if arch == 'x86_64' else arch
|
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class UnrarTarget(base.MakeTarget):
|
2022-09-24 06:53:24 +00:00
|
|
|
def __init__(self, name='unrar'):
|
|
|
|
super().__init__(name)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://www.rarlab.com/rar/unrarsrc-6.0.7.tar.gz',
|
|
|
|
'a7029942006cbcced3f3b7322ec197683f8e7be408972ca08099b196c038f518')
|
|
|
|
|
|
|
|
def post_build(self, state: BuildState):
|
|
|
|
self.copy_to_bin(state)
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('rar.hpp')
|
|
|
|
|
|
|
|
|
2023-03-20 10:39:37 +00:00
|
|
|
class ZipTarget(base.SingleExeCTarget):
|
2022-09-23 11:55:40 +00:00
|
|
|
def __init__(self, name='zip'):
|
|
|
|
super().__init__(name)
|
|
|
|
self.options = (
|
|
|
|
'-I.', '-DUNIX', '-DBZIP2_SUPPORT', '-DLARGE_FILE_SUPPORT', '-DUNICODE_SUPPORT',
|
|
|
|
'-DHAVE_DIRENT_H', '-DHAVE_TERMIOS_H', '-lbz2',
|
|
|
|
'crc32.c', 'crypt.c', 'deflate.c', 'fileio.c', 'globals.c', 'trees.c',
|
|
|
|
'ttyio.c', 'unix/unix.c', 'util.c', 'zip.c', 'zipfile.c', 'zipup.c',
|
|
|
|
)
|
|
|
|
|
|
|
|
def prepare_source(self, state: BuildState):
|
|
|
|
state.download_source(
|
|
|
|
'https://downloads.sourceforge.net/project/infozip/Zip%203.x%20%28latest%29/3.0/zip30.tar.gz',
|
|
|
|
'f0e8bb1f9b7eb0b01285495a2699df3a4b766784c1765a8f1aeedf63c0806369',
|
|
|
|
patches='zip-fix-misc')
|
|
|
|
|
|
|
|
def detect(self, state: BuildState) -> bool:
|
|
|
|
return state.has_source_file('zip.h')
|