zdoom-macos-deps/deps/system/bin/pkg-config

65 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
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 = os.path.dirname(os.path.abspath(__file__)) + os.sep
prefix_path = os.path.abspath(bin_path + os.pardir)
config_path = prefix_path + '/lib/pkgconfig'
environment = os.environ
environment['PKG_CONFIG_PATH'] = config_path
predefined_args = [
bin_path + 'pkg-config.exe',
'--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()