Merge pull request #1788 from aradi/fix-fortran-scan

Fix scanning of Fortran sources created during configuration
pull/1779/merge
Jussi Pakkanen 8 years ago committed by GitHub
commit 08bd92a6ae
  1. 9
      mesonbuild/backend/ninjabackend.py
  2. 22
      test cases/fortran/7 generated/meson.build
  3. 6
      test cases/fortran/7 generated/mod1.fpp
  4. 7
      test cases/fortran/7 generated/mod2.fpp
  5. 9
      test cases/fortran/7 generated/prog.f90

@ -1698,12 +1698,13 @@ rule FORTRAN_DEP_HACK
modre = re.compile(r"\s*module\s+(\w+)", re.IGNORECASE)
module_files = {}
for s in target.get_sources():
# FIXME, does not work for generated Fortran sources,
# but those are really rare. I hope.
# FIXME, does not work for Fortran sources generated by
# custom_target() and generator() as those are run after
# the configuration (configure_file() is OK)
if not compiler.can_compile(s):
continue
filename = os.path.join(self.environment.get_source_dir(),
s.subdir, s.fname)
filename = s.absolute_path(self.environment.get_source_dir(),
self.environment.get_build_dir())
with open(filename) as f:
for line in f:
modmatch = modre.match(line)

@ -0,0 +1,22 @@
# Tests whether fortran sources files created during configuration are properly
# scanned for dependency information
project('generated', 'fortran')
conf_data = configuration_data()
conf_data.set('ONE', 1)
conf_data.set('TWO', 2)
templates_basenames = ['mod2', 'mod1']
generated_sources = []
foreach template_basename : templates_basenames
infilename = '@0@.fpp'.format(template_basename)
outfilename = '@0@.f90'.format(template_basename)
outfile = configure_file(
input : infilename, output : outfilename, configuration : conf_data)
generated_sources += [outfile]
endforeach
sources = ['prog.f90'] + generated_sources
exe = executable('generated', sources)
test('generated', exe)

@ -0,0 +1,6 @@
module mod1
implicit none
integer, parameter :: modval1 = @ONE@
end module mod1

@ -0,0 +1,7 @@
module mod2
use mod1
implicit none
integer, parameter :: modval2 = @TWO@
end module mod2

@ -0,0 +1,9 @@
program prog
use mod2
implicit none
if (modval1 + modval2 /= 3) then
stop 1
end if
end program prog
Loading…
Cancel
Save