github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/example/golden/testdata/proto_repository/README.md (about) 1 # proto_repository 2 3 This test demonstrates the use of proto_repository and go language generation. 4 A few notes about the test: 5 6 - The files are used in both "//example/golden:golden_test" (a golden test) and 7 "//example/golden:proto_repository_test" (go_bazel_test). 8 - The proto mode is "file", so the proto_library rule for "app.proto" has two 9 dependencies: one for annotations.proto and another for field_behavior.proto. 10 Yet, the proto_go_library has only a single dependency on 11 annotations_go_proto. This is because go sources that share the same 12 "importpath" must be compiled together under a single go_library rule. 13 Therefore, there is logic that merges proto_go_library rules when they share 14 the same importpath. The relationship of annotations.proto and 15 field_behavior.proto tests this merge behavior. 16 17 ## //example/golden:golden_test (golden test) 18 19 - Only the ".gazelle.args and "imports.csv" file is used in the golden test. 20 This simulates the existence of the "@googleapis" repo and the imports.csv 21 file file that it would produce. Only the two relevant entries of the file 22 are included for deps resolution of the proto_library and proto_go_library 23 rules. 24 25 ## //example/golden:proto_repository_test" (go_bazel_test) 26 27 - This runs "bazel build ..." and then "bazel run //:gazelle", "bazel build 28 //...". 29 - The effective WORKSPACE file is a concatenation of "prebuilt.WORKSPACE" and 30 the "WORKSPACE" file here. 31 - The order of loads in that effective workspace are important, namely we need 32 to load newer versions of @org_golang_google_grpc before rules_go or gazelle 33 try and do that. 34 - proto file mode is used. 35 - reresolve_known_proto_imports = True is needed to rewrite labels that would normally 36 be in the "go_googleapis" and "com_google_protobuf" external workspace.