gn2bp: Update --proto_path and --cpp_out arg
--proto_path specify the directory in which to search for imports.
net_quic_proto and metrics_proto have files that import other files.
Get proper --proto_path from the args in the desc.
Also, update --cpp_out to follow --proto_path change.
There are 6 targets which use protoc_wrapper.py in the dependency
from cronet_package_android.
It is confirmed that they could build with this commit.
Test: m cronet_aml_net_isolation_info_proto_gen
(//net:isolation_info_proto)
Test: m cronet_aml_net_net_nqe_proto_gen
(//net:net_nqe_proto)
Test: m cronet_aml_net_third_party_quiche_net_quic_test_tools_proto_gen
(//net/third_party/quiche:net_quic_test_tools_proto)
Test: m cronet_aml_net_cert_root_store_proto_full_gen
(//net/cert:root_store_proto_full)
Test: m cronet_aml_net_third_party_quiche_net_quic_proto_gen
(//net/third_party/quiche:net_quic_proto)
Test: m cronet_aml_third_party_metrics_proto_metrics_proto_gen
(//third_party/metrics_proto:metrics_proto)
Change-Id: Id19e956eb0eb3fb402f8aaa9eb94734b731c74fd
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 589b12a..6fcc0f8 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -110,6 +110,7 @@
self.proto_plugin = None
self.proto_paths = set()
self.proto_exports = set()
+ self.proto_in_dir = ""
self.sources = set()
# TODO(primiano): consider whether the public section should be part of
@@ -232,6 +233,7 @@
target.proto_plugin = proto_target_type
target.proto_paths.update(self.get_proto_paths(proto_desc))
target.proto_exports.update(self.get_proto_exports(proto_desc))
+ target.proto_in_dir = self.get_proto_in_dir(proto_desc)
target.sources.update(proto_desc.get('sources', []))
assert (all(x.endswith('.proto') for x in target.sources))
elif target.type == 'source_set':
@@ -322,6 +324,11 @@
metadata = proto_desc.get('metadata', {})
return metadata.get('import_dirs', [])
+
+ def get_proto_in_dir(self, proto_desc):
+ args = proto_desc.get('args')
+ return re.sub('^\.\./\.\./', '', args[args.index('--proto-in-dir') + 1])
+
def get_proto_target_type(self, target):
""" Checks if the target is a proto library and return the plugin.