diff options
| author | ruki <[email protected]> | 2019-09-06 00:13:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-09-05 19:21:07 +0800 |
| commit | 5f3ad152caf5509dd6e8a8249872c8969be1d49f (patch) | |
| tree | 7bf28a9ce47129605e7b7c52e90e284106adad89 | |
| parent | a8061f2bed770641ea7137e6211aea50bbe6abd9 (diff) | |
add cppmodule rules and tests
| -rw-r--r-- | tests/projects/c++/modules/hello/src/hello.mpp | 10 | ||||
| -rw-r--r-- | tests/projects/c++/modules/hello/src/main.cpp | 6 | ||||
| -rw-r--r-- | tests/projects/c++/modules/hello/xmake.lua | 6 | ||||
| -rw-r--r-- | xmake/languages/c++/xmake.lua | 2 | ||||
| -rw-r--r-- | xmake/rules/c++/modules/xmake.lua | 27 | ||||
| -rw-r--r-- | xmake/rules/c++/xmake.lua | 14 | ||||
| -rw-r--r-- | xmake/rules/objc++/xmake.lua | 2 |
7 files changed, 58 insertions, 9 deletions
diff --git a/tests/projects/c++/modules/hello/src/hello.mpp b/tests/projects/c++/modules/hello/src/hello.mpp new file mode 100644 index 000000000..fbd7fd6ad --- /dev/null +++ b/tests/projects/c++/modules/hello/src/hello.mpp @@ -0,0 +1,10 @@ +// module; +#include <cstdio> +export module hello; +using namespace std; + +export namespace hello { + void say(const char* str) { + printf("%s\n", str); + } +}
\ No newline at end of file diff --git a/tests/projects/c++/modules/hello/src/main.cpp b/tests/projects/c++/modules/hello/src/main.cpp new file mode 100644 index 000000000..175b4d348 --- /dev/null +++ b/tests/projects/c++/modules/hello/src/main.cpp @@ -0,0 +1,6 @@ +import hello; + +int main() { + hello::say("hello module!"); + return 0; +}
\ No newline at end of file diff --git a/tests/projects/c++/modules/hello/xmake.lua b/tests/projects/c++/modules/hello/xmake.lua new file mode 100644 index 000000000..5d94b5d15 --- /dev/null +++ b/tests/projects/c++/modules/hello/xmake.lua @@ -0,0 +1,6 @@ +target("hello") + set_kind("binary") + add_rules("c++.build.modules") + add_files("src/*.cpp", "src/*.mpp") + + diff --git a/xmake/languages/c++/xmake.lua b/xmake/languages/c++/xmake.lua index 93f0eb528..97c3bdca5 100644 --- a/xmake/languages/c++/xmake.lua +++ b/xmake/languages/c++/xmake.lua @@ -40,7 +40,7 @@ language("c++") set_mixingkinds("cc", "cxx", "as", "mrc") -- add rules - add_rules("cpp") + add_rules("c++") -- on load on_load("load") diff --git a/xmake/rules/c++/modules/xmake.lua b/xmake/rules/c++/modules/xmake.lua new file mode 100644 index 000000000..26421103b --- /dev/null +++ b/xmake/rules/c++/modules/xmake.lua @@ -0,0 +1,27 @@ +--!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 - 2019, TBOOX Open Source Group. +-- +-- @author ruki +-- @file xmake.lua +-- + +-- define rule: c++.build.modules +rule("c++.build.modules") + set_extensions(".mpp") + before_build_files(function (target, sourcebatch, opt) + print(sourcebatch) + end) + diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua index 1330fbfca..32bd19f5b 100644 --- a/xmake/rules/c++/xmake.lua +++ b/xmake/rules/c++/xmake.lua @@ -32,20 +32,20 @@ rule("c.build") import("private.action.build.object")(target, sourcebatch, opt) end) --- define rule: cpp.build.pcheader -rule("cpp.build.pcheader") +-- define rule: c++.build.pcheader +rule("c++.build.pcheader") before_build(function (target, opt) import("private.action.build.pcheader")(target, "cxx", opt) end) --- define rule: cpp.build -rule("cpp.build") +-- define rule: c++.build +rule("c++.build") set_extensions(".cpp", ".cc", ".cxx") - add_deps("cpp.build.pcheader") + add_deps("c++.build.pcheader") on_build_files(function (target, sourcebatch, opt) import("private.action.build.object")(target, sourcebatch, opt) end) -- define rule: cpp -rule("cpp") - add_deps("cpp.build", "c.build", "utils.merge.object", "utils.merge.archive") +rule("c++") + add_deps("c++.build", "c.build", "utils.merge.object", "utils.merge.archive") diff --git a/xmake/rules/objc++/xmake.lua b/xmake/rules/objc++/xmake.lua index 986e3d1a3..e666d8b38 100644 --- a/xmake/rules/objc++/xmake.lua +++ b/xmake/rules/objc++/xmake.lua @@ -29,7 +29,7 @@ rule("objc.build") -- define rule: objc++.build rule("objc++.build") set_extensions(".mm") - add_deps("cpp.build.pcheader") + add_deps("c++.build.pcheader") on_build_files(function (target, sourcebatch, opt) import("private.action.build.object")(target, sourcebatch, opt) end) |
