gn2bp: Split genrule for proto to source and header
genrule needs to generate .h files or .c files so that other modules can
specify the genrule from the srcs, headers.
Test: ./update_result.sh
Change-Id: If3bd3301b1ae3d2b02f867ea20a80110c5d44349
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index be9c3ba..8a33036 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -32,6 +32,7 @@
import os
import re
import sys
+import copy
import gn_utils
@@ -937,6 +938,15 @@
elif target.script == "//tools/grit/stamp_grit_sources.py":
# stamp_grit_sources.py is not executable
module.cmd = "python " + module.cmd
+ elif target.script == "//tools/protoc_wrapper/protoc_wrapper.py":
+ # Split module to source module and header module.
+ # Source module has the .cc files and header module has the .h files in the out.
+ header_module = copy.deepcopy(module)
+ header_module.name += "_headers"
+ header_module.out = [file for file in header_module.out if os.path.splitext(file)[1] == '.h']
+ module.out = [file for file in module.out if os.path.splitext(file)[1] == '.cc']
+ module.genrule_headers.add(header_module.name)
+ blueprint.add_module(header_module)
blueprint.add_module(module)
return module