gn2bp: properly apply -fexceptions

Test: //components/cronet/android:cronet
Change-Id: I0704cd08308bd4ae4428d53c7cf14c3d920e2ec2
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index 3c81f4b..d1a1158 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -1944,9 +1944,6 @@
         "jni_headers",
     ],
     cpp_std: "c++20",
-    cppflags: [
-        "-fexceptions",
-    ],
     rtti: true,
 }
 
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index cdee102..22d69be 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -128,13 +128,6 @@
             "libssl",
         }),
     ],
-    'cronet_aml_components_cronet_android_cronet': [
-        ('cppflags', {
-            # TODO: figure out if there is no way around this and if this is
-            # allowed for platform code.
-            "-fexceptions",
-        })
-    ],
 }
 
 
@@ -1140,6 +1133,9 @@
         local_include_dirs_set.add(flag[len('-isystem../../'):])
       if '-frtti' in flag:
         module.rtti = True
+      if '-fexceptions' in flag:
+        module.cppflags.add('-fexceptions')
+
 
     # Adding local_include_dirs is necessary due to source_sets / filegroups
     # which do not properly propagate include directories.