Merge pull request #1788 from aradi/fix-fortran-scan
Fix scanning of Fortran sources created during configuration
This commit is contained in:
commit
08bd92a6ae
|
@ -1698,12 +1698,13 @@ rule FORTRAN_DEP_HACK
|
||||||
modre = re.compile(r"\s*module\s+(\w+)", re.IGNORECASE)
|
modre = re.compile(r"\s*module\s+(\w+)", re.IGNORECASE)
|
||||||
module_files = {}
|
module_files = {}
|
||||||
for s in target.get_sources():
|
for s in target.get_sources():
|
||||||
# FIXME, does not work for generated Fortran sources,
|
# FIXME, does not work for Fortran sources generated by
|
||||||
# but those are really rare. I hope.
|
# custom_target() and generator() as those are run after
|
||||||
|
# the configuration (configure_file() is OK)
|
||||||
if not compiler.can_compile(s):
|
if not compiler.can_compile(s):
|
||||||
continue
|
continue
|
||||||
filename = os.path.join(self.environment.get_source_dir(),
|
filename = s.absolute_path(self.environment.get_source_dir(),
|
||||||
s.subdir, s.fname)
|
self.environment.get_build_dir())
|
||||||
with open(filename) as f:
|
with open(filename) as f:
|
||||||
for line in f:
|
for line in f:
|
||||||
modmatch = modre.match(line)
|
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…
Reference in New Issue