mirror of
https://github.com/ZDoom/zdoom-macos-deps.git
synced 2024-11-22 03:51:33 +00:00
66 lines
1.9 KiB
Python
Executable file
66 lines
1.9 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
|
|
#
|
|
# 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 os
|
|
from pathlib import Path
|
|
import shlex
|
|
import subprocess
|
|
import sys
|
|
|
|
|
|
def _main():
|
|
args = sys.argv[1:]
|
|
|
|
with open('pkg-config.log', 'a') as log:
|
|
cmdline = ' '.join(map(shlex.quote, args))
|
|
log.write(f'% pkg-config {cmdline}\n')
|
|
|
|
bin_path = Path(__file__).parent
|
|
prefix_path = bin_path.parent
|
|
config_path = prefix_path / 'lib/pkgconfig'
|
|
|
|
environment = os.environ
|
|
environment['PKG_CONFIG_PATH'] = str(config_path)
|
|
|
|
predefined_args = [
|
|
f'{bin_path}/pkg-config.exe',
|
|
f'--define-variable=prefix={prefix_path}',
|
|
'--static'
|
|
]
|
|
args = predefined_args + args
|
|
result = subprocess.run(args, env=environment, capture_output=True)
|
|
|
|
stdout = result.stdout.decode('ascii')
|
|
stderr = result.stderr.decode('ascii')
|
|
|
|
with open('pkg-config.log', 'a') as log:
|
|
log.write('out> ')
|
|
log.write(stdout if stdout else '\n')
|
|
log.write('err> ')
|
|
log.write(stderr if stderr else '\n')
|
|
|
|
sys.stdout.write(stdout)
|
|
sys.stderr.write(stderr)
|
|
|
|
sys.exit(result.returncode)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
_main()
|