summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjiangyanan <[email protected]>2025-05-08 11:40:34 +0800
committerjiangyanan <[email protected]>2025-05-08 22:48:30 +0800
commit2e9f1281f79c5447948324e564c99cd97e99f4fe (patch)
treed6ce445f8678f70057789c2f8d47b40c76a89278
parent7301a531f1581e5b22897c13c66d2704c493dbd9 (diff)
protobuf.cpp rule: custom flags, pass through to protoc
-rw-r--r--xmake/rules/protobuf/proto.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua
index bebeb3105..76b471948 100644
--- a/xmake/rules/protobuf/proto.lua
+++ b/xmake/rules/protobuf/proto.lua
@@ -108,6 +108,7 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
local autogendir
local public
local grpc_cpp_plugin
+ local proto_args
local fileconfig = target:fileconfig(sourcefile_proto)
if fileconfig then
public = fileconfig.proto_public
@@ -116,6 +117,8 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
-- @see https://github.com/xmake-io/xmake/issues/3678
autogendir = fileconfig.proto_autogendir
grpc_cpp_plugin = fileconfig.proto_grpc_cpp_plugin
+ -- custom args, pass through to protoc
+ proto_args = fileconfig.proto_args
end
local rootdir = autogendir and autogendir or path.join(target:autogendir(), "rules", "protobuf")
local filename = path.basename(sourcefile_proto) .. ".pb" .. (sourcekind == "cxx" and ".cc" or "-c.c")
@@ -143,6 +146,16 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
table.insert(protoc_args, path(sourcefile_dir, function (p) return ("--grpc_out=") .. p end))
end
+ if proto_args then
+ if type(proto_args) == "string" then
+ table.insert(protoc_args, proto_args)
+ else
+ for _, v in ipairs(proto_args) do
+ table.insert(protoc_args, v)
+ end
+ end
+ end
+
-- add commands
batchcmds:mkdir(sourcefile_dir)
batchcmds:show_progress(