diff options
author | Jussi Pakkanen <jpakkane@gmail.com> | 2015-08-23 20:07:21 +0300 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2015-08-23 20:17:37 +0300 |
commit | 5467b7d58b310c3dab975ea924de4e28fec884fc (patch) | |
tree | a32c9bfbf029ca852121be587a9f70ba21985fe1 | |
parent | 7c6e99149bc742ba0e98521907a690a526bb894c (diff) | |
download | meson-5467b7d58b310c3dab975ea924de4e28fec884fc.zip meson-5467b7d58b310c3dab975ea924de4e28fec884fc.tar.gz meson-5467b7d58b310c3dab975ea924de4e28fec884fc.tar.bz2 |
Made Fortran static libraries work. Closes #237.
-rw-r--r-- | backends.py | 6 | ||||
-rw-r--r-- | ninjabackend.py | 13 | ||||
-rw-r--r-- | test cases/fortran/5 static/main.f95 | 6 | ||||
-rw-r--r-- | test cases/fortran/5 static/meson.build | 5 | ||||
-rw-r--r-- | test cases/fortran/5 static/static_hello.f95 | 17 |
5 files changed, 47 insertions, 0 deletions
diff --git a/backends.py b/backends.py index d3c3157..47b39d1 100644 --- a/backends.py +++ b/backends.py @@ -220,6 +220,12 @@ class Backend(): if isinstance(target, build.Executable): commands += dep.get_exe_args() + # Fortran rquires extra include directives. + if compiler.language == 'fortran': + for lt in target.link_targets: + priv_dir = os.path.join(lt.subdir, lt.get_basename() + lt.type_suffix()) + incflag = compiler.get_include_args(priv_dir) + commands += incflag return commands def build_target_link_arguments(self, compiler, deps): diff --git a/ninjabackend.py b/ninjabackend.py index 6f10e38..b0419de 100644 --- a/ninjabackend.py +++ b/ninjabackend.py @@ -1225,11 +1225,24 @@ rule FORTRAN_DEP_HACK element.add_orderdep(d) element.add_orderdep(pch_dep) element.add_orderdep(extra_orderdeps) + for i in self.get_fortran_orderdeps(target, compiler): + element.add_orderdep(i) element.add_item('DEPFILE', dep_file) element.add_item('ARGS', commands) element.write(outfile) return rel_obj + # Fortran is a bit weird (again). When you link against a library, just compiling a source file + # requires the mod files that are output when single files are built. To do this right we would need to + # scan all inputs and write out explicit deps for each file. That is stoo slow and too much effort so + # instead just have an ordered dependendy on the library. This ensures all reqquired mod files are created. + # The real deps are then detected via dep file generation from the compiler. This breaks on compilers that + # produce incorrect dep files but such is life. + def get_fortran_orderdeps(self, target, compiler): + if compiler.language != 'fortran': + return [] + return [os.path.join(lt.subdir, lt.filename) for lt in target.link_targets] + def generate_msvc_pch_command(self, target, compiler, pch): if len(pch) != 2: raise RuntimeError('MSVC requires one header and one source to produce precompiled headers.') diff --git a/test cases/fortran/5 static/main.f95 b/test cases/fortran/5 static/main.f95 new file mode 100644 index 0000000..dc6454c --- /dev/null +++ b/test cases/fortran/5 static/main.f95 @@ -0,0 +1,6 @@ +program hello + use static_hello + implicit none + + call static_say_hello() +end program hello diff --git a/test cases/fortran/5 static/meson.build b/test cases/fortran/5 static/meson.build new file mode 100644 index 0000000..d6f922b --- /dev/null +++ b/test cases/fortran/5 static/meson.build @@ -0,0 +1,5 @@ +project('try-static-library', 'fortran') + +static_hello = static_library('static_hello', 'static_hello.f95') + +executable('test_exe', 'main.f95', link_with : static_hello) diff --git a/test cases/fortran/5 static/static_hello.f95 b/test cases/fortran/5 static/static_hello.f95 new file mode 100644 index 0000000..63415b0 --- /dev/null +++ b/test cases/fortran/5 static/static_hello.f95 @@ -0,0 +1,17 @@ +module static_hello + implicit none + + private + public :: static_say_hello + + interface static_say_hello + module procedure say_hello + end interface static_say_hello + +contains + + subroutine say_hello + print *, "Static library called." + end subroutine say_hello + +end module static_hello |