diff --git a/mesonbuild/compilers/cs.py b/mesonbuild/compilers/cs.py index a6c74d260..95b160393 100644 --- a/mesonbuild/compilers/cs.py +++ b/mesonbuild/compilers/cs.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): diff --git a/mesonbuild/compilers/java.py b/mesonbuild/compilers/java.py index 978562ca1..686d2e051 100644 --- a/mesonbuild/compilers/java.py +++ b/mesonbuild/compilers/java.py @@ -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): diff --git a/mesonbuild/compilers/swift.py b/mesonbuild/compilers/swift.py index 4d5dd0cfe..c156541d7 100644 --- a/mesonbuild/compilers/swift.py +++ b/mesonbuild/compilers/swift.py @@ -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): diff --git a/mesonbuild/mesonlib.py b/mesonbuild/mesonlib.py index 98c2366d6..ef029405e 100644 --- a/mesonbuild/mesonlib.py +++ b/mesonbuild/mesonlib.py @@ -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): diff --git a/mesonbuild/mintro.py b/mesonbuild/mintro.py index 9af9c6c00..b6c00ec16 100644 --- a/mesonbuild/mintro.py +++ b/mesonbuild/mintro.py @@ -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 = []