summaryrefslogtreecommitdiffstats
path: root/test cases/fortran/7 generated
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-29 04:41:38 +0000
commit7b6e527f440cd7e6f8be2b07cee320ee6ca18786 (patch)
tree4a2738d69fa2814659fdadddf5826282e73d81f4 /test cases/fortran/7 generated
parentInitial commit. (diff)
downloadmeson-upstream.tar.xz
meson-upstream.zip
Adding upstream version 1.0.1.upstream/1.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'test cases/fortran/7 generated')
-rw-r--r--test cases/fortran/7 generated/meson.build39
-rw-r--r--test cases/fortran/7 generated/mod1.fpp6
-rw-r--r--test cases/fortran/7 generated/mod2.fpp7
-rw-r--r--test cases/fortran/7 generated/mod3.f906
-rw-r--r--test cases/fortran/7 generated/prog.f908
5 files changed, 66 insertions, 0 deletions
diff --git a/test cases/fortran/7 generated/meson.build b/test cases/fortran/7 generated/meson.build
new file mode 100644
index 0000000..f021309
--- /dev/null
+++ b/test cases/fortran/7 generated/meson.build
@@ -0,0 +1,39 @@
+# Tests whether fortran sources files created during configuration are properly
+# scanned for dependency information
+
+project('generated', 'fortran',
+ default_options : ['default_library=static'])
+
+conf_data = configuration_data()
+conf_data.set('ONE', 1)
+conf_data.set('TWO', 2)
+
+mod3_f = custom_target(
+ 'mod3.f',
+ input : 'mod3.f90',
+ output : 'mod3.f90',
+ # We need a platform agnostic way to do a copy a file, using a custom_target
+ # and we need to use the @OUTDIR@, not @OUTPUT@ in order to exercise
+ # https://github.com/mesonbuild/meson/issues/9258
+ command : [
+ find_program('python', 'python3'), '-c',
+ 'import sys, shutil; shutil.copy(sys.argv[1], sys.argv[2])',
+ '@INPUT@', '@OUTDIR@',
+ ],
+)
+
+three = library('mod3', mod3_f)
+
+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, link_with: three)
+test('generated', exe)
diff --git a/test cases/fortran/7 generated/mod1.fpp b/test cases/fortran/7 generated/mod1.fpp
new file mode 100644
index 0000000..c4decf6
--- /dev/null
+++ b/test cases/fortran/7 generated/mod1.fpp
@@ -0,0 +1,6 @@
+module mod1
+implicit none
+
+integer, parameter :: modval1 = @ONE@
+
+end module mod1
diff --git a/test cases/fortran/7 generated/mod2.fpp b/test cases/fortran/7 generated/mod2.fpp
new file mode 100644
index 0000000..78ceae4
--- /dev/null
+++ b/test cases/fortran/7 generated/mod2.fpp
@@ -0,0 +1,7 @@
+module mod2
+use mod1, only : modval1
+implicit none
+
+integer, parameter :: modval2 = @TWO@
+
+end module mod2
diff --git a/test cases/fortran/7 generated/mod3.f90 b/test cases/fortran/7 generated/mod3.f90
new file mode 100644
index 0000000..5e4b417
--- /dev/null
+++ b/test cases/fortran/7 generated/mod3.f90
@@ -0,0 +1,6 @@
+module mod3
+implicit none
+
+integer, parameter :: modval3 = 3
+
+end module mod3
diff --git a/test cases/fortran/7 generated/prog.f90 b/test cases/fortran/7 generated/prog.f90
new file mode 100644
index 0000000..6ee0bca
--- /dev/null
+++ b/test cases/fortran/7 generated/prog.f90
@@ -0,0 +1,8 @@
+program generated
+use mod2, only : modval1, modval2
+use mod3, only : modval3
+implicit none
+
+if (modval1 + modval2 + modval3 /= 6) error stop
+
+end program generated