@@ -79,12 +79,8 @@ pub const RunProtocStep = struct {
7979 include_directories : []std.Build.LazyPath ,
8080 destination_directory : std.Build.LazyPath ,
8181 generator : * std.Build.Step.Compile ,
82- protoc_owner : * std.Build ,
83- /// Optional external protoc binary. When set, skips the built-in download
84- /// mechanism and uses this artifact's emitted binary instead. Useful for
85- /// consumers (e.g. conformance tests) that already have protoc from another
86- /// dependency.
87- protoc_override : ? * std.Build.Step.Compile = null ,
82+ generator_bin : std.Build.LazyPath ,
83+ protoc_override_bin : ? std.Build.LazyPath = null ,
8884 preserve_unknown_fields : bool = false ,
8985 verbose : bool = false ,
9086
@@ -98,9 +94,9 @@ pub const RunProtocStep = struct {
9894 /// protoc step can be owned by a consumer builder while the generator
9995 /// stays owned by the zig-protobuf dependency builder.
10096 generator : ? * std.Build.Step.Compile = null ,
101- /// Optional pre-built protoc artifact . When provided, overrides the
97+ /// Optional pre-built protoc binary . When provided, overrides the
10298 /// built-in protoc download mechanism.
103- protoc : ? * std.Build.Step.Compile = null ,
99+ protoc : ? std.Build.LazyPath = null ,
104100 /// When true, every generated message preserves unknown fields during
105101 /// binary decode/encode round trips. Defaults to false.
106102 preserve_unknown_fields : bool = false ,
@@ -128,13 +124,15 @@ pub const RunProtocStep = struct {
128124 .include_directories = dupeLazyPaths (owner , options .include_directories ),
129125 .destination_directory = options .destination_directory .dupe (owner ),
130126 .generator = generator ,
131- .protoc_owner = generator .step .owner ,
132- .protoc_override = options .protoc ,
127+ // Request the emitted binaries now, at configure time, so the
128+ // Compile steps actually emit them. See `generator_bin` docs.
129+ .generator_bin = generator .getEmittedBin (),
130+ .protoc_override_bin = options .protoc ,
133131 .preserve_unknown_fields = options .preserve_unknown_fields ,
134132 };
135133
136134 self .step .dependOn (& self .generator .step );
137- if ( options . protoc ) | p | self . step . dependOn ( & p . step );
135+
138136 return self ;
139137 }
140138
@@ -166,17 +164,17 @@ pub const RunProtocStep = struct {
166164 { // run protoc
167165 var argv : std .ArrayList ([]const u8 ) = .empty ;
168166
169- const maybe_protoc_path : ? []const u8 = if (self .protoc_override ) | p |
170- p . getEmittedBin () .getPath2 (b , step )
167+ const maybe_protoc_path : ? []const u8 = if (self .protoc_override_bin ) | bin |
168+ bin .getPath2 (b , step )
171169 else
172- try ensureProtocBinaryDownloaded (self .protoc_owner , step );
170+ try ensureProtocBinaryDownloaded (self .step . owner , step );
173171
174172 if (maybe_protoc_path ) | protoc_path | {
175173 try argv .append (b .allocator , protoc_path );
176174
177175 try argv .append (b .allocator , try std .mem .concat (b .allocator , u8 , &.{
178176 "--plugin=protoc-gen-zig=" ,
179- self .generator . getEmittedBin () .getPath2 (b , step ),
177+ self .generator_bin .getPath2 (b , step ),
180178 }));
181179
182180 const zig_out = if (self .preserve_unknown_fields )
0 commit comments