Skip to content

Commit a3df7af

Browse files
authored
Merge pull request #6405 from jiangyanan224/pb_rule
rule protobuf.cpp add custom args, pass through to protoc. Resolves #6398
2 parents 93c6fb1 + 6ee4c9b commit a3df7af

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

xmake/rules/protobuf/proto.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
108108
local autogendir
109109
local public
110110
local grpc_cpp_plugin
111+
local proto_flags
111112
local fileconfig = target:fileconfig(sourcefile_proto)
112113
if fileconfig then
113114
public = fileconfig.proto_public
@@ -116,6 +117,8 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
116117
-- @see https://github.com/xmake-io/xmake/issues/3678
117118
autogendir = fileconfig.proto_autogendir
118119
grpc_cpp_plugin = fileconfig.proto_grpc_cpp_plugin
120+
-- custom flags, pass through to protoc
121+
proto_flags = fileconfig.proto_flags
119122
end
120123
local rootdir = autogendir and autogendir or path.join(target:autogendir(), "rules", "protobuf")
121124
local filename = path.basename(sourcefile_proto) .. ".pb" .. (sourcekind == "cxx" and ".cc" or "-c.c")
@@ -143,6 +146,10 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt)
143146
table.insert(protoc_args, path(sourcefile_dir, function (p) return ("--grpc_out=") .. p end))
144147
end
145148

149+
if proto_flags then
150+
table.join2(protoc_args, proto_flags)
151+
end
152+
146153
-- add commands
147154
batchcmds:mkdir(sourcefile_dir)
148155
batchcmds:show_progress(

0 commit comments

Comments
 (0)