51 lines
1.9 KiB
Python
51 lines
1.9 KiB
Python
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
|
"""Build pinned Perl for Make recipes; no host Perl is required after packaging."""
|
|
import argparse
|
|
import os
|
|
from pathlib import Path
|
|
import shutil
|
|
import subprocess
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
VERSION = '5.44.0'
|
|
|
|
|
|
def build(output, architectures, jobs):
|
|
source = ROOT / 'third_party/perl'
|
|
env = dict(os.environ)
|
|
env.setdefault('DEVELOPER_DIR', '/Applications/Xcode.app/Contents/Developer')
|
|
prefixes = {}
|
|
for arch in architectures:
|
|
work = output / arch / 'work'
|
|
prefix = output / arch / 'install'
|
|
shutil.copytree(source, work)
|
|
flags = f'-arch {arch} -mmacosx-version-min=14.0'
|
|
commands = [
|
|
['sh', 'Configure', '-des', f'-Dprefix={prefix}', '-Dcc=clang',
|
|
f'-Dccflags={flags}', f'-Dldflags={flags}',
|
|
f'-Dlddlflags=-bundle -undefined dynamic_lookup {flags}',
|
|
'-Duserelocatableinc', '-Uuseshrplib', '-Uuseithreads',
|
|
'-Dman1dir=none', '-Dman3dir=none'],
|
|
['/usr/bin/make', f'-j{jobs}'], ['/usr/bin/make', 'install']]
|
|
for command in commands:
|
|
print('+', ' '.join(map(str, command)), flush=True)
|
|
subprocess.run(command, cwd=work, env=env, check=True)
|
|
prefixes[arch] = prefix
|
|
return prefixes
|
|
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description=__doc__)
|
|
parser.add_argument('--output', type=Path, required=True)
|
|
parser.add_argument('--architectures', nargs='+', choices=['arm64', 'x86_64'], default=['arm64', 'x86_64'])
|
|
parser.add_argument('--jobs', type=int, default=4)
|
|
args = parser.parse_args()
|
|
output = args.output.resolve()
|
|
if output.exists(): parser.error('Choose a fresh output directory')
|
|
output.mkdir(parents=True)
|
|
build(output, list(dict.fromkeys(args.architectures)), max(1, args.jobs))
|
|
|
|
|
|
if __name__ == '__main__': main()
|