From fa198c5925c5faf00db7946a31db4e9fc611dc91 Mon Sep 17 00:00:00 2001 From: ruki Date: Tue, 27 Sep 2022 23:03:28 +0800 Subject: improve rule test --- tests/apis/rules_inject_deps/src/hello.mpp | 10 ---------- tests/apis/rules_inject_deps/src/main.cpp | 9 ++++++--- tests/apis/rules_inject_deps/test.lua | 3 +++ tests/apis/rules_inject_deps/xmake.lua | 16 ++++++++++------ 4 files changed, 19 insertions(+), 19 deletions(-) delete mode 100644 tests/apis/rules_inject_deps/src/hello.mpp create mode 100644 tests/apis/rules_inject_deps/test.lua diff --git a/tests/apis/rules_inject_deps/src/hello.mpp b/tests/apis/rules_inject_deps/src/hello.mpp deleted file mode 100644 index 124bd72bc..000000000 --- a/tests/apis/rules_inject_deps/src/hello.mpp +++ /dev/null @@ -1,10 +0,0 @@ -module; -#include - -export module hello; - -export namespace hello { - void say(const char* str) { - printf("%s\n", str); - } -} diff --git a/tests/apis/rules_inject_deps/src/main.cpp b/tests/apis/rules_inject_deps/src/main.cpp index 1e5cc698f..db2361659 100644 --- a/tests/apis/rules_inject_deps/src/main.cpp +++ b/tests/apis/rules_inject_deps/src/main.cpp @@ -1,6 +1,9 @@ -import hello; +#include -int main() { - hello::say("hello module!"); +using namespace std; + +int main(int argc, char** argv) +{ + cout << "hello world!" << endl; return 0; } diff --git a/tests/apis/rules_inject_deps/test.lua b/tests/apis/rules_inject_deps/test.lua new file mode 100644 index 000000000..a750f2cf4 --- /dev/null +++ b/tests/apis/rules_inject_deps/test.lua @@ -0,0 +1,3 @@ +function main() + os.exec("xmake -j1") +end diff --git a/tests/apis/rules_inject_deps/xmake.lua b/tests/apis/rules_inject_deps/xmake.lua index 18a8fdeaa..6a11192cd 100644 --- a/tests/apis/rules_inject_deps/xmake.lua +++ b/tests/apis/rules_inject_deps/xmake.lua @@ -1,19 +1,23 @@ rule("cppfront") set_extensions(".cpp2") on_load(function (target) - local rule = target:rule("c++.build.modules.builder"):clone() + local rule = target:rule("c++.build"):clone() rule:add("deps", "cppfront", {order = true}) - target:rule_set("c++.build.modules.builder", rule) + target:rule_set("c++.build", rule) end) - before_build_files(function (target, sourcebatch, opt) - print("build cppfront files") + on_build_file(function (target, sourcefile, opt) + print("build cppfront file") + local objectfile = target:objectfile(sourcefile:gsub("cpp2", "cpp")) + assert(not os.isfile(objectfile), "invalid rule order!") end) target("test") set_kind("binary") add_rules("cppfront") - set_languages("c++20") add_files("src/*.cpp") - add_files("src/*.mpp") add_files("src/*.cpp2") + before_build_file(function (target, sourcefile, opt) + local objectfile = target:objectfile(sourcefile) + os.tryrm(objectfile) + end) -- cgit v1.3.1