Merge changes Iac05e49a,If9b0e74b,I341043b4,I5eef9120,I4d747786, ...

* changes:
  gn2bp: Add flags and include_dirs to target
  gn2bp: Add cppflags and local_include_dirs to Target
  gn2bp: Split function to set local_include_dirs
  gn2bp: Split function to set module flags
  gn2bp: Add indlue_dirs to arch
  gn2bp: Add defines to arch
  gn2bp: Add cflags to arch
diff --git a/tools/gn2bp/Android.bp.swp b/tools/gn2bp/Android.bp.swp
index cc34e64..02ccc56 100644
--- a/tools/gn2bp/Android.bp.swp
+++ b/tools/gn2bp/Android.bp.swp
@@ -189,24 +189,14 @@
         "cronet_aml_third_party_android_ndk_cpu_features",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
         "-DIS_PARTITION_ALLOC_IMPL",
         "-DPA_PCSCAN_STACK_SUPPORTED",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -219,10 +209,6 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "third_party/android_ndk/sources/android/cpufeatures/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
     target: {
@@ -233,6 +219,30 @@
                 "base/allocator/partition_allocator/partition_alloc_base/native_library_posix.cc",
                 "base/allocator/partition_allocator/partition_alloc_base/time/time_android.cc",
             ],
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/sources/android/cpufeatures/",
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
         },
     },
 }
@@ -876,32 +886,20 @@
     ],
     cflags: [
         "-DABSL_ALLOCATOR_NOTHROW=1",
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DBASE_IMPLEMENTATION",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DGLOG_EXPORT=",
-        "-DHAVE_SYS_UIO_H",
         "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
-        "-DUSE_AURA=1",
         "-DUSE_CHROMIUM_ICU=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_SYMBOLIZE",
-        "-DUSE_UDEV",
         "-DU_ENABLE_DYLOAD=0",
         "-DU_ENABLE_RESOURCE_TRACING=0",
         "-DU_ENABLE_TRACING=1",
         "-DU_STATIC_IMPLEMENTATION",
         "-DU_USING_ICU_NAMESPACE=0",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -915,13 +913,9 @@
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
         "third_party/abseil-cpp/",
-        "third_party/android_ndk/sources/android/cpufeatures/",
         "third_party/boringssl/src/include/",
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     header_libs: [
         "jni_headers",
@@ -1008,6 +1002,15 @@
                 "base/threading/platform_thread_android.cc",
                 "base/time/time_android.cc",
             ],
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/sources/android/cpufeatures/",
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
         },
         host: {
             srcs: [
@@ -1026,6 +1029,21 @@
                 "base/stack_canary_linux.cc",
                 "base/threading/platform_thread_linux.cc",
             ],
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DGLOG_EXPORT=",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_SYMBOLIZE",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
         },
     },
 }
@@ -1312,22 +1330,12 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -1340,11 +1348,35 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //base:build_date
@@ -1643,22 +1675,12 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -1671,11 +1693,35 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //base/third_party/dynamic_annotations:dynamic_annotations
@@ -1689,22 +1735,12 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -1715,11 +1751,35 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //base/third_party/symbolize:symbolize
@@ -1753,7 +1813,6 @@
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
     ],
     local_include_dirs: [
         "./",
@@ -1802,7 +1861,6 @@
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
     ],
     local_include_dirs: [
         "./",
@@ -1846,7 +1904,6 @@
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D__STDC_CONSTANT_MACROS",
         "-D__STDC_FORMAT_MACROS",
-        "-UANDROID",
     ],
     local_include_dirs: [
         "./",
@@ -2667,23 +2724,13 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCRYPTO_IMPLEMENTATION",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -2693,16 +2740,11 @@
     ],
     local_include_dirs: [
         "./",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/nspr",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/nss",
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
         "third_party/abseil-cpp/",
         "third_party/boringssl/src/include/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
     target: {
@@ -2712,11 +2754,36 @@
                 "liblog",
             ],
         },
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
         host: {
             srcs: [
                 "crypto/nss_key_util.cc",
                 "crypto/nss_util.cc",
             ],
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/nspr",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/nss",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
         },
     },
 }
@@ -5493,26 +5560,16 @@
         "cronet_aml_third_party_boringssl_src_third_party_fiat_fiat_license",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DBORINGSSL_ALLOW_CXX_RUNTIME",
         "-DBORINGSSL_IMPLEMENTATION",
         "-DBORINGSSL_NO_STATIC_INITIALIZER",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
         "-DOPENSSL_SMALL",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -5526,11 +5583,35 @@
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
         "third_party/boringssl/src/include/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/boringssl:boringssl_asm
@@ -5910,22 +5991,15 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
         "-DHAVE_DLOPEN=0",
