diff options
| author | ruki <[email protected]> | 2022-09-27 23:53:57 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2022-09-27 23:53:57 +0800 |
| commit | a1d3d4633fcbe0d112952f5d0ea111570ce3876f (patch) | |
| tree | bbde172bd0d7b9a958e6159a3c595e5cffbcd808 | |
| parent | 89a12a21daf519d0f9d9cb5846dfe7c4835c97b5 (diff) | |
improve rule api
| -rw-r--r-- | tests/apis/clone_target/src/main.cpp | 9 | ||||
| -rw-r--r-- | tests/apis/clone_target/test.lua | 3 | ||||
| -rw-r--r-- | tests/apis/clone_target/xmake.lua | 7 | ||||
| -rw-r--r-- | tests/apis/rules_inject_deps/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/core/project/rule.lua | 5 | ||||
| -rw-r--r-- | xmake/core/project/target.lua | 4 |
6 files changed, 27 insertions, 3 deletions
diff --git a/tests/apis/clone_target/src/main.cpp b/tests/apis/clone_target/src/main.cpp new file mode 100644 index 000000000..db2361659 --- /dev/null +++ b/tests/apis/clone_target/src/main.cpp @@ -0,0 +1,9 @@ +#include <iostream> + +using namespace std; + +int main(int argc, char** argv) +{ + cout << "hello world!" << endl; + return 0; +} diff --git a/tests/apis/clone_target/test.lua b/tests/apis/clone_target/test.lua new file mode 100644 index 000000000..a4a38b0ce --- /dev/null +++ b/tests/apis/clone_target/test.lua @@ -0,0 +1,3 @@ +function main() + os.exec("xmake") +end diff --git a/tests/apis/clone_target/xmake.lua b/tests/apis/clone_target/xmake.lua new file mode 100644 index 000000000..4aa01b034 --- /dev/null +++ b/tests/apis/clone_target/xmake.lua @@ -0,0 +1,7 @@ +target("test") + set_kind("binary") + add_files("src/*.cpp") + after_load(function (target) + --target:clone() + end) + diff --git a/tests/apis/rules_inject_deps/xmake.lua b/tests/apis/rules_inject_deps/xmake.lua index 6a11192cd..cf73449bb 100644 --- a/tests/apis/rules_inject_deps/xmake.lua +++ b/tests/apis/rules_inject_deps/xmake.lua @@ -3,7 +3,7 @@ rule("cppfront") on_load(function (target) local rule = target:rule("c++.build"):clone() rule:add("deps", "cppfront", {order = true}) - target:rule_set("c++.build", rule) + target:rule_add(rule) end) on_build_file(function (target, sourcefile, opt) print("build cppfront file") diff --git a/xmake/core/project/rule.lua b/xmake/core/project/rule.lua index 52b8e9ff9..155f96754 100644 --- a/xmake/core/project/rule.lua +++ b/xmake/core/project/rule.lua @@ -89,6 +89,11 @@ function _instance:name() return self._NAME end +-- set the rule name +function _instance:name_set(name) + self._NAME = name +end + -- get the rule kind -- -- current supported kind: diff --git a/xmake/core/project/target.lua b/xmake/core/project/target.lua index 4e5f150be..f0e519384 100644 --- a/xmake/core/project/target.lua +++ b/xmake/core/project/target.lua @@ -713,9 +713,9 @@ function _instance:rule(name) end -- set rule -function _instance:rule_set(name, ruleinst) +function _instance:rule_add(r) self._RULES = self._RULES or {} - self._RULES[name] = ruleinst + self._RULES[r:name()] = r self._ORDERULES = nil end |
