diff options
| author | ruki <[email protected]> | 2019-08-29 00:29:16 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-08-28 20:55:38 +0800 |
| commit | 6f8d4b91cf019662a58f822c700d894d82a2c76d (patch) | |
| tree | 3ed6d85592e4a64427f195f6098a070dbdb48d7b /xmake/rules/c++ | |
| parent | 57d0b3900a27add2dbd81e186c7aa496ea9d369f (diff) | |
cpprules
Diffstat (limited to 'xmake/rules/c++')
| -rw-r--r-- | xmake/rules/c++/cache/xmake.lua | 46 | ||||
| -rw-r--r-- | xmake/rules/c++/pcheader/build.lua | 24 | ||||
| -rw-r--r-- | xmake/rules/c++/xmake.lua | 30 |
3 files changed, 100 insertions, 0 deletions
diff --git a/xmake/rules/c++/cache/xmake.lua b/xmake/rules/c++/cache/xmake.lua new file mode 100644 index 000000000..38cf390d3 --- /dev/null +++ b/xmake/rules/c++/cache/xmake.lua @@ -0,0 +1,46 @@ +--!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: cpp.cache +rule("cpp.cache") + + -- we attempt to use ccache now + -- maybe we will implement cross-platform cache in the future + before_load(function (target) + + -- imports + import("lib.detect.find_tool") + + -- find ccache + local ccache = target:data("cpp.ccache") + if not ccache and config.get("ccache") then + ccache = find_tool("ccache") + target:data_set("cpp.ccache", ccache) + end + + -- add the prefix information of building object + -- + -- e.g. + -- [ 0%]: ccache compiling.release src/xxx.c + -- + if ccache then + target:data_set("build.object.prefix", "ccache") + end + end) diff --git a/xmake/rules/c++/pcheader/build.lua b/xmake/rules/c++/pcheader/build.lua new file mode 100644 index 000000000..cd6929681 --- /dev/null +++ b/xmake/rules/c++/pcheader/build.lua @@ -0,0 +1,24 @@ +--!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 build.lua +-- + +-- build the precompiled header +function (target) + -- TODO +end diff --git a/xmake/rules/c++/xmake.lua b/xmake/rules/c++/xmake.lua new file mode 100644 index 000000000..3105d69dc --- /dev/null +++ b/xmake/rules/c++/xmake.lua @@ -0,0 +1,30 @@ +--!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: cpp.pcheader +rule("cpp.pcheader") + add_deps("cpp.cache") + before_build(function (target, opt) + import("pcheader.build")(target, opt) + end) + +-- define rule: cpp +rule("cpp") + add_deps("cpp.pcheader", "cpp.cache") |
