fortran: make include scanning also work for CMake subprojects

also fixed PEP8

I originally implemented the "include" scanning,
but hadn't made a test for this case
pull/7689/head
Michael Hirsch 4 years ago
parent 0b0873c743
commit 34f7fee741
No known key found for this signature in database
GPG Key ID: 6D23CDADAB0294F9
  1. 42
      mesonbuild/backend/ninjabackend.py

@ -543,10 +543,10 @@ int dummy;
# rule store as being wanted in compdb
for for_machine in MachineChoice:
for lang in self.environment.coredata.compilers[for_machine]:
rules += [ "%s%s" % (rule, ext) for rule in [self.get_compiler_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
rules += [ "%s%s" % (rule, ext) for rule in [self.get_pch_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
rules += ["%s%s" % (rule, ext) for rule in [self.get_compiler_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
rules += ["%s%s" % (rule, ext) for rule in [self.get_pch_rule_name(lang, for_machine)]
for ext in ['', '_RSP']]
compdb_options = ['-x'] if mesonlib.version_compare(self.ninja_version, '>=1.9') else []
ninja_compdb = [self.ninja_command, '-t', 'compdb'] + compdb_options + rules
builddir = self.environment.get_build_dir()
@ -990,7 +990,7 @@ int dummy;
self.build.get_subproject_dir()),
self.environment.get_build_dir(),
self.environment.get_log_dir()] +
(['--use_llvm_cov'] if use_llvm_cov else []))
(['--use_llvm_cov'] if use_llvm_cov else []))
def generate_coverage_rules(self):
e = NinjaBuildElement(self.all_outputs, 'meson-coverage', 'CUSTOM_COMMAND', 'PHONY')
@ -1560,13 +1560,13 @@ int dummy;
self.get_target_dir(target))
else:
target_slashname_workaround_dir = self.get_target_dir(target)
(rpath_args, target.rpath_dirs_to_remove) = \
rustc.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
target.install_rpath)
rpath_args, target.rpath_dirs_to_remove = (
rustc.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
target.install_rpath))
# ... but then add rustc's sysroot to account for rustup
# installations
for rpath_arg in rpath_args:
@ -2777,13 +2777,13 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
self.get_target_dir(target))
else:
target_slashname_workaround_dir = self.get_target_dir(target)
(rpath_args, target.rpath_dirs_to_remove) = \
linker.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
target.install_rpath)
(rpath_args, target.rpath_dirs_to_remove) = (
linker.build_rpath_args(self.environment,
self.environment.get_build_dir(),
target_slashname_workaround_dir,
self.determine_rpath_dirs(target),
target.build_rpath,
target.install_rpath))
commands += rpath_args
# Add libraries generated by custom targets
custom_target_libraries = self.get_custom_target_provided_libraries(target)
@ -3041,7 +3041,9 @@ def _scan_fortran_file_deps(src: Path, srcdir: Path, dirname: Path, tdeps, compi
# included files
incmatch = incre.match(line)
if incmatch is not None:
incfile = srcdir / incmatch.group(1)
incfile = src.parent / incmatch.group(1)
# NOTE: src.parent is most general, in particular for CMake subproject with Fortran file
# having an `include 'foo.f'` statement.
if incfile.suffix.lower()[1:] in compiler.file_suffixes:
mod_files.extend(_scan_fortran_file_deps(incfile, srcdir, dirname, tdeps, compiler))
# modules

Loading…
Cancel
Save