From 2e9f1281f79c5447948324e564c99cd97e99f4fe Mon Sep 17 00:00:00 2001 From: jiangyanan Date: Thu, 8 May 2025 11:40:34 +0800 Subject: protobuf.cpp rule: custom flags, pass through to protoc --- xmake/rules/protobuf/proto.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) 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( -- cgit v1.3.1 From 82e14aa3b67bec5f97c9100f4d5c1e63510423b6 Mon Sep 17 00:00:00 2001 From: jiangyanan Date: Thu, 8 May 2025 13:43:31 +0800 Subject: rename proto_flags --- xmake/rules/protobuf/proto.lua | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index 76b471948..68f9da886 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -108,7 +108,7 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt) local autogendir local public local grpc_cpp_plugin - local proto_args + local proto_flags local fileconfig = target:fileconfig(sourcefile_proto) if fileconfig then public = fileconfig.proto_public @@ -118,7 +118,7 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt) autogendir = fileconfig.proto_autogendir grpc_cpp_plugin = fileconfig.proto_grpc_cpp_plugin -- custom args, pass through to protoc - proto_args = fileconfig.proto_args + proto_flags = fileconfig.proto_flags 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") @@ -146,13 +146,11 @@ 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) + if proto_flags then + if type(proto_flags) == "string" then + table.insert(protoc_args, proto_flags) else - for _, v in ipairs(proto_args) do - table.insert(protoc_args, v) - end + table.join2(protoc_args, proto_flags) end end -- cgit v1.3.1 From 6ee4c9b436c94ed8827d63e5a4e3cd91f9d4ad3c Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 May 2025 21:43:44 +0800 Subject: Update proto.lua --- xmake/rules/protobuf/proto.lua | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index 68f9da886..2649a0586 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -117,7 +117,7 @@ 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 + -- custom flags, pass through to protoc proto_flags = fileconfig.proto_flags end local rootdir = autogendir and autogendir or path.join(target:autogendir(), "rules", "protobuf") @@ -147,11 +147,7 @@ function buildcmd_pfile(target, batchcmds, sourcefile_proto, sourcekind, opt) end if proto_flags then - if type(proto_flags) == "string" then - table.insert(protoc_args, proto_flags) - else - table.join2(protoc_args, proto_flags) - end + table.join2(protoc_args, proto_flags) end -- add commands -- cgit v1.3.1