Lines Matching +full:- +full:- +full:proto +full:- +full:path
7 # http://www.apache.org/licenses/LICENSE-2.0
16 load("@rules_proto//proto:defs.bzl", "ProtoInfo")
18 _PROTO_EXTENSION = ".proto"
45 # We include both the alias path and the underlying path to be resilient to
72 return proto_filename[:-len(_PROTO_EXTENSION)]
75 """Calculates the name of a generated file for a protobuf path.
77 For example, "examples/protos/helloworld.proto" might map to
81 proto_path: The path to the .proto file.
91 """Returns the include directory path for the source_file.
96 The returned directory path can be used as the "--proto_path=" argument
100 source_file: A proto file.
103 The include directory path for the source_file.
105 directory = source_file.path
109 root, relative = source_file.path.split(_VIRTUAL_IMPORTS, 2)
113 if not source_file.is_source and directory.startswith(source_file.root.path):
114 prefix_len = len(source_file.root.path) + 1
121 return source_file.root.path if source_file.root.path else "."
150 "--plugin=protoc-gen-{plugin_name}={plugin_path}".format(
152 plugin_path = plugin.path,
154 "--{plugin_name}_out={dir_out}".format(
163 @repo//foo/bar:sub/dir/file.proto => 'external/repo/foo/bar/'
164 //foo/bar:sub/dir/file.proto => 'foo/bar/'
165 //:sub/dir/file.proto => ''
167 That is, the prefix can be removed from a file's full path to
184 """Copies a proto file to the appropriate location if necessary.
187 label: The label of the rule using the .proto file.
189 source_file: The original .proto file.
192 The original proto file OR a new file in the staged location.
202 copied_proto = context.actions.declare_file(source_file.path[len(prefix):])
206 command = "cp {} {}".format(source_file.path, copied_proto.path),
212 """Copies proto files to the appropriate location.
239 genfiles_dir_path: The path to the genfiles directory.
245 for proto in protos:
247 if is_in_virtual_imports(proto):
248 incl_directory = get_include_directory(proto)
249 if proto.path.startswith(incl_directory):
251 elif proto.path.startswith(genfiles_dir_path):
254 arguments.append(proto.path[strip_prefix_len:])
273 for proto in protos:
274 if not is_in_virtual_imports(proto):
275 prefix = _make_prefix(proto.owner)
276 full_prefix = context.genfiles_dir.path + "/" + prefix
277 if proto.path.startswith(full_prefix):
278 out_file_paths.append(proto.path[len(full_prefix):])
279 elif proto.path.startswith(prefix):
280 out_file_paths.append(proto.path[len(prefix):])
282 out_file_paths.append(proto.path[proto.path.index(_VIRTUAL_IMPORTS) + 1:])
295 """Returns the value to supply to the --<lang>_out= protoc flag.
297 The result is based on the input source proto files and current context.
303 The value of --<lang>_out= argument.
306 for proto in protos:
307 if is_in_virtual_imports(proto):
310 fail("Proto sources must be either all virtual imports or all real")
317 path = out_dir,
321 out_dir = context.genfiles_dir.path
325 return struct(path = out_dir, import_path = None)
335 source_file: A proto file.
341 return not source_file.is_source and virtual_folder in source_file.path