summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-07-05 10:32:38 +0800
committerruki <[email protected]>2020-07-05 10:34:37 +0800
commitc14bfc6fa4e30b2a2af6cb7500bd7b7c16896472 (patch)
treed5d682e10937cdebc6fa9285e1e2978a4f17ec21
parent22229713a006394d0bb5d70865850bad60898f00 (diff)
add fortran static library tests
-rw-r--r--.gitignore3
-rw-r--r--tests/projects/c++/console/xmake.lua9
-rw-r--r--tests/projects/c/console/xmake.lua10
-rw-r--r--tests/projects/fortran/static_library/src/main.f905
-rw-r--r--tests/projects/fortran/static_library/src/test.f908
-rw-r--r--tests/projects/fortran/static_library/xmake.lua11
-rw-r--r--xmake/languages/fortran/xmake.lua2
-rw-r--r--xmake/rules/fortran/xmake.lua4
-rw-r--r--xmake/toolchains/fortran/xmake.lua1
9 files changed, 34 insertions, 19 deletions
diff --git a/.gitignore b/.gitignore
index 00aa14163..955e049f7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,4 +31,7 @@ winenv/
/core/**/*.b
/core/**/*.a
+# for fortran
+/tests/**/*.mod
+
!/xmake/actions/build/
diff --git a/tests/projects/c++/console/xmake.lua b/tests/projects/c++/console/xmake.lua
index 9ab7f42ca..35b9bde70 100644
--- a/tests/projects/c++/console/xmake.lua
+++ b/tests/projects/c++/console/xmake.lua
@@ -1,12 +1,5 @@
--- add rules
add_rules("mode.debug", "mode.release")
-
--- add target
-target("console_c++")
-
- -- set kind
+target("test")
set_kind("binary")
-
- -- add files
add_files("src/*.cpp")
diff --git a/tests/projects/c/console/xmake.lua b/tests/projects/c/console/xmake.lua
index 547d0f101..405285a8f 100644
--- a/tests/projects/c/console/xmake.lua
+++ b/tests/projects/c/console/xmake.lua
@@ -1,13 +1,5 @@
-
--- add modes: debug and release
add_rules("mode.debug", "mode.release")
-
--- add target
-target("console_c")
-
- -- set kind
+target("test")
set_kind("binary")
-
- -- add files
add_files("src/*.c")
diff --git a/tests/projects/fortran/static_library/src/main.f90 b/tests/projects/fortran/static_library/src/main.f90
new file mode 100644
index 000000000..9adea3e26
--- /dev/null
+++ b/tests/projects/fortran/static_library/src/main.f90
@@ -0,0 +1,5 @@
+program hello
+ use test, only: print_hello
+ implicit none (type, external)
+ call print_hello()
+end program hello
diff --git a/tests/projects/fortran/static_library/src/test.f90 b/tests/projects/fortran/static_library/src/test.f90
new file mode 100644
index 000000000..b1e97a36c
--- /dev/null
+++ b/tests/projects/fortran/static_library/src/test.f90
@@ -0,0 +1,8 @@
+module test
+ implicit none (type, external)
+
+contains
+ subroutine print_hello()
+ print *, "Hello World!"
+ end subroutine print_hello
+end module test
diff --git a/tests/projects/fortran/static_library/xmake.lua b/tests/projects/fortran/static_library/xmake.lua
new file mode 100644
index 000000000..694755de5
--- /dev/null
+++ b/tests/projects/fortran/static_library/xmake.lua
@@ -0,0 +1,11 @@
+add_rules("mode.debug", "mode.release")
+
+target("testlib")
+ set_kind("static")
+ add_files("src/test.f90")
+
+target("test")
+ set_kind("binary")
+ add_deps("testlib")
+ add_files("src/main.f90")
+
diff --git a/xmake/languages/fortran/xmake.lua b/xmake/languages/fortran/xmake.lua
index 8ae47ce38..3520a3621 100644
--- a/xmake/languages/fortran/xmake.lua
+++ b/xmake/languages/fortran/xmake.lua
@@ -28,7 +28,7 @@ language("fortran")
set_sourceflags {fc = "fcflags"}
-- set target kinds
- set_targetkinds {binary = "fcld", static = "fcar", shared = "fcsh"}
+ set_targetkinds {binary = "fcld", static = "ar", shared = "fcsh"}
-- set target flags
set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"}
diff --git a/xmake/rules/fortran/xmake.lua b/xmake/rules/fortran/xmake.lua
index c4b630be7..1e694cfd8 100644
--- a/xmake/rules/fortran/xmake.lua
+++ b/xmake/rules/fortran/xmake.lua
@@ -21,6 +21,10 @@
-- define rule: fortran.build
rule("fortran.build")
set_sourcekinds("fc")
+ on_load(function (target)
+ -- we disable to build across targets in parallel, because the source files may depend on other target modules
+ target:set("policy", "build.across_targets_in_parallel", false)
+ end)
on_build_files("private.action.build.object", {batch = true})
-- define rule: fortran
diff --git a/xmake/toolchains/fortran/xmake.lua b/xmake/toolchains/fortran/xmake.lua
index 0b3cb896f..d00d6ce24 100644
--- a/xmake/toolchains/fortran/xmake.lua
+++ b/xmake/toolchains/fortran/xmake.lua
@@ -29,7 +29,6 @@ toolchain("fortran")
set_toolset("fc", "$(env FC)", "gfortran")
set_toolset("fcld", "$(env FC)", "gfortran")
set_toolset("fcsh", "$(env FC)", "gfortran")
- set_toolset("fcar", "$(env FC)", "gfortran")
-- on load
on_load(function (toolchain)