Add default -Wall -Werror or -Wall.

* When -Wno-error and -Werror are not used:
  add -Wall to the front of cflags
  if the project is in the WarningAllowedProjects,
  otherwise add -Wall -Werror.
* Add -Wall -Werror to ndk_library build targets.
* Collect names of modules with -Wno-error or without -Werror,
  and pass them to makefile variables:
      SOONG_MODULES_USING_WNO_ERROR
      SOONG_MODULES_ADDED_WERROR
      SOONG_MODULES_ADDED_WALL
* Generate ANDROID_WARNING_ALLOWED_PROJECTS for old makefiles.

Bug: 66996870
Test: normal build
Change-Id: I31385e12b80ca946c7395a5a184ef259b029aac6
diff --git a/cc/config/global.go b/cc/config/global.go
index 44ad30b..4322436 100644
--- a/cc/config/global.go
+++ b/cc/config/global.go
@@ -118,6 +118,51 @@
 	ClangDefaultBase         = "prebuilts/clang/host"
 	ClangDefaultVersion      = "clang-4393122"
 	ClangDefaultShortVersion = "5.0.1"
+
+	WarningAllowedProjects = []string{
+		"external/boringssl/",
+		"external/libese/third_party/NXPNFC_P61_JCOP_Kit/",
+		"external/mdnsresponder/",
+		"external/protobuf/",
+		"external/skia/",
+		"device/",
+		"frameworks/av/media/libeffects/factory/",
+		"frameworks/av/media/libstagefright/codecs/",
+		"frameworks/base/tools/streaming_proto/",
+		"frameworks/ml/nn/",
+		"frameworks/native/libs/vr/libbufferhub/",
+		"frameworks/native/libs/vr/libbufferhubqueue/",
+		"frameworks/native/libs/vr/libdvr/tests/",
+		"frameworks/native/services/surfaceflinger/tests/",
+		"frameworks/native/services/vr/",
+		"hardware/interfaces/audio/effect/",
+		"hardware/interfaces/biometrics/fingerprint/",
+		"vendor/",
+	}
+
+	// Some Android.mk files still have warnings.
+	WarningAllowedOldProjects = []string{
+		"cts/hostsidetests/security/securityPatch/",
+		"cts/tests/tests/permission/jni/",
+		"development/tutorials/ReverseDebug/",
+		"external/freetype/",
+		"frameworks/av/drm/mediacas/plugins/",
+		"frameworks/av/media/libaaudio/examples/",
+		"frameworks/av/services/mediaextractor/",
+		"frameworks/base/core/tests/webkit/apk_with_native_libs/jni/",
+		"frameworks/base/tests/backup/",
+		"frameworks/native/cmds/cmd/",
+		"frameworks/webview/chromium/",
+		"hardware/interfaces/audio/2.0/",
+		"hardware/libhardware/modules/",
+		"hardware/libhardware/tests/",
+		"hardware/qcom/",
+		"sdk/emulator/mksdcard/",
+		"system/vold/tests/",
+		"test/vts-testcase/kernel/api/qtaguid/",
+		"test/vts-testcase/security/poc/target/",
+		"tools/adt/idea/android/ultimate/get_modification_time/jni/",
+	}
 )
 
 var pctx = android.NewPackageContext("android/soong/cc/config")