dist: Fix --include-subprojects when .wrap file has directory value
This commit is contained in:
parent
fc800a2cb8
commit
5031f4981d
|
@ -24,6 +24,7 @@ from glob import glob
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from mesonbuild.environment import detect_ninja
|
from mesonbuild.environment import detect_ninja
|
||||||
from mesonbuild.mesonlib import windows_proof_rmtree, MesonException
|
from mesonbuild.mesonlib import windows_proof_rmtree, MesonException
|
||||||
|
from mesonbuild.wrap import wrap
|
||||||
from mesonbuild import mlog, build
|
from mesonbuild import mlog, build
|
||||||
|
|
||||||
archive_choices = ['gztar', 'xztar', 'zip']
|
archive_choices = ['gztar', 'xztar', 'zip']
|
||||||
|
@ -237,7 +238,10 @@ def run(options):
|
||||||
subprojects = []
|
subprojects = []
|
||||||
extra_meson_args = []
|
extra_meson_args = []
|
||||||
if options.include_subprojects:
|
if options.include_subprojects:
|
||||||
subprojects = [os.path.join(b.subproject_dir, sub) for sub in b.subprojects]
|
subproject_dir = os.path.join(src_root, b.subproject_dir)
|
||||||
|
for sub in b.subprojects:
|
||||||
|
_, directory = wrap.get_directory(subproject_dir, sub)
|
||||||
|
subprojects.append(os.path.join(b.subproject_dir, directory))
|
||||||
extra_meson_args.append('-Dwrap_mode=nodownload')
|
extra_meson_args.append('-Dwrap_mode=nodownload')
|
||||||
|
|
||||||
if is_git(src_root):
|
if is_git(src_root):
|
||||||
|
|
|
@ -125,6 +125,23 @@ class PackageDefinition:
|
||||||
def has_patch(self) -> bool:
|
def has_patch(self) -> bool:
|
||||||
return 'patch_url' in self.values
|
return 'patch_url' in self.values
|
||||||
|
|
||||||
|
def load_wrap(subdir_root: str, packagename: str) -> PackageDefinition:
|
||||||
|
fname = os.path.join(subdir_root, packagename + '.wrap')
|
||||||
|
if os.path.isfile(fname):
|
||||||
|
return PackageDefinition(fname)
|
||||||
|
return None
|
||||||
|
|
||||||
|
def get_directory(subdir_root: str, packagename: str):
|
||||||
|
directory = packagename
|
||||||
|
# We always have to load the wrap file, if it exists, because it could
|
||||||
|
# override the default directory name.
|
||||||
|
wrap = load_wrap(subdir_root, packagename)
|
||||||
|
if wrap and 'directory' in wrap.values:
|
||||||
|
directory = wrap.get('directory')
|
||||||
|
if os.path.dirname(directory):
|
||||||
|
raise WrapException('Directory key must be a name and not a path')
|
||||||
|
return wrap, directory
|
||||||
|
|
||||||
class Resolver:
|
class Resolver:
|
||||||
def __init__(self, subdir_root: str, wrap_mode=WrapMode.default):
|
def __init__(self, subdir_root: str, wrap_mode=WrapMode.default):
|
||||||
self.wrap_mode = wrap_mode
|
self.wrap_mode = wrap_mode
|
||||||
|
@ -133,14 +150,7 @@ class Resolver:
|
||||||
|
|
||||||
def resolve(self, packagename: str, method: str) -> str:
|
def resolve(self, packagename: str, method: str) -> str:
|
||||||
self.packagename = packagename
|
self.packagename = packagename
|
||||||
self.directory = packagename
|
self.wrap, self.directory = get_directory(self.subdir_root, self.packagename)
|
||||||
# We always have to load the wrap file, if it exists, because it could
|
|
||||||
# override the default directory name.
|
|
||||||
self.wrap = self.load_wrap()
|
|
||||||
if self.wrap and 'directory' in self.wrap.values:
|
|
||||||
self.directory = self.wrap.get('directory')
|
|
||||||
if os.path.dirname(self.directory):
|
|
||||||
raise WrapException('Directory key must be a name and not a path')
|
|
||||||
self.dirname = os.path.join(self.subdir_root, self.directory)
|
self.dirname = os.path.join(self.subdir_root, self.directory)
|
||||||
meson_file = os.path.join(self.dirname, 'meson.build')
|
meson_file = os.path.join(self.dirname, 'meson.build')
|
||||||
cmake_file = os.path.join(self.dirname, 'CMakeLists.txt')
|
cmake_file = os.path.join(self.dirname, 'CMakeLists.txt')
|
||||||
|
@ -187,12 +197,6 @@ class Resolver:
|
||||||
|
|
||||||
return self.directory
|
return self.directory
|
||||||
|
|
||||||
def load_wrap(self) -> PackageDefinition:
|
|
||||||
fname = os.path.join(self.subdir_root, self.packagename + '.wrap')
|
|
||||||
if os.path.isfile(fname):
|
|
||||||
return PackageDefinition(fname)
|
|
||||||
return None
|
|
||||||
|
|
||||||
def check_can_download(self) -> None:
|
def check_can_download(self) -> None:
|
||||||
# Don't download subproject data based on wrap file if requested.
|
# Don't download subproject data based on wrap file if requested.
|
||||||
# Git submodules are ok (see above)!
|
# Git submodules are ok (see above)!
|
||||||
|
|
Loading…
Reference in New Issue