2020-12-06 08:05:32 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
#
|
|
|
|
# Helper module to build macOS version of various source ports
|
2021-01-01 08:45:24 +00:00
|
|
|
# Copyright (C) 2020-2021 Alexey Lysiuk
|
2020-12-06 08:05:32 +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/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
import os
|
2021-09-08 07:06:46 +00:00
|
|
|
from pathlib import Path
|
2020-12-06 08:05:32 +00:00
|
|
|
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')
|
|
|
|
|
2021-09-08 07:06:46 +00:00
|
|
|
bin_path = Path(__file__).parent
|
|
|
|
prefix_path = bin_path.parent
|
|
|
|
config_path = prefix_path / 'lib/pkgconfig'
|
2020-12-06 08:05:32 +00:00
|
|
|
|
|
|
|
environment = os.environ
|
2021-09-08 07:06:46 +00:00
|
|
|
environment['PKG_CONFIG_PATH'] = str(config_path)
|
2020-12-06 08:05:32 +00:00
|
|
|
|
2020-12-20 11:11:23 +00:00
|
|
|
predefined_args = [
|
2021-09-08 07:06:46 +00:00
|
|
|
f'{bin_path}/pkg-config.exe',
|
|
|
|
f'--define-variable=prefix={prefix_path}',
|
2020-12-20 11:11:23 +00:00
|
|
|
'--static'
|
|
|
|
]
|
|
|
|
args = predefined_args + args
|
2020-12-06 08:05:32 +00:00
|
|
|
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()
|