-        "-DHAVE_SYS_UIO_H",
         "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
         "-DUCONFIG_ONLY_HTML_CONVERSION=1",
         "-DUCONFIG_USE_WINDOWS_LCID_MAPPING_API=0",
-        "-DUSE_AURA=1",
         "-DUSE_CHROMIUM_ICU=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-DU_CHARSET_IS_UTF8=1",
         "-DU_ENABLE_DYLOAD=0",
         "-DU_ENABLE_RESOURCE_TRACING=0",
@@ -5934,10 +6008,7 @@
         "-DU_STATIC_IMPLEMENTATION",
         "-DU_USING_ICU_NAMESPACE=0",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -5950,12 +6021,36 @@
         "buildtools/third_party/libc++abi/trunk/include",
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
     rtti: true,
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/icu:icuuc_private
@@ -6168,22 +6263,15 @@
         "cronet_aml_third_party_icu_icuuc_public",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
         "-DHAVE_DLOPEN=0",
-        "-DHAVE_SYS_UIO_H",
         "-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE",
         "-DUCONFIG_ONLY_HTML_CONVERSION=1",
         "-DUCONFIG_USE_WINDOWS_LCID_MAPPING_API=0",
-        "-DUSE_AURA=1",
         "-DUSE_CHROMIUM_ICU=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-DU_CHARSET_IS_UTF8=1",
         "-DU_COMMON_IMPLEMENTATION",
         "-DU_ENABLE_DYLOAD=0",
@@ -6193,10 +6281,7 @@
         "-DU_STATIC_IMPLEMENTATION",
         "-DU_USING_ICU_NAMESPACE=0",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -6211,12 +6296,36 @@
         "buildtools/third_party/libc++abi/trunk/include",
         "third_party/icu/source/common/",
         "third_party/icu/source/i18n/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
     rtti: true,
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/icu:icuuc_public
@@ -6248,23 +6357,13 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
         "-DHAVE_CONFIG_H",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -6275,13 +6374,37 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "third_party/libevent/android/",
-        "third_party/libevent/linux/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+                "third_party/libevent/android/",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+                "third_party/libevent/linux/",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/metrics_proto:metrics_proto
@@ -6434,22 +6557,12 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -6462,11 +6575,35 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/protobuf:protobuf_full
@@ -6589,7 +6726,6 @@
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
     ],
     local_include_dirs: [
         "./",
@@ -6697,8 +6833,6 @@
         "cronet_aml_defaults",
     ],
     cflags: [
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
         "-DCR_SYSROOT_KEY=20220331T153654Z-0",
@@ -6708,7 +6842,6 @@
         "-DGOOGLE_PROTOBUF_NO_RTTI",
         "-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER",
         "-DHAVE_PTHREAD",
-        "-DHAVE_SYS_UIO_H",
         "-DLIBCXXABI_SILENT_TERMINATE",
         "-DLIBCXX_BUILDING_LIBCXXABI",
         "-DUSE_AURA=1",
@@ -6726,8 +6859,6 @@
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
         "-D_LIBCPP_OVERRIDABLE_FUNC_VIS=__attribute__((__visibility__(\"default\")))",
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D_LIBUNWIND_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-D_LIBUNWIND_IS_NATIVE_ONLY",
     ],
     local_include_dirs: [
         "./",
@@ -6735,11 +6866,9 @@
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++/trunk/src/",
         "buildtools/third_party/libc++abi/trunk/include",
-        "buildtools/third_party/libunwind/trunk/include/",
         "third_party/protobuf/src/",
         "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
         "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
     cppflags: [
@@ -6869,7 +6998,6 @@
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
         "-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS",
-        "-UANDROID",
     ],
     local_include_dirs: [
         "./",
@@ -6915,29 +7043,19 @@
     ],
     cflags: [
         "-DADLER32_SIMD_SSSE3",
-        "-DANDROID",
-        "-DANDROID_NDK_VERSION_ROLL=r23_1",
         "-DCRC32_SIMD_SSE42_PCLMUL",
         "-DCR_CLANG_REVISION=\"llvmorg-16-init-8697-g60809cd2-1\"",
         "-DCR_LIBCXX_REVISION=47b31179d10646029c260702650a25d24f555acc",
-        "-DCR_SYSROOT_KEY=20220331T153654Z-0",
         "-DDCHECK_ALWAYS_ON=1",
         "-DDEFLATE_SLIDE_HASH_SSE2",
         "-DDYNAMIC_ANNOTATIONS_ENABLED=1",
-        "-DHAVE_SYS_UIO_H",
         "-DINFLATE_CHUNK_READ_64LE",
         "-DINFLATE_CHUNK_SIMD_SSE2",
-        "-DUSE_AURA=1",
-        "-DUSE_OZONE=1",
-        "-DUSE_UDEV",
         "-DX86_NOT_WINDOWS",
         "-DZLIB_DEBUG",
         "-DZLIB_IMPLEMENTATION",
         "-D_DEBUG",
-        "-D_FILE_OFFSET_BITS=64",
         "-D_GNU_SOURCE",
-        "-D_LARGEFILE64_SOURCE",
-        "-D_LARGEFILE_SOURCE",
         "-D_LIBCPP_AVAILABILITY_CUSTOM_VERBOSE_ABORT_PROVIDED=1",
         "-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS",
         "-D_LIBCPP_ENABLE_ASSERTIONS_DEFAULT=1",
@@ -6952,13 +7070,37 @@
         "buildtools/third_party/libc++/",
         "buildtools/third_party/libc++/trunk/include",
         "buildtools/third_party/libc++abi/trunk/include",
-        "third_party/android_ndk/sources/android/cpufeatures/",
         "third_party/zlib/",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
-        "build/linux/debian_bullseye_amd64-sysroot/usr/include",
-        "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
     ],
     cpp_std: "c++20",
+    target: {
+        android_x86_64: {
+            cflags: [
+                "-DANDROID",
+                "-DANDROID_NDK_VERSION_ROLL=r23_1",
+                "-DHAVE_SYS_UIO_H",
+            ],
+            local_include_dirs: [
+                "third_party/android_ndk/sources/android/cpufeatures/",
+                "third_party/android_ndk/toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/include",
+            ],
+        },
+        host: {
+            cflags: [
+                "-DCR_SYSROOT_KEY=20220331T153654Z-0",
+                "-DUSE_AURA=1",
+                "-DUSE_OZONE=1",
+                "-DUSE_UDEV",
+                "-D_FILE_OFFSET_BITS=64",
+                "-D_LARGEFILE64_SOURCE",
+                "-D_LARGEFILE_SOURCE",
+            ],
+            local_include_dirs: [
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include",
+                "build/linux/debian_bullseye_amd64-sysroot/usr/include/x86_64-linux-gnu",
+            ],
+        },
+    },
 }
 
 // GN: //third_party/zlib:zlib_adler32_simd
diff --git a/tools/gn2bp/gen_android_bp b/tools/gn2bp/gen_android_bp
index dd0f736..10abd9b 100755
--- a/tools/gn2bp/gen_android_bp
+++ b/tools/gn2bp/gen_android_bp
@@ -207,6 +207,8 @@
     self.dist = dict()
     self.strip = dict()
     self.stl = None
+    self.cppflags = set()
+    self.local_include_dirs = []
 
   def to_string(self, output):
     nested_out = []
@@ -218,6 +220,8 @@
     self._output_field(nested_out, 'stl')
     self._output_field(nested_out, 'dist')
     self._output_field(nested_out, 'strip')
+    self._output_field(nested_out, 'cppflags')
+    self._output_field(nested_out, 'local_include_dirs')
 
     if nested_out:
       output.append('    %s: {' % self.name)
@@ -946,17 +950,54 @@
 
 
 
-def _get_cflags(target):
-  cflags = {flag for flag in target.cflags if flag in cflag_allowlist}
+def _get_cflags(cflags, defines):
+  cflags = {flag for flag in cflags if flag in cflag_allowlist}
   # Consider proper allowlist or denylist if needed
-  cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in target.defines)
+  cflags |= set("-D%s" % define.replace("\"", "\\\"") for define in defines)
   # -DANDROID is added by default but target.defines contain -DANDROID if it's required.
   # So adding -UANDROID to cancel default -DANDROID if it's not specified.
   # This is needed for some targets(e.g. symbolize)
-  if "ANDROID" not in target.defines:
-    cflags.add("-UANDROID")
+  # TODO: Set -UANDROID considering common define
+  # if "ANDROID" not in defines:
+  #   cflags.add("-UANDROID")
   return cflags
 
+def set_module_flags(module, cflags, defines):
+  module.cflags.update(_get_cflags(cflags, defines))
+  # TODO: implement proper cflag parsing.
+  for flag in cflags:
+    if '-std=' in flag:
+      module.cpp_std = flag[len('-std='):]
+    if '-frtti' in flag:
+      module.rtti = True
+    if '-fexceptions' in flag:
+      module.cppflags.add('-fexceptions')
+
+def set_module_include_dirs(module, cflags, include_dirs):
+  local_include_dirs_set = set()
+  for flag in cflags:
+    if '-isystem' in flag:
+      local_include_dirs_set.add(flag[len('-isystem../../'):])
+
+  # Adding local_include_dirs is necessary due to source_sets / filegroups
+  # which do not properly propagate include directories.
+  # Filter any directory inside //out as a) this directory does not exist for
+  # aosp / soong builds and b) the include directory should already be
+  # configured via library dependency.
+  local_include_dirs_set.update([gn_utils.label_to_path(d)
+                                 for d in include_dirs
+                                 if not re.match('^//out/.*', d)])
+  module.local_include_dirs = sorted(list(local_include_dirs_set))
+
+  # Order matters for some targets. For example, base/time/time_exploded_icu.cc
+  # in //base:base needs to have sysroot include after icu/source/common
+  # include. So adding sysroot include at the end.
+  for flag in sorted(cflags):
+    if '--sysroot' in flag:
+      sysroot = flag[len('--sysroot=../../'):]
+      if sysroot == "build/linux/debian_bullseye_amd64-sysroot":
+        module.local_include_dirs.append(sysroot + "/usr/include/x86_64-linux-gnu")
+      module.local_include_dirs.append(sysroot + "/usr/include")
 
 def create_modules_from_target(blueprint, gn, gn_target_name):
   """Generate module(s) for a given GN target.
@@ -1034,40 +1075,13 @@
       for src in arch.sources
       if is_supported_source_file(src) and not src.startswith("//out/test"))
 
-  local_include_dirs_set = set()
   if target.type in gn_utils.LINKER_UNIT_TYPES:
-    module.cflags.update(_get_cflags(target))
-    # TODO: implement proper cflag parsing.
-    for flag in target.cflags:
-      if '-std=' in flag:
-        module.cpp_std = flag[len('-std='):]
-      if '-isystem' in flag:
-        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.
-    # Filter any directory inside //out as a) this directory does not exist for
-    # aosp / soong builds and b) the include directory should already be
-    # configured via library dependency.
-    local_include_dirs_set.update([gn_utils.label_to_path(d)
-                                      for d in target.include_dirs
-                                      if not re.match('^//out/.*', d)])
-    module.local_include_dirs = sorted(list(local_include_dirs_set))
-
-    # Order matters for some targets. For example, base/time/time_exploded_icu.cc
-    # in //base:base needs to have sysroot include after icu/source/common
-    # include. So adding sysroot include at the end.
-    for flag in sorted(target.cflags):
-      if '--sysroot' in flag:
-        sysroot = flag[len('--sysroot=../../'):]
-        if sysroot == "build/linux/debian_bullseye_amd64-sysroot":
-          module.local_include_dirs.append(sysroot + "/usr/include/x86_64-linux-gnu")
-        module.local_include_dirs.append(sysroot + "/usr/include")
+    set_module_flags(module, target.cflags, target.defines)
+    set_module_include_dirs(module, target.cflags, target.include_dirs)
+    # TODO: set_module_xxx is confusing, apply similar function to module and target in better way.
+    for arch_name, arch in target.arch.items():
+      set_module_flags(module.target[arch_name], arch.cflags, arch.defines)
+      set_module_include_dirs(module.target[arch_name], arch.cflags, arch.include_dirs)
 
   if module.is_compiled():
     module.host_supported = target.host_supported()
diff --git a/tools/gn2bp/gn_utils.py b/tools/gn2bp/gn_utils.py
index 494ed25..f2dc15a 100644
--- a/tools/gn2bp/gn_utils.py
+++ b/tools/gn2bp/gn_utils.py
@@ -97,6 +97,9 @@
         """
       def __init__(self):
         self.sources = set()
+        self.cflags = set()
+        self.defines = set()
+        self.include_dirs = set()
 
 
     def __init__(self, name, type):
@@ -174,12 +177,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', 'defines', 'include_dirs'):
+        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.
 
@@ -191,11 +198,16 @@
 
       # Target contains the intersection of arch-dependent properties
       self.sources = set.intersection(*[arch.sources for arch in self.arch.values()])
+      self.cflags = set.intersection(*[arch.cflags for arch in self.arch.values()])
+      self.defines = set.intersection(*[arch.defines for arch in self.arch.values()])
+      self.include_dirs = set.intersection(*[arch.include_dirs for arch in self.arch.values()])
 
       # Deduplicate arch-dependent properties
       for arch in self.arch.keys():
         self.arch[arch].sources -= self.sources
-
+        self.arch[arch].cflags -= self.cflags
+        self.arch[arch].defines -= self.defines
+        self.arch[arch].include_dirs -= self.include_dirs
 
   def __init__(self):
     self.all_targets = {}
@@ -317,11 +329,11 @@
     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', []))
-    target.include_dirs.update(desc.get('include_dirs', []))
+    target.arch[arch].defines.update(desc.get('defines', []))
+    target.arch[arch].include_dirs.update(desc.get('include_dirs', []))
 
     # Recurse in dependencies.
     for gn_dep_name in desc.get('deps', []):
@@ -335,9 +347,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)