summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hirsch, Ph.D <scivision@users.noreply.github.com>2019-01-29 16:25:23 -0500
committerJussi Pakkanen <jpakkane@gmail.com>2019-01-29 23:25:23 +0200
commitcccffaa29d63503128803b848bd4843cc942538d (patch)
treeee4e792eab40df529d99b7a10e2dc399085405aa
parentda34bea893b3b309800e0f03021a99ee58c599d6 (diff)
downloadmeson-cccffaa29d63503128803b848bd4843cc942538d.tar.gz
BUGFIX: allow fc.run(code) to work, pick only Fortran module
-rw-r--r--mesonbuild/backend/ninjabackend.py5
-rw-r--r--mesonbuild/compilers/fortran.py5
-rw-r--r--test cases/fortran/11 compiles links runs/meson.build20
3 files changed, 22 insertions, 8 deletions
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index debb4fbcf..493fc0ddf 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -1826,7 +1826,7 @@ rule FORTRAN_DEP_HACK%s
if compiler is None:
self.fortran_deps[target.get_basename()] = {}
return
- modre = re.compile(r"\s*module\s+(\w+)", re.IGNORECASE)
+ modre = re.compile(r"\bmodule\s+(\w+)\s*$", re.IGNORECASE)
module_files = {}
for s in target.get_sources():
# FIXME, does not work for Fortran sources generated by
@@ -1843,9 +1843,6 @@ rule FORTRAN_DEP_HACK%s
modmatch = modre.match(line)
if modmatch is not None:
modname = modmatch.group(1).lower()
- if modname == 'procedure':
- # MODULE PROCEDURE construct
- continue
if modname in module_files:
raise InvalidArguments(
'Namespace collision: module %s defined in '
diff --git a/mesonbuild/compilers/fortran.py b/mesonbuild/compilers/fortran.py
index c29c4bd00..a8e8e2542 100644
--- a/mesonbuild/compilers/fortran.py
+++ b/mesonbuild/compilers/fortran.py
@@ -77,10 +77,7 @@ class FortranCompiler(Compiler):
source_name = os.path.join(work_dir, 'sanitycheckf.f90')
binary_name = os.path.join(work_dir, 'sanitycheckf')
with open(source_name, 'w') as ofile:
- ofile.write('''program prog
- print *, "Fortran compilation is working."
-end program prog
-''')
+ ofile.write('print *, "Fortran compilation is working."; end')
extra_flags = self.get_cross_extra_flags(environment, link=True)
pc = subprocess.Popen(self.exelist + extra_flags + [source_name, '-o', binary_name])
pc.wait()
diff --git a/test cases/fortran/11 compiles links runs/meson.build b/test cases/fortran/11 compiles links runs/meson.build
new file mode 100644
index 000000000..81eb90791
--- /dev/null
+++ b/test cases/fortran/11 compiles links runs/meson.build
@@ -0,0 +1,20 @@
+project('compiles_links_runs', 'fortran')
+
+fc = meson.get_compiler('fortran')
+
+code = '''error stop 123; end'''
+
+if not fc.compiles(code)
+ error('Fortran 2008 code failed to compile')
+endif
+
+if not fc.links(code)
+ error('Fortran 2008 code failed to link')
+endif
+
+if fc.run(code).returncode() != 123
+ error('Fortran 2008 code failed to run')
+endif
+
+
+