rizin/sys/check_meson_subproject.py
Riccardo Schirone f8291ee3c1
Switch to meson subprojects and wraps
* Remove tree-sitter/sdb git submodules and move them to meson subprojects/wraps
* Use meson subprojects/wraps to get capstone
* Remove capstone patches as they are already applied to rizinorg/capstone repository
* Use meson from master branch to create the release tarball, as all released versions so far have a bug that prevent wrap-git to be patched correctly when creating the tarball with meson dist
* Add check_meson_subproject script to do a quick check if the currently downloaded subprojects are updated
* Add subprojects_check meson option to skip the check_meson_subproject script
* Update documentation to remove references to git submodules.
2021-02-03 14:31:11 +01:00

42 lines
No EOL
1.2 KiB
Python

#!/usr/bin/env python
#
# This script is necessary to make sure people notice a subproject has been
# changed and need to be updated. Meson does not warn you now (0.56.0)
""" Portable python script to check if subproject is up-to-date and warn if not """
import sys
import os
subproject = sys.argv[1]
meson_root = os.environ['MESON_SOURCE_ROOT']
subproject_filename = os.path.join(meson_root, 'subprojects', subproject + '.wrap')
try:
f = open(subproject_filename, 'r')
is_wrap_git = False
revision = None
directory = subproject
for l in f:
if 'wrap-git' in l:
is_wrap_git = True
elif l.startswith('revision'):
revision = l.split('=')[1].strip()
elif l.startswith('directory'):
directory = l.split('=')[1].strip()
if not is_wrap_git or not revision:
sys.exit(0)
subproject_dir = os.path.join(meson_root, 'subprojects', directory)
subproject_git_dir = os.path.join(subproject_dir, '.git')
if os.path.isdir(subproject_dir) and os.path.isdir(subproject_git_dir):
head = open(os.path.join(subproject_git_dir, 'HEAD'), 'r').read().strip()
if head != revision:
sys.exit(1)
sys.exit(0)
except FileNotFoundError:
sys.exit(0)