diff options
| author | ruki <[email protected]> | 2020-07-25 21:25:55 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2020-07-25 21:25:55 +0800 |
| commit | 56c0819b70ee17f8f8f1f5d27d2f905ee34bb726 (patch) | |
| tree | c66b687e7cb6280066be518a927ec32be65ba366 | |
| parent | 5d7d07a9d1a2f4728a0857ff42d9a8f09b34bee2 (diff) | |
improve dlang tests and template projects
16 files changed, 71 insertions, 84 deletions
diff --git a/tests/projects/dlang/console/xmake.lua b/tests/projects/dlang/console/xmake.lua index 374a6826a..b1b8e0bfb 100644 --- a/tests/projects/dlang/console/xmake.lua +++ b/tests/projects/dlang/console/xmake.lua @@ -1,12 +1,6 @@ --- add rules add_rules("mode.debug", "mode.release") --- add target -target("console_dlang") - - -- set kind +target("test") set_kind("binary") - - -- add files add_files("src/*.d") diff --git a/tests/projects/dlang/console_with_pkgs/src/main.d b/tests/projects/dlang/console_with_pkgs/src/main.d new file mode 100644 index 000000000..524c4f94c --- /dev/null +++ b/tests/projects/dlang/console_with_pkgs/src/main.d @@ -0,0 +1,6 @@ +import std.stdio; + +void main() +{ + writeln("hello world!"); +} diff --git a/tests/projects/dlang/console_with_pkgs/xmake.lua b/tests/projects/dlang/console_with_pkgs/xmake.lua new file mode 100644 index 000000000..b1b8e0bfb --- /dev/null +++ b/tests/projects/dlang/console_with_pkgs/xmake.lua @@ -0,0 +1,6 @@ +add_rules("mode.debug", "mode.release") + +target("test") + set_kind("binary") + add_files("src/*.d") + diff --git a/tests/projects/dlang/shared_library/xmake.lua b/tests/projects/dlang/shared_library/xmake.lua index 7fa8b3b8a..9535bf1d3 100644 --- a/tests/projects/dlang/shared_library/xmake.lua +++ b/tests/projects/dlang/shared_library/xmake.lua @@ -1,34 +1,12 @@ --- add rules add_rules("mode.debug", "mode.release") --- add target target("interfaces") - - -- set kind set_kind("shared") - - -- add files add_files("src/interfaces.d") + add_includedirs("src", {public = true}) --- add target target("test") - - -- set kind set_kind("binary") - - -- add deps add_deps("interfaces") - - -- add files add_files("src/main.d") - -- add links - add_links("interfaces") - - -- add link directory - add_linkdirs("$(buildir)") - add_rpathdirs("$(buildir)") - - -- add include directory - add_includedirs("$(projectdir)/src") - diff --git a/tests/projects/dlang/static_library/xmake.lua b/tests/projects/dlang/static_library/xmake.lua index 74699bb04..273462475 100644 --- a/tests/projects/dlang/static_library/xmake.lua +++ b/tests/projects/dlang/static_library/xmake.lua @@ -1,33 +1,12 @@ --- add rules add_rules("mode.debug", "mode.release") --- add target target("interfaces") - - -- set kind set_kind("static") - - -- add files add_files("src/interfaces.d") + add_includedirs("src", {public = true}) --- add target target("test") - - -- set kind set_kind("binary") - - -- add deps add_deps("interfaces") - - -- add files add_files("src/main.d") - -- add links - add_links("interfaces") - - -- add link directory - add_linkdirs("$(buildir)") - - -- add include directory - add_includedirs("$(projectdir)/src") - diff --git a/tests/projects/go/console_with_deps/src/main.go b/tests/projects/go/console_with_pkgs/src/main.go index 194d6ac86..194d6ac86 100644 --- a/tests/projects/go/console_with_deps/src/main.go +++ b/tests/projects/go/console_with_pkgs/src/main.go diff --git a/tests/projects/go/console_with_deps/xmake.lua b/tests/projects/go/console_with_pkgs/xmake.lua index d3324d855..d3324d855 100644 --- a/tests/projects/go/console_with_deps/xmake.lua +++ b/tests/projects/go/console_with_pkgs/xmake.lua diff --git a/tests/projects/go/static_library_with_deps/src/main.go b/tests/projects/go/static_library_with_pkgs/src/main.go index f2b477453..f2b477453 100644 --- a/tests/projects/go/static_library_with_deps/src/main.go +++ b/tests/projects/go/static_library_with_pkgs/src/main.go diff --git a/tests/projects/go/static_library_with_deps/src/test.go b/tests/projects/go/static_library_with_pkgs/src/test.go index cf10523f9..cf10523f9 100644 --- a/tests/projects/go/static_library_with_deps/src/test.go +++ b/tests/projects/go/static_library_with_pkgs/src/test.go diff --git a/tests/projects/go/static_library_with_deps/src/test/add.go b/tests/projects/go/static_library_with_pkgs/src/test/add.go index b87b21138..b87b21138 100644 --- a/tests/projects/go/static_library_with_deps/src/test/add.go +++ b/tests/projects/go/static_library_with_pkgs/src/test/add.go diff --git a/tests/projects/go/static_library_with_deps/src/test/sub.go b/tests/projects/go/static_library_with_pkgs/src/test/sub.go index a24a9abb7..a24a9abb7 100644 --- a/tests/projects/go/static_library_with_deps/src/test/sub.go +++ b/tests/projects/go/static_library_with_pkgs/src/test/sub.go diff --git a/tests/projects/go/static_library_with_deps/xmake.lua b/tests/projects/go/static_library_with_pkgs/xmake.lua index 6943a29aa..6943a29aa 100644 --- a/tests/projects/go/static_library_with_deps/xmake.lua +++ b/tests/projects/go/static_library_with_pkgs/xmake.lua diff --git a/xmake/modules/detect/tools/find_dub.lua b/xmake/modules/detect/tools/find_dub.lua new file mode 100644 index 000000000..9b66795fe --- /dev/null +++ b/xmake/modules/detect/tools/find_dub.lua @@ -0,0 +1,54 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015-2020, TBOOX Open Source Group. +-- +-- @author ruki +-- @file find_dub.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find dub +-- +-- @param opt the argument options, e.g. {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local dub = find_dub() +-- local dub, version = find_dub({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "dub", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end diff --git a/xmake/templates/dlang/console/project/xmake.lua b/xmake/templates/dlang/console/project/xmake.lua index 5f522baf8..86ace289d 100644 --- a/xmake/templates/dlang/console/project/xmake.lua +++ b/xmake/templates/dlang/console/project/xmake.lua @@ -1,13 +1,7 @@ --- add modes: debug and release add_rules("mode.debug", "mode.release") --- add target target("${TARGETNAME}") - - -- set kind set_kind("binary") - - -- add files add_files("src/*.d") ${FAQ} diff --git a/xmake/templates/dlang/shared/project/xmake.lua b/xmake/templates/dlang/shared/project/xmake.lua index 23fe35a70..277b2e611 100644 --- a/xmake/templates/dlang/shared/project/xmake.lua +++ b/xmake/templates/dlang/shared/project/xmake.lua @@ -1,25 +1,13 @@ --- add modes: debug and release add_rules("mode.debug", "mode.release") --- add target target("${TARGETNAME}") - - -- set kind set_kind("shared") - - -- add files add_files("src/interfaces.d") + add_includedirs("src", {public = true}) --- add target target("${TARGETNAME}_demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add files add_files("src/main.d") ${FAQ} diff --git a/xmake/templates/dlang/static/project/xmake.lua b/xmake/templates/dlang/static/project/xmake.lua index 281c63734..ba4d99e77 100644 --- a/xmake/templates/dlang/static/project/xmake.lua +++ b/xmake/templates/dlang/static/project/xmake.lua @@ -1,25 +1,13 @@ --- add modes: debug and release add_rules("mode.debug", "mode.release") --- add target target("${TARGETNAME}") - - -- set kind set_kind("static") - - -- add files add_files("src/interfaces.d") + add_includedirs("src", {public = true}) --- add target target("${TARGETNAME}_demo") - - -- set kind set_kind("binary") - - -- add deps add_deps("${TARGETNAME}") - - -- add files add_files("src/main.d") ${FAQ} |
