diff options
| author | ruki <[email protected]> | 2019-06-30 13:27:31 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-06-30 13:27:31 +0800 |
| commit | ff067fda68bf431a4d46ce0149d425c7665aa2e7 (patch) | |
| tree | f92d697dcfdafdd4e078b379aef73816b5b2b3a7 /xmake/rules/protobuf/xmake.lua | |
| parent | 782068ccf675fb9846708b549b2ef3888701472b (diff) | |
add protobuf rules
Diffstat (limited to 'xmake/rules/protobuf/xmake.lua')
| -rw-r--r-- | xmake/rules/protobuf/xmake.lua | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/xmake/rules/protobuf/xmake.lua b/xmake/rules/protobuf/xmake.lua new file mode 100644 index 000000000..3907a4c2d --- /dev/null +++ b/xmake/rules/protobuf/xmake.lua @@ -0,0 +1,66 @@ +--!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: protobuf-cpp +rule("protobuf.env") + + -- load protoc + before_load(function (target) + import("lib.detect.find_tool") + local protoc = target:data("protobuf.protoc") + if not protoc then + protoc = find_tool("protoc") + if protoc and protoc.program then + target:data_set("protobuf.protoc", protoc.program) + else + raise("protoc not found!") + end + end + end) + +-- define rule: protobuf.cpp +rule("protobuf.cpp") + + -- add deps + add_deps("protobuf.env") + + -- set extension + set_extensions(".proto") + + -- build protobuf file + on_build_file(function (target, sourcefile_proto, opt) + import("proto")(target, "cxx", sourcefile_proto, opt) + end) + + +-- define rule: protobuf.c +rule("protobuf.c") + + -- add deps + add_deps("protobuf.env") + + -- set extension + set_extensions(".proto") + + -- build protobuf file + on_build_file(function (target, sourcefile_proto, opt) + import("proto")(target, "cc", sourcefile_proto, opt) + end) |
