Skip to content

Commit fbfdfbf

Browse files
committed
use specialized protoc invocation
1 parent 44c839c commit fbfdfbf

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/generate.jl

+15-1
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,20 @@ function get_generated_method_table(s::String)
118118
T
119119
end
120120

121+
# Defining a local protoc to avoid issues with ProtoBuf.protoc,
122+
# wherein it was using the form `protoc_jll.protoc() do .. end`
123+
# which is now deprecated and is causing errors in code generation.
124+
function grpc_protoc(args=``)
125+
plugin_dir = abspath(joinpath(dirname(pathof(ProtoBuf)), "..", "plugin"))
126+
plugin = joinpath(plugin_dir, Sys.iswindows() ? "protoc-gen-julia_win.bat" : "protoc-gen-julia")
127+
128+
protoc_path = ProtoBuf.protoc_jll.protoc()
129+
ENV= copy(ENV)
130+
ENV′["PATH"] = string(plugin_dir, Sys.iswindows() ? ";" : ":", ENV′["PATH"])
131+
ENV′["JULIA"] = joinpath(Sys.BINDIR, Base.julia_exename())
132+
run(setenv(`$protoc_path --plugin=protoc-gen-julia=$plugin $args`, ENV′))
133+
end
134+
121135
"""
122136
generate(proto::String; outdir::String=pwd())
123137
@@ -149,7 +163,7 @@ function generate(proto::String; outdir::String=pwd(), includes::Vector{String}=
149163
bindir = Sys.BINDIR
150164
pathenv = string(ENV["PATH"], Sys.iswindows() ? ";" : ":", bindir)
151165
withenv("PATH"=>pathenv) do
152-
ProtoBuf.protoc(`$includeflag --julia_out=$outdir $proto`)
166+
grpc_protoc(`$includeflag --julia_out=$outdir $proto`)
153167
end
154168

155169
# include the generated code and detect service method names

0 commit comments

Comments
 (0)