-
Notifications
You must be signed in to change notification settings - Fork 152
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the strip prefix logic for python libraries (#361)
* Fix imports directive for py_library when using stripPrefix Signed-off-by: Vihang Mehta <vihang@gimletlabs.ai> * Tests Signed-off-by: Vihang Mehta <vihang@gimletlabs.ai> --------- Signed-off-by: Vihang Mehta <vihang@gimletlabs.ai>
- Loading branch information
Showing
5 changed files
with
48 additions
and
4 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
example/golden/testdata/strip_import_prefix/module_lib/util/nested/prefix/BUILD.in
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# gazelle:proto_strip_import_prefix /module_lib/util/nested |
28 changes: 28 additions & 0 deletions
28
example/golden/testdata/strip_import_prefix/module_lib/util/nested/prefix/BUILD.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
load("@rules_proto//proto:defs.bzl", "proto_library") | ||
load("@build_stack_rules_proto//rules/py:proto_py_library.bzl", "proto_py_library") | ||
load("@build_stack_rules_proto//rules:proto_compile.bzl", "proto_compile") | ||
|
||
# gazelle:proto_strip_import_prefix /module_lib/util/nested | ||
|
||
proto_library( | ||
name = "prefix_test_proto", | ||
srcs = ["test.proto"], | ||
strip_import_prefix = "/module_lib/util/nested", | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
proto_compile( | ||
name = "prefix_test_python_compile", | ||
output_mappings = ["test_pb2.py=/prefix/test_pb2.py"], | ||
outputs = ["test_pb2.py"], | ||
plugins = ["@build_stack_rules_proto//plugin/builtin:python"], | ||
proto = "prefix_test_proto", | ||
) | ||
|
||
proto_py_library( | ||
name = "prefix_test_py_library", | ||
srcs = ["test_pb2.py"], | ||
imports = [".."], | ||
visibility = ["//visibility:public"], | ||
deps = ["@com_google_protobuf//:protobuf_python"], | ||
) |
7 changes: 7 additions & 0 deletions
7
example/golden/testdata/strip_import_prefix/module_lib/util/nested/prefix/test.proto
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
syntax = "proto3"; | ||
|
||
package prefix.test; | ||
|
||
message Data { | ||
int64 id = 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters