mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-22 09:41:07 +00:00
win: add new win-pkgconfig subproject
This subprojects provides the pkg-config.exe binary on Windows required by g-ir-scanner to build introspection GIR's Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1584>
This commit is contained in:
parent
4172b0152f
commit
2ae4aa2384
3 changed files with 81 additions and 0 deletions
|
@ -116,6 +116,7 @@ if get_option('build-tools-source') == 'subproject'
|
||||||
if build_system == 'windows'
|
if build_system == 'windows'
|
||||||
subproject('win-flex-bison-binaries')
|
subproject('win-flex-bison-binaries')
|
||||||
subproject('win-nasm')
|
subproject('win-nasm')
|
||||||
|
subproject('win-pkgconfig')
|
||||||
elif build_system == 'darwin'
|
elif build_system == 'darwin'
|
||||||
subproject('macos-bison-binary')
|
subproject('macos-bison-binary')
|
||||||
# Newer macOS provides /usr/lib/pkgconfig/libpcre2-8.pc which is broken
|
# Newer macOS provides /usr/lib/pkgconfig/libpcre2-8.pc which is broken
|
||||||
|
|
61
subprojects/win-pkgconfig/download-binary.py
Normal file
61
subprojects/win-pkgconfig/download-binary.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import ssl
|
||||||
|
import zipfile
|
||||||
|
import hashlib
|
||||||
|
import urllib.request
|
||||||
|
import urllib.error
|
||||||
|
|
||||||
|
# Disable certificate checking because it always fails on Windows
|
||||||
|
# We verify the checksum anyway.
|
||||||
|
ctx = ssl.create_default_context()
|
||||||
|
ctx.check_hostname = False
|
||||||
|
ctx.verify_mode = ssl.CERT_NONE
|
||||||
|
|
||||||
|
BASENAME = 'pkg-config.zip'
|
||||||
|
GSTREAMER_URL = 'https://gstreamer.freedesktop.org/src/mirror/pkg-config.zip'
|
||||||
|
|
||||||
|
zip_sha256 = sys.argv[1]
|
||||||
|
source_dir = os.path.join(
|
||||||
|
os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR'])
|
||||||
|
dest = BASENAME
|
||||||
|
dest_path = os.path.join(source_dir, dest)
|
||||||
|
|
||||||
|
|
||||||
|
def get_sha256(zipf):
|
||||||
|
hasher = hashlib.sha256()
|
||||||
|
with open(zipf, 'rb') as f:
|
||||||
|
hasher.update(f.read())
|
||||||
|
return hasher.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
if os.path.isfile(dest_path):
|
||||||
|
found_sha256 = get_sha256(dest_path)
|
||||||
|
if found_sha256 == zip_sha256:
|
||||||
|
print('{} already downloaded'.format(dest))
|
||||||
|
sys.exit(0)
|
||||||
|
else:
|
||||||
|
print('{} checksum mismatch, redownloading'.format(dest))
|
||||||
|
|
||||||
|
url = GSTREAMER_URL.format(dest)
|
||||||
|
print('Downloading {} to {}'.format(GSTREAMER_URL.format(dest), dest))
|
||||||
|
try:
|
||||||
|
with open(dest_path, 'wb') as d:
|
||||||
|
f = urllib.request.urlopen(url, context=ctx)
|
||||||
|
d.write(f.read())
|
||||||
|
except urllib.error.URLError as ex:
|
||||||
|
curdir = os.path.dirname(sys.argv[0])
|
||||||
|
print('Couldn\'t download {!r}! Try downloading it manually and '
|
||||||
|
'placing it into {!r}'.format(dest, curdir))
|
||||||
|
|
||||||
|
found_sha256 = get_sha256(dest_path)
|
||||||
|
if found_sha256 != zip_sha256:
|
||||||
|
print('SHA256 of downloaded file {} was {} instead of {}'
|
||||||
|
''.format(dest, found_sha256, zip_sha256))
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
print('Extracting {}'.format(dest))
|
||||||
|
zf = zipfile.ZipFile(dest_path, "r")
|
||||||
|
zf.extractall(path=source_dir)
|
19
subprojects/win-pkgconfig/meson.build
Normal file
19
subprojects/win-pkgconfig/meson.build
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
project('win-pkgconfig', version : '0.29.2')
|
||||||
|
|
||||||
|
py3 = import('python3').find_python()
|
||||||
|
|
||||||
|
if host_machine.system() != 'windows'
|
||||||
|
error('Can only download pkgconfig for Windows, sorry')
|
||||||
|
endif
|
||||||
|
|
||||||
|
message('Downloading pkg-config.exe binary for Windows...')
|
||||||
|
|
||||||
|
zip_hash = 'b74be141a53f193727fdcb33e9a052a38d9b79c6262326d264e502796b73dfe1'
|
||||||
|
|
||||||
|
ret = run_command(py3, files('download-binary.py'), zip_hash, check: true)
|
||||||
|
if ret.returncode() != 0
|
||||||
|
message(ret.stdout())
|
||||||
|
error(ret.stderr())
|
||||||
|
endif
|
||||||
|
|
||||||
|
meson.override_find_program('pkg-config', find_program('pkg-config.exe'))
|
Loading…
Reference in a new issue