Fixed list_target_files and list_targets

pull/4547/head
Daniel Mensinger 6 years ago
parent a0d478da39
commit 71d17b44e4
No known key found for this signature in database
GPG Key ID: 54DD94C131E277D4
  1. 2
      mesonbuild/compilers/cs.py
  2. 2
      mesonbuild/compilers/java.py
  3. 2
      mesonbuild/compilers/swift.py
  4. 4
      mesonbuild/mesonlib.py
  5. 68
      mesonbuild/mintro.py

@ -82,7 +82,7 @@ class CsCompiler(Compiler):
def get_std_exe_link_args(self):
return []
def get_include_args(self, path):
def get_include_args(self, path, is_system):
return []
def get_pic_args(self):

@ -63,7 +63,7 @@ class JavaCompiler(Compiler):
def get_std_exe_link_args(self):
return []
def get_include_args(self, path):
def get_include_args(self, path, is_system):
return []
def get_pic_args(self):

@ -85,7 +85,7 @@ class SwiftCompiler(Compiler):
def build_rpath_args(self, *args):
return [] # FIXME
def get_include_args(self, dirname):
def get_include_args(self, dirname, is_system):
return ['-I' + dirname]
def get_compile_only_args(self):

@ -268,10 +268,12 @@ class File:
def relative_name(self):
return os.path.join(self.subdir, self.fname)
def get_compiler_for_source(compilers, src):
def get_compiler_for_source(compilers, src, canfail=False):
for comp in compilers:
if comp.can_compile(src):
return comp
if canfail:
return None
raise MesonException('No specified compiler can handle file {!s}'.format(src))
def classify_unity_sources(compilers, sources):

@ -183,10 +183,12 @@ def list_targets(coredata, builddata, installdata):
comp_list = target.compilers.values()
source_list = target.sources + target.extra_files
source_list = list(map(lambda x: (mesonlib.get_compiler_for_source(comp_list, x), x), source_list))
source_list = list(map(lambda x: (mesonlib.get_compiler_for_source(comp_list, x, True), x), source_list))
for comp, src in source_list:
if isinstance(comp, compilers.Compiler) and isinstance(src, mesonlib.File):
if isinstance(src, mesonlib.File):
src = os.path.join(src.subdir, src.fname)
if isinstance(comp, compilers.Compiler) and isinstance(src, str):
lang = comp.get_language()
if lang not in sources:
parameters = []
@ -208,7 +210,21 @@ def list_targets(coredata, builddata, installdata):
'source_files': []
}
sources[lang]['source_files'] += [os.path.join(src.subdir, src.fname)]
sources[lang]['source_files'] += [src]
elif comp is None and isinstance(src, str):
if 'unknown' not in sources:
sources['unknown'] = {'compiler': [], 'parameters': [], 'source_files': []}
sources['unknown']['source_files'] += [src]
elif isinstance(target, build.CustomTarget):
source_list_raw = target.sources + target.extra_files
source_list = []
for i in source_list_raw:
if isinstance(i, mesonlib.File):
source_list += [os.path.join(i.subdir, i.fname)]
elif isinstance(i, str):
source_list += [i]
sources['unknown'] = {'compiler': [], 'parameters': [], 'source_files': source_list}
# Convert the dict to a list and add the language key.
# This list approach will also work if the gurantee is removed that all
@ -245,21 +261,6 @@ def list_targets(coredata, builddata, installdata):
tlist.append(t)
return ('targets', tlist)
<<<<<<< HEAD
def list_target_files(target_name, coredata, builddata):
try:
t = builddata.targets[target_name]
sources = t.sources + t.extra_files
except KeyError:
print("Unknown target %s." % target_name)
sys.exit(1)
out = []
for i in sources:
if isinstance(i, mesonlib.File):
i = os.path.join(i.subdir, i.fname)
out.append(i)
return ('target_files', out)
class BuildoptionsOptionHelper:
# mimic an argparse namespace
def __init__(self, cross_file):
@ -406,22 +407,23 @@ def list_buildoptions_from_source(sourcedir, backend):
# Reenable logging just in case
mlog.enable()
list_buildoptions(intr.coredata)
=======
def list_target_files(target_name, targets):
return ('error: TODO implement', [])
#try:
# t = builddata.targets[target_name]
# sources = t.sources + t.extra_files
#except KeyError:
# print("Unknown target %s." % target_name)
# sys.exit(1)
#out = []
#for i in sources:
# if isinstance(i, mesonlib.File):
# i = os.path.join(i.subdir, i.fname)
# out.append(i)
#return ('target_files', out)
>>>>>>> More refactoring
result = []
tgt = None
for i in targets:
if i['id'] == target_name:
tgt = i
break
if tgt is None:
raise RuntimeError('Target with the ID "{}" could not be found'.format(target_name))
for i in tgt['sources']:
result += i['source_files']
return ('target_files', result)
def list_buildoptions(coredata):
optlist = []

Loading…
Cancel
Save