gn2bp: Add cflags to arch

Test: m cronet_aml_third_party_protobuf_protoc
Change-Id: Iea847d205fd258ae00ba1ff03e382798deb2f0a8
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 494ed25..a03989c 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -97,6 +97,7 @@
         """
       def __init__(self):
         self.sources = set()
+        self.cflags = set()
 
 
     def __init__(self, name, type):
@@ -174,12 +175,16 @@
                         indent=4,
                         sort_keys=True)
 
-    def update(self, other):
+    def update(self, other, arch):
       for key in ('cflags', 'defines', 'deps', 'include_dirs', 'ldflags',
                   'source_set_deps', 'proto_deps', 'transitive_proto_deps',
                   'libs', 'proto_paths'):
         self.__dict__[key].update(other.__dict__.get(key, []))
 
+      for key_in_arch in ('cflags',):
+        self.arch[arch].__dict__[key_in_arch].update(
+          other.arch[arch].__dict__.get(key_in_arch, []))
+
     def finalize(self):
       """Move common properties out of arch-dependent subobjects to Target object.
 
@@ -196,6 +201,10 @@
       for arch in self.arch.keys():
         self.arch[arch].sources -= self.sources
 
+      # TODO: Keep cflags per arch
+      for arch_value in self.arch.values():
+        self.cflags = self.cflags.union(arch_value.cflags)
+
 
   def __init__(self):
     self.all_targets = {}
@@ -317,7 +326,7 @@
     public_headers = [x for x in desc.get('public', []) if x != '*']
     target.public_headers.update(public_headers)
 
-    target.cflags.update(desc.get('cflags', []) + desc.get('cflags_cc', []))
+    target.arch[arch].cflags.update(desc.get('cflags', []) + desc.get('cflags_cc', []))
     target.libs.update(desc.get('libs', []))
     target.ldflags.update(desc.get('ldflags', []))
     target.defines.update(desc.get('defines', []))
@@ -335,9 +344,9 @@
         target.transitive_proto_deps.update(dep.transitive_proto_deps)
       elif dep.type == 'source_set':
         target.source_set_deps.add(dep.name)
-        target.update(dep)  # Bubble up source set's cflags/ldflags etc.
+        target.update(dep, arch)  # Bubble up source set's cflags/ldflags etc.
       elif dep.type == 'group':
-        target.update(dep)  # Bubble up groups's cflags/ldflags etc.
+        target.update(dep, arch)  # Bubble up groups's cflags/ldflags etc.
       elif dep.type in ['action', 'action_foreach', 'copy']:
         if proto_target_type is None:
           target.deps.add(dep.name)