sourcegraph/dev/proto.bzl
Jean-Hadrien Chabran 9f07628311
fix: gazelle and proto generation (continuation of #49547) (#49713)
This is a continuation of
https://github.com/sourcegraph/sourcegraph/pull/49547, updated to the
recent main.

~Currently in draft until we fix the rust issues.~ Fixed 

See https://github.com/sourcegraph/sourcegraph/issues/50032 for more
context on how to handle the generated files.

## Test plan

<!-- All pull requests REQUIRE a test plan:
https://docs.sourcegraph.com/dev/background-information/testing_principles
-->

CI

---------

Signed-off-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
Co-authored-by: Thulio Ferraz Assis <3149049+f0rmiga@users.noreply.github.com>
2023-04-11 11:36:45 +02:00

28 lines
853 B
Python

"""This module contains definitions for dealing with stubs in the source tree.
"""
load("@aspect_bazel_lib//lib:write_source_files.bzl", "write_source_files")
load("@aspect_bazel_lib//lib:copy_to_directory.bzl", "copy_to_directory")
load("@aspect_bazel_lib//lib:directory_path.bzl", "make_directory_path")
def write_proto_stubs_to_source(name, target, output_files):
native.filegroup(
name = name,
srcs = [target],
output_group = "go_generated_srcs",
)
copy_to_directory(
name = name + "_flattened",
srcs = [name],
root_paths = ["**"],
)
write_source_files(
name = "write_" + name,
files = {
output_file: make_directory_path(output_file + "_directory_path", name + "_flattened", output_file)
for output_file in output_files
},
)