mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-31 20:48:56 +00:00
Add a new subproject 'win-flex-bison-binaries'
This subproject will download and provide win32 binaries for flex and/or bison if they aren't found at configure time on Windows.
This commit is contained in:
parent
d22add782b
commit
85e49c19d4
4 changed files with 92 additions and 0 deletions
|
@ -14,6 +14,7 @@ subprojects = [
|
||||||
'gst-plugins-good',
|
'gst-plugins-good',
|
||||||
]
|
]
|
||||||
|
|
||||||
|
build_system = build_machine.system()
|
||||||
cc = meson.get_compiler('c')
|
cc = meson.get_compiler('c')
|
||||||
|
|
||||||
# Make it possible to use msys2 built zlib which fails
|
# Make it possible to use msys2 built zlib which fails
|
||||||
|
@ -130,6 +131,13 @@ foreach custom_subproj: get_option('custom_subprojects').split(',')
|
||||||
endif
|
endif
|
||||||
endforeach
|
endforeach
|
||||||
|
|
||||||
|
# On Windows, if flex/bison aren't found, we use a subproject to get them
|
||||||
|
flex = find_program('flex', 'win_flex', required : build_system != 'windows')
|
||||||
|
bison = find_program('bison', 'win_bison', required : build_system != 'windows')
|
||||||
|
if not flex.found() or not bison.found()
|
||||||
|
subproject('win-flex-bison-binaries')
|
||||||
|
endif
|
||||||
|
|
||||||
message('Building subprojects: ' + ', '.join(subprojects))
|
message('Building subprojects: ' + ', '.join(subprojects))
|
||||||
foreach subproj: subprojects
|
foreach subproj: subprojects
|
||||||
subproject(subproj, version: gst_version)
|
subproject(subproj, version: gst_version)
|
||||||
|
|
9
subprojects/win-flex-bison-binaries/.gitignore
vendored
Normal file
9
subprojects/win-flex-bison-binaries/.gitignore
vendored
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
*.sw[op]
|
||||||
|
*~
|
||||||
|
custom_build_rules
|
||||||
|
data/
|
||||||
|
FlexLexer.h
|
||||||
|
README.txt
|
||||||
|
UNISTD_ERROR.readme
|
||||||
|
*.exe
|
||||||
|
*.zip
|
50
subprojects/win-flex-bison-binaries/download-binary.py
Normal file
50
subprojects/win-flex-bison-binaries/download-binary.py
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import ssl
|
||||||
|
import zipfile
|
||||||
|
import hashlib
|
||||||
|
import urllib.request
|
||||||
|
|
||||||
|
# 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
|
||||||
|
|
||||||
|
base_url = 'https://sourceforge.net/projects/winflexbison/files/win_flex_bison-{}.zip'
|
||||||
|
url = base_url.format(sys.argv[1])
|
||||||
|
zip_sha256 = sys.argv[2]
|
||||||
|
source_dir = os.path.join(os.environ['MESON_SOURCE_ROOT'], os.environ['MESON_SUBDIR'])
|
||||||
|
dest = os.path.basename(url)
|
||||||
|
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))
|
||||||
|
|
||||||
|
print('Downloading {} to {}'.format(url, dest))
|
||||||
|
with open(dest_path, 'wb') as d:
|
||||||
|
f = urllib.request.urlopen(url, context=ctx)
|
||||||
|
d.write(f.read())
|
||||||
|
|
||||||
|
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)
|
25
subprojects/win-flex-bison-binaries/meson.build
Normal file
25
subprojects/win-flex-bison-binaries/meson.build
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
project('win-flex-bison-binary', version : '2.5.14')
|
||||||
|
|
||||||
|
provide_flex = not find_program('flex', required : false).found()
|
||||||
|
provide_bison = not find_program('bison', required : false).found()
|
||||||
|
|
||||||
|
if provide_flex or provide_bison
|
||||||
|
py3 = import('python3').find_python()
|
||||||
|
|
||||||
|
message('Downloading and extracting win-flex-bison binaries...')
|
||||||
|
|
||||||
|
zip_hash = '354c9aae02aca421c52abfda7fe3ce6c32ad07e25ff3f66e31da9437a0b906cf'
|
||||||
|
|
||||||
|
ret = run_command(py3, files('download-binary.py'), meson.project_version(), zip_hash)
|
||||||
|
if ret.returncode() != 0
|
||||||
|
message(ret.stdout())
|
||||||
|
error(ret.stderr())
|
||||||
|
endif
|
||||||
|
|
||||||
|
if provide_flex
|
||||||
|
meson.override_find_program('flex', find_program('win_flex'))
|
||||||
|
endif
|
||||||
|
if provide_bison
|
||||||
|
meson.override_find_program('bison', find_program('win_bison'))
|
||||||
|
endif
|
||||||
|
endif
|
Loading…
Reference in a new issue