From bf3b4234d48cd8a9ece936886d48f71f66db8a08 Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:05:50 +0200 Subject: Fix proto grpc build on windows --- xmake/rules/protobuf/proto.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index fee266087..561526ef1 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -52,7 +52,7 @@ end -- get grpc_cpp_plugin function _get_grpc_cpp_plugin(target, sourcekind) assert(sourcekind == "cxx", "grpc_cpp_plugin only support c++") - local grpc_cpp_plugin = find_tool("grpc_cpp_plugin", {norun = true}) + local grpc_cpp_plugin = find_tool("grpc_cpp_plugin", {norun = true, force = true, envs = target:pkgenvs()}) return assert(grpc_cpp_plugin and grpc_cpp_plugin.program, "grpc_cpp_plugin not found!") end @@ -143,7 +143,8 @@ function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind) } if grpc_cpp_plugin then - table.insert(protoc_args, "--plugin=protoc-gen-grpc=" .. grpc_cpp_plugin_bin) + local exe = is_plat("windows") and ".exe" or "" + table.insert(protoc_args, "--plugin=protoc-gen-grpc=" .. grpc_cpp_plugin_bin .. exe) table.insert(protoc_args, path(sourcefile_dir, function (p) return ("--grpc_out=") .. p end)) end -- cgit v1.3.1 From 27be8483199557b28424805d8fa17fa98f964175 Mon Sep 17 00:00:00 2001 From: A2va <49582555+A2va@users.noreply.github.com> Date: Fri, 13 Oct 2023 09:46:39 +0200 Subject: Improve variable name --- xmake/rules/protobuf/proto.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/rules/protobuf/proto.lua b/xmake/rules/protobuf/proto.lua index 561526ef1..1124899c0 100644 --- a/xmake/rules/protobuf/proto.lua +++ b/xmake/rules/protobuf/proto.lua @@ -143,8 +143,8 @@ function buildcmd(target, batchcmds, sourcefile_proto, opt, sourcekind) } if grpc_cpp_plugin then - local exe = is_plat("windows") and ".exe" or "" - table.insert(protoc_args, "--plugin=protoc-gen-grpc=" .. grpc_cpp_plugin_bin .. exe) + local extension = target:is_plat("windows") and ".exe" or "" + table.insert(protoc_args, "--plugin=protoc-gen-grpc=" .. grpc_cpp_plugin_bin .. extension) table.insert(protoc_args, path(sourcefile_dir, function (p) return ("--grpc_out=") .. p end)) end -- cgit v1.3.1