|
|
@ -534,9 +534,7 @@ class BuildTarget(Target): |
|
|
|
|
|
|
|
|
|
|
|
def process_objectlist(self, objects): |
|
|
|
def process_objectlist(self, objects): |
|
|
|
assert(isinstance(objects, list)) |
|
|
|
assert(isinstance(objects, list)) |
|
|
|
for s in objects: |
|
|
|
for s in unholder(objects): |
|
|
|
if hasattr(s, 'held_object'): |
|
|
|
|
|
|
|
s = s.held_object |
|
|
|
|
|
|
|
if isinstance(s, (str, File, ExtractedObjects)): |
|
|
|
if isinstance(s, (str, File, ExtractedObjects)): |
|
|
|
self.objects.append(s) |
|
|
|
self.objects.append(s) |
|
|
|
elif isinstance(s, (GeneratedList, CustomTarget)): |
|
|
|
elif isinstance(s, (GeneratedList, CustomTarget)): |
|
|
@ -552,10 +550,7 @@ class BuildTarget(Target): |
|
|
|
def process_sourcelist(self, sources): |
|
|
|
def process_sourcelist(self, sources): |
|
|
|
sources = listify(sources) |
|
|
|
sources = listify(sources) |
|
|
|
added_sources = {} # If the same source is defined multiple times, use it only once. |
|
|
|
added_sources = {} # If the same source is defined multiple times, use it only once. |
|
|
|
for s in sources: |
|
|
|
for s in unholder(sources): |
|
|
|
# Holder unpacking. Ugly. |
|
|
|
|
|
|
|
if hasattr(s, 'held_object'): |
|
|
|
|
|
|
|
s = s.held_object |
|
|
|
|
|
|
|
if isinstance(s, File): |
|
|
|
if isinstance(s, File): |
|
|
|
if s not in added_sources: |
|
|
|
if s not in added_sources: |
|
|
|
self.sources.append(s) |
|
|
|
self.sources.append(s) |
|
|
@ -632,9 +627,7 @@ class BuildTarget(Target): |
|
|
|
# which is what we need. |
|
|
|
# which is what we need. |
|
|
|
if not is_object(s): |
|
|
|
if not is_object(s): |
|
|
|
sources.append(s) |
|
|
|
sources.append(s) |
|
|
|
for d in self.external_deps: |
|
|
|
for d in unholder(self.external_deps): |
|
|
|
if hasattr(d, 'held_object'): |
|
|
|
|
|
|
|
d = d.held_object |
|
|
|
|
|
|
|
for s in d.sources: |
|
|
|
for s in d.sources: |
|
|
|
if isinstance(s, (str, File)): |
|
|
|
if isinstance(s, (str, File)): |
|
|
|
sources.append(s) |
|
|
|
sources.append(s) |
|
|
@ -696,10 +689,7 @@ class BuildTarget(Target): |
|
|
|
link_depends. |
|
|
|
link_depends. |
|
|
|
""" |
|
|
|
""" |
|
|
|
sources = listify(sources) |
|
|
|
sources = listify(sources) |
|
|
|
for s in sources: |
|
|
|
for s in unholder(sources): |
|
|
|
if hasattr(s, 'held_object'): |
|
|
|
|
|
|
|
s = s.held_object |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if isinstance(s, File): |
|
|
|
if isinstance(s, File): |
|
|
|
self.link_depends.append(s) |
|
|
|
self.link_depends.append(s) |
|
|
|
elif isinstance(s, str): |
|
|
|
elif isinstance(s, str): |
|
|
@ -810,11 +800,7 @@ class BuildTarget(Target): |
|
|
|
kwargs.get('modules', []) |
|
|
|
kwargs.get('modules', []) |
|
|
|
self.need_install = kwargs.get('install', self.need_install) |
|
|
|
self.need_install = kwargs.get('install', self.need_install) |
|
|
|
llist = extract_as_list(kwargs, 'link_with') |
|
|
|
llist = extract_as_list(kwargs, 'link_with') |
|
|
|
for linktarget in llist: |
|
|
|
for linktarget in unholder(llist): |
|
|
|
# Sorry for this hack. Keyword targets are kept in holders |
|
|
|
|
|
|
|
# in kwargs. Unpack here without looking at the exact type. |
|
|
|
|
|
|
|
if hasattr(linktarget, "held_object"): |
|
|
|
|
|
|
|
linktarget = linktarget.held_object |
|
|
|
|
|
|
|
if isinstance(linktarget, dependencies.ExternalLibrary): |
|
|
|
if isinstance(linktarget, dependencies.ExternalLibrary): |
|
|
|
raise MesonException('''An external library was used in link_with keyword argument, which |
|
|
|
raise MesonException('''An external library was used in link_with keyword argument, which |
|
|
|
is reserved for libraries built as part of this project. External |
|
|
|
is reserved for libraries built as part of this project. External |
|
|
@ -1033,9 +1019,7 @@ This will become a hard error in a future Meson release.''') |
|
|
|
|
|
|
|
|
|
|
|
def add_deps(self, deps): |
|
|
|
def add_deps(self, deps): |
|
|
|
deps = listify(deps) |
|
|
|
deps = listify(deps) |
|
|
|
for dep in deps: |
|
|
|
for dep in unholder(deps): |
|
|
|
if hasattr(dep, 'held_object'): |
|
|
|
|
|
|
|
dep = dep.held_object |
|
|
|
|
|
|
|
if isinstance(dep, dependencies.InternalDependency): |
|
|
|
if isinstance(dep, dependencies.InternalDependency): |
|
|
|
# Those parts that are internal. |
|
|
|
# Those parts that are internal. |
|
|
|
self.process_sourcelist(dep.sources) |
|
|
|
self.process_sourcelist(dep.sources) |
|
|
@ -1170,10 +1154,7 @@ You probably should put it in link_with instead.''') |
|
|
|
|
|
|
|
|
|
|
|
def add_include_dirs(self, args, set_is_system: T.Optional[str] = None): |
|
|
|
def add_include_dirs(self, args, set_is_system: T.Optional[str] = None): |
|
|
|
ids = [] |
|
|
|
ids = [] |
|
|
|
for a in args: |
|
|
|
for a in unholder(args): |
|
|
|
# FIXME same hack, forcibly unpack from holder. |
|
|
|
|
|
|
|
if hasattr(a, 'held_object'): |
|
|
|
|
|
|
|
a = a.held_object |
|
|
|
|
|
|
|
if not isinstance(a, IncludeDirs): |
|
|
|
if not isinstance(a, IncludeDirs): |
|
|
|
raise InvalidArguments('Include directory to be added is not an include directory object.') |
|
|
|
raise InvalidArguments('Include directory to be added is not an include directory object.') |
|
|
|
ids.append(a) |
|
|
|
ids.append(a) |
|
|
@ -1313,9 +1294,7 @@ class Generator: |
|
|
|
def __init__(self, args, kwargs): |
|
|
|
def __init__(self, args, kwargs): |
|
|
|
if len(args) != 1: |
|
|
|
if len(args) != 1: |
|
|
|
raise InvalidArguments('Generator requires exactly one positional argument: the executable') |
|
|
|
raise InvalidArguments('Generator requires exactly one positional argument: the executable') |
|
|
|
exe = args[0] |
|
|
|
exe = unholder(args[0]) |
|
|
|
if hasattr(exe, 'held_object'): |
|
|
|
|
|
|
|
exe = exe.held_object |
|
|
|
|
|
|
|
if not isinstance(exe, (Executable, dependencies.ExternalProgram)): |
|
|
|
if not isinstance(exe, (Executable, dependencies.ExternalProgram)): |
|
|
|
raise InvalidArguments('First generator argument must be an executable.') |
|
|
|
raise InvalidArguments('First generator argument must be an executable.') |
|
|
|
self.exe = exe |
|
|
|
self.exe = exe |
|
|
@ -1416,9 +1395,7 @@ class Generator: |
|
|
|
|
|
|
|
|
|
|
|
class GeneratedList: |
|
|
|
class GeneratedList: |
|
|
|
def __init__(self, generator, subdir, preserve_path_from=None, extra_args=None): |
|
|
|
def __init__(self, generator, subdir, preserve_path_from=None, extra_args=None): |
|
|
|
if hasattr(generator, 'held_object'): |
|
|
|
self.generator = unholder(generator) |
|
|
|
generator = generator.held_object |
|
|
|
|
|
|
|
self.generator = generator |
|
|
|
|
|
|
|
self.name = self.generator.exe |
|
|
|
self.name = self.generator.exe |
|
|
|
self.subdir = subdir |
|
|
|
self.subdir = subdir |
|
|
|
self.infilelist = [] |
|
|
|
self.infilelist = [] |
|
|
@ -1428,10 +1405,10 @@ class GeneratedList: |
|
|
|
self.depend_files = [] |
|
|
|
self.depend_files = [] |
|
|
|
self.preserve_path_from = preserve_path_from |
|
|
|
self.preserve_path_from = preserve_path_from |
|
|
|
self.extra_args = extra_args if extra_args is not None else [] |
|
|
|
self.extra_args = extra_args if extra_args is not None else [] |
|
|
|
if isinstance(generator.exe, dependencies.ExternalProgram): |
|
|
|
if isinstance(self.generator.exe, dependencies.ExternalProgram): |
|
|
|
if not generator.exe.found(): |
|
|
|
if not self.generator.exe.found(): |
|
|
|
raise InvalidArguments('Tried to use not-found external program as generator') |
|
|
|
raise InvalidArguments('Tried to use not-found external program as generator') |
|
|
|
path = generator.exe.get_path() |
|
|
|
path = self.generator.exe.get_path() |
|
|
|
if os.path.isabs(path): |
|
|
|
if os.path.isabs(path): |
|
|
|
# Can only add a dependency on an external program which we |
|
|
|
# Can only add a dependency on an external program which we |
|
|
|
# know the absolute path of |
|
|
|
# know the absolute path of |
|
|
@ -1873,9 +1850,7 @@ class SharedLibrary(BuildTarget): |
|
|
|
|
|
|
|
|
|
|
|
# Visual Studio module-definitions file |
|
|
|
# Visual Studio module-definitions file |
|
|
|
if 'vs_module_defs' in kwargs: |
|
|
|
if 'vs_module_defs' in kwargs: |
|
|
|
path = kwargs['vs_module_defs'] |
|
|
|
path = unholder(kwargs['vs_module_defs']) |
|
|
|
if hasattr(path, 'held_object'): |
|
|
|
|
|
|
|
path = path.held_object |
|
|
|
|
|
|
|
if isinstance(path, str): |
|
|
|
if isinstance(path, str): |
|
|
|
if os.path.isabs(path): |
|
|
|
if os.path.isabs(path): |
|
|
|
self.vs_module_defs = File.from_absolute_file(path) |
|
|
|
self.vs_module_defs = File.from_absolute_file(path) |
|
|
@ -2027,9 +2002,7 @@ class CustomTarget(Target): |
|
|
|
def get_target_dependencies(self): |
|
|
|
def get_target_dependencies(self): |
|
|
|
deps = self.dependencies[:] |
|
|
|
deps = self.dependencies[:] |
|
|
|
deps += self.extra_depends |
|
|
|
deps += self.extra_depends |
|
|
|
for c in self.sources: |
|
|
|
for c in unholder(self.sources): |
|
|
|
if hasattr(c, 'held_object'): |
|
|
|
|
|
|
|
c = c.held_object |
|
|
|
|
|
|
|
if isinstance(c, (BuildTarget, CustomTarget)): |
|
|
|
if isinstance(c, (BuildTarget, CustomTarget)): |
|
|
|
deps.append(c) |
|
|
|
deps.append(c) |
|
|
|
return deps |
|
|
|
return deps |
|
|
@ -2161,9 +2134,7 @@ class CustomTarget(Target): |
|
|
|
if not isinstance(self.build_always_stale, bool): |
|
|
|
if not isinstance(self.build_always_stale, bool): |
|
|
|
raise InvalidArguments('Argument build_always_stale must be a boolean.') |
|
|
|
raise InvalidArguments('Argument build_always_stale must be a boolean.') |
|
|
|
extra_deps, depend_files = [extract_as_list(kwargs, c, pop=False) for c in ['depends', 'depend_files']] |
|
|
|
extra_deps, depend_files = [extract_as_list(kwargs, c, pop=False) for c in ['depends', 'depend_files']] |
|
|
|
for ed in extra_deps: |
|
|
|
for ed in unholder(extra_deps): |
|
|
|
while hasattr(ed, 'held_object'): |
|
|
|
|
|
|
|
ed = ed.held_object |
|
|
|
|
|
|
|
if not isinstance(ed, (CustomTarget, BuildTarget)): |
|
|
|
if not isinstance(ed, (CustomTarget, BuildTarget)): |
|
|
|
raise InvalidArguments('Can only depend on toplevel targets: custom_target or build_target (executable or a library) got: {}({})' |
|
|
|
raise InvalidArguments('Can only depend on toplevel targets: custom_target or build_target (executable or a library) got: {}({})' |
|
|
|
.format(type(ed), ed)) |
|
|
|
.format(type(ed), ed)) |
|
|
@ -2198,9 +2169,7 @@ class CustomTarget(Target): |
|
|
|
|
|
|
|
|
|
|
|
def get_generated_lists(self): |
|
|
|
def get_generated_lists(self): |
|
|
|
genlists = [] |
|
|
|
genlists = [] |
|
|
|
for c in self.sources: |
|
|
|
for c in unholder(self.sources): |
|
|
|
if hasattr(c, 'held_object'): |
|
|
|
|
|
|
|
c = c.held_object |
|
|
|
|
|
|
|
if isinstance(c, GeneratedList): |
|
|
|
if isinstance(c, GeneratedList): |
|
|
|
genlists.append(c) |
|
|
|
genlists.append(c) |
|
|
|
return genlists |
|
|
|
return genlists |
|
|
@ -2463,9 +2432,7 @@ def get_sources_string_names(sources, backend): |
|
|
|
get all the output basenames. |
|
|
|
get all the output basenames. |
|
|
|
''' |
|
|
|
''' |
|
|
|
names = [] |
|
|
|
names = [] |
|
|
|
for s in sources: |
|
|
|
for s in unholder(sources): |
|
|
|
if hasattr(s, 'held_object'): |
|
|
|
|
|
|
|
s = s.held_object |
|
|
|
|
|
|
|
if isinstance(s, str): |
|
|
|
if isinstance(s, str): |
|
|
|
names.append(s) |
|
|
|
names.append(s) |
|
|
|
elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)): |
|
|
|
elif isinstance(s, (BuildTarget, CustomTarget, CustomTargetIndex, GeneratedList)): |
|
|
|