soong: Add bliss soong config variables

Ref: https://android.googlesource.com/platform/build/soong/+/refs/tags/android-11.0.0_r4#soong-config-variables

Change-Id: Icaf35b65b63d4245c92e39ce628bb8d6ffd0d4bb

Signed-off-by: Jackeagle <jackeagle102@gmail.com>
Change-Id: Ia672a12a13016d99b283fcf4e8bb20e8f458e014
diff --git a/build/soong/Android.bp b/build/soong/Android.bp
index 0268354..81a6c53 100644
--- a/build/soong/Android.bp
+++ b/build/soong/Android.bp
@@ -1,3 +1,5 @@
+// Bliss soong configs
+
 bootstrap_go_package {
     name: "soong-bliss-generator",
     pkgPath: "bliss/soong/generator",
@@ -46,3 +48,384 @@
     vendor_available: true,
     recovery_available: true,
 }
+
+// Target platform agnostic config modules
+soong_config_module_type {
+    name: "gralloc_10_usage_bits",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["additional_gralloc_10_usage_bits"],
+    properties: ["cppflags"],
+}
+
+gralloc_10_usage_bits {
+    name: "gralloc_10_usage_bits_defaults",
+    soong_config_variables: {
+        additional_gralloc_10_usage_bits: {
+            cppflags: ["-DADDNL_GRALLOC_10_USAGE_BITS=%s"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "target_process_sdk_version_overrides",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["target_process_sdk_version_override"],
+    properties: ["cppflags"],
+}
+
+target_process_sdk_version_overrides {
+    name: "process_sdk_version_overrides_defaults",
+    soong_config_variables: {
+        target_process_sdk_version_override: {
+            cppflags: ["-DSDK_VERSION_OVERRIDES=\"%s\""],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "target_shim_libs",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["target_ld_shim_libs"],
+    properties: ["cppflags"],
+}
+
+target_shim_libs {
+    name: "shim_libs_defaults",
+    soong_config_variables: {
+        target_ld_shim_libs: {
+            cppflags: ["-DLD_SHIM_LIBS=\"%s\""],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "vendor_init",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["target_init_vendor_lib"],
+    properties: ["whole_static_libs"],
+}
+
+vendor_init {
+    name: "vendor_init_defaults",
+    soong_config_variables: {
+        target_init_vendor_lib: {
+            whole_static_libs: ["%s"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "surfaceflinger_fod_lib",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["target_surfaceflinger_fod_lib"],
+    properties: [
+        "cppflags",
+        "whole_static_libs",
+    ],
+}
+
+surfaceflinger_fod_lib {
+    name: "surfaceflinger_fod_lib_defaults",
+    soong_config_variables: {
+        target_surfaceflinger_fod_lib: {
+            cppflags: ["-DTARGET_PROVIDES_FOD_LIB"],
+            whole_static_libs: ["%s"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "ignores_ftp_pptp_conntrack_failure_defaults",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    bool_variables: ["ignores_ftp_pptp_conntrack_failure"],
+    properties: ["cppflags"],
+}
+
+ignores_ftp_pptp_conntrack_failure_defaults {
+    name: "ignores_ftp_pptp_conntrack_failure",
+    soong_config_variables: {
+        ignores_ftp_pptp_conntrack_failure: {
+            cppflags: ["DIGNORES_FTP_PPTP_CONNTRACK_FAILURE"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "needs_netd_direct_connect_rule",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    bool_variables: ["needs_netd_direct_connect_rule"],
+    properties: ["cppflags"],
+}
+
+needs_netd_direct_connect_rule {
+    name: "needs_netd_direct_connect_rule_defaults",
+    soong_config_variables: {
+        needs_netd_direct_connect_rule: {
+            cppflags: ["-DNEEDS_NETD_DIRECT_CONNECT_RULE"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "no_cameraserver",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    bool_variables: ["has_legacy_camera_hal1"],
+    properties: [
+        "cppflags",
+    ],
+}
+
+no_cameraserver {
+    name: "no_cameraserver_defaults",
+    soong_config_variables: {
+        has_legacy_camera_hal1: {
+            cppflags: [
+                "-DNO_CAMERA_SERVER",
+                "-Wno-overloaded-virtual",
+            ],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "camera_in_mediaserver",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    bool_variables: ["has_legacy_camera_hal1"],
+    properties: [
+        "overrides",
+        "shared_libs",
+    ],
+}
+
+camera_in_mediaserver {
+    name: "camera_in_mediaserver_defaults",
+    defaults: ["no_cameraserver_defaults"],
+    soong_config_variables: {
+        has_legacy_camera_hal1: {
+            overrides: ["cameraserver"],
+            shared_libs: [
+                "android.hardware.camera.common@1.0",
+                "android.hardware.camera.device@3.4",
+                "android.hardware.camera.provider@2.6",
+                "libcameraservice",
+                "libgui",
+            ],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "bootloader_message_offset",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["bootloader_message_offset"],
+    properties: ["cflags"],
+}
+
+bootloader_message_offset {
+    name: "bootloader_message_offset_defaults",
+    soong_config_variables: {
+        bootloader_message_offset: {
+            cflags: ["-DBOARD_RECOVERY_BLDRMSG_OFFSET=%s"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "camera_parameter_library",
+    module_type: "cc_defaults",
+    config_namespace: "blissGlobalVars",
+    value_variables: ["uses_camera_parameter_lib"],
+    properties: ["whole_static_libs"],
+}
+
+camera_parameter_library {
+    name: "camera_parameter_library_defaults",
+    soong_config_variables: {
+        uses_camera_parameter_lib: {
+            whole_static_libs: ["%s"],
+        },
+    },
+}
+
+// NVIDIA specific config modules
+soong_config_module_type {
+    name: "nvidia_enhancements",
+    module_type: "cc_defaults",
+    config_namespace: "blissNvidiaVars",
+    bool_variables: ["uses_nvidia_enhancements"],
+    properties: ["cppflags"],
+}
+
+nvidia_enhancements {
+    name: "nvidia_enhancements_defaults",
+    soong_config_variables: {
+        uses_nvidia_enhancements: {
+            cppflags: ["-DNV_ANDROID_FRAMEWORK_ENHANCEMENTS"],
+        },
+    },
+}
+
+// QCOM specific config modules
+soong_config_module_type {
+    name: "librmnetctl_pre_uplink",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["uses_pre_uplink_features_netmgrd"],
+    properties: ["cflags"],
+}
+
+librmnetctl_pre_uplink {
+    name: "librmnetctl_pre_uplink_defaults",
+    soong_config_variables: {
+        uses_pre_uplink_features_netmgrd: {
+            cflags: ["-DNO_UPLINK_FEATURES"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "qti_camera_device",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["uses_qti_camera_device"],
+    properties: [
+        "cppflags",
+        "shared_libs",
+    ],
+}
+
+qti_camera_device {
+    name: "qti_camera_device_defaults",
+    soong_config_variables: {
+        uses_qti_camera_device: {
+            cppflags: ["-DQTI_CAMERA_DEVICE"],
+            shared_libs: ["vendor.qti.hardware.camera.device@1.0"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "extended_compress_format",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["supports_extended_compress_format"],
+    properties: ["cflags"],
+}
+
+extended_compress_format {
+    name: "extended_compress_format_defaults",
+    soong_config_variables: {
+        supports_extended_compress_format: {
+            cflags: ["-DENABLE_EXTENDED_COMPRESS_FORMAT"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "vold_hw_fde",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["supports_hw_fde"],
+    properties: [
+        "cflags",
+        "header_libs",
+        "shared_libs",
+    ],
+}
+
+vold_hw_fde {
+    name: "vold_hw_fde_defaults",
+    soong_config_variables: {
+        supports_hw_fde: {
+            cflags: ["-DCONFIG_HW_DISK_ENCRYPTION"],
+            header_libs: ["libcryptfs_hw_headers"],
+            shared_libs: ["libcryptfs_hw"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "vold_hw_fde_perf",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["supports_hw_fde_perf"],
+    properties: [
+        "cflags",
+        "shared_libs",
+    ],
+}
+
+vold_hw_fde_perf {
+    name: "vold_hw_fde_perf_defaults",
+    soong_config_variables: {
+        supports_hw_fde_perf: {
+            cflags: ["-DCONFIG_HW_DISK_ENCRYPT_PERF"],
+            shared_libs: ["libcryptfs_hw"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "qti_cryptfshw_qsee",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["should_wait_for_qsee"],
+    properties: ["cflags"],
+}
+
+qti_cryptfshw_qsee {
+    name: "qti_cryptfshw_qsee_defaults",
+    soong_config_variables: {
+        should_wait_for_qsee: {
+            cflags: ["-DWAIT_FOR_QSEE"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "surfaceflinger_qcom_extensions",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    value_variables: ["qcom_soong_namespace"],
+    properties: [
+        "cppflags",
+        "header_libs",
+    ],
+}
+
+surfaceflinger_qcom_extensions {
+    name: "surfaceflinger_qcom_ext_defaults",
+    soong_config_variables: {
+        qcom_soong_namespace: {
+            cppflags: ["-DQCOM_UM_FAMILY"],
+            header_libs: ["//%s/display:display_intf_headers"],
+        },
+    },
+}
+
+soong_config_module_type {
+    name: "stagefright_qcom_legacy",
+    module_type: "cc_defaults",
+    config_namespace: "blissQcomVars",
+    bool_variables: ["uses_qcom_bsp_legacy"],
+    properties: ["cppflags"],
+}
+
+stagefright_qcom_legacy {
+    name: "stagefright_qcom_legacy_defaults",
+    soong_config_variables: {
+        uses_qcom_bsp_legacy: {
+            cppflags: ["-DQCOM_BSP_LEGACY"],
+        },
+    },
+}
diff --git a/config/BoardConfigQcom.mk b/config/BoardConfigQcom.mk
index 126d768..924fad5 100644
--- a/config/BoardConfigQcom.mk
+++ b/config/BoardConfigQcom.mk
@@ -96,7 +96,3 @@
 # Allow a device to opt-out hardset of PRODUCT_SOONG_NAMESPACES
 QCOM_SOONG_NAMESPACE ?= hardware/qcom-caf/$(QCOM_HARDWARE_VARIANT)
 PRODUCT_SOONG_NAMESPACES += $(QCOM_SOONG_NAMESPACE)
-
-SOONG_CONFIG_NAMESPACES += DATASERVICES
-SOONG_CONFIG_DATASERVICES += USES_PRE_UPLINK_FEATURES_NETMGRD
-SOONG_CONFIG_DATASERVICES_USES_PRE_UPLINK_FEATURES_NETMGRD := $(TARGET_USES_PRE_UPLINK_FEATURES_NETMGRD)
diff --git a/config/BoardConfigSoong.mk b/config/BoardConfigSoong.mk
index 38d7164..0ec834d 100644
--- a/config/BoardConfigSoong.mk
+++ b/config/BoardConfigSoong.mk
@@ -25,3 +25,67 @@
 endef
 
 $(foreach v,$(EXPORT_TO_SOONG),$(eval $(call addVar,$(v))))
+
+SOONG_CONFIG_NAMESPACES += blissGlobalVars
+SOONG_CONFIG_blissGlobalVars += \
+    additional_gralloc_10_usage_bits \
+    bootloader_message_offset \
+    has_legacy_camera_hal1 \
+    ignores_ftp_pptp_conntrack_failure \
+    needs_netd_direct_connect_rule \
+    target_init_vendor_lib \
+    target_ld_shim_libs \
+    target_process_sdk_version_override \
+    target_surfaceflinger_fod_lib \
+    uses_camera_parameter_lib
+
+SOONG_CONFIG_NAMESPACES += blissNvidiaVars
+SOONG_CONFIG_blissNvidiaVars += \
+    uses_nv_enhancements
+
+SOONG_CONFIG_NAMESPACES += blissQcomVars
+SOONG_CONFIG_blissQcomVars += \
+    should_wait_for_qsee \
+    supports_extended_compress_format \
+    supports_hw_fde \
+    supports_hw_fde_perf \
+    uses_pre_uplink_features_netmgrd \
+    uses_qcom_bsp_legacy \
+    uses_qti_camera_device
+
+# Only create soong_namespace var if dealing with UM platforms to avoid breaking build for all other platforms
+ifneq ($(filter $(UM_PLATFORMS),$(TARGET_BOARD_PLATFORM)),)
+SOONG_CONFIG_blissQcomVars += \
+    qcom_soong_namespace
+endif
+
+# Soong bool variables
+SOONG_CONFIG_blissGlobalVars_has_legacy_camera_hal1 := $(TARGET_HAS_LEGACY_CAMERA_HAL1)
+SOONG_CONFIG_blissGlobalVars_ignores_ftp_pptp_conntrack_failure := $(TARGET_IGNORES_FTP_PPTP_CONNTRACK_FAILURE)
+SOONG_CONFIG_blissGlobalVars_needs_netd_direct_connect_rule := $(TARGET_NEEDS_NETD_DIRECT_CONNECT_RULE)
+SOONG_CONFIG_blissNvidiaVars_uses_nv_enhancements := $(NV_ANDROID_FRAMEWORK_ENHANCEMENTS)
+SOONG_CONFIG_blissQcomVars_should_wait_for_qsee := $(TARGET_KEYMASTER_WAIT_FOR_QSEE)
+SOONG_CONFIG_blissQcomVars_supports_extended_compress_format := $(AUDIO_FEATURE_ENABLED_EXTENDED_COMPRESS_FORMAT)
+SOONG_CONFIG_blissQcomVars_supports_hw_fde := $(TARGET_HW_DISK_ENCRYPTION)
+SOONG_CONFIG_blissQcomVars_supports_hw_fde_perf := $(TARGET_HW_DISK_ENCRYPTION_PERF)
+SOONG_CONFIG_blissQcomVars_uses_pre_uplink_features_netmgrd := $(TARGET_USES_PRE_UPLINK_FEATURES_NETMGRD)
+SOONG_CONFIG_blissQcomVars_uses_qcom_bsp_legacy := $(TARGET_USES_QCOM_BSP_LEGACY)
+SOONG_CONFIG_blissQcomVars_uses_qti_camera_device := $(TARGET_USES_QTI_CAMERA_DEVICE)
+
+# Set default values
+BOOTLOADER_MESSAGE_OFFSET ?= 0
+TARGET_INIT_VENDOR_LIB ?= vendor_init
+TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY ?= libcamera_parameters
+TARGET_SURFACEFLINGER_FOD_LIB ?= surfaceflinger_fod_lib
+
+# Soong value variables
+SOONG_CONFIG_blissGlobalVars_additional_gralloc_10_usage_bits := $(TARGET_ADDITIONAL_GRALLOC_10_USAGE_BITS)
+SOONG_CONFIG_blissGlobalVars_bootloader_message_offset := $(BOOTLOADER_MESSAGE_OFFSET)
+SOONG_CONFIG_blissGlobalVars_target_init_vendor_lib := $(TARGET_INIT_VENDOR_LIB)
+SOONG_CONFIG_blissGlobalVars_target_ld_shim_libs := $(subst $(space),:,$(TARGET_LD_SHIM_LIBS))
+SOONG_CONFIG_blissGlobalVars_target_process_sdk_version_override := $(TARGET_PROCESS_SDK_VERSION_OVERRIDE)
+SOONG_CONFIG_blissGlobalVars_target_surfaceflinger_fod_lib := $(TARGET_SURFACEFLINGER_FOD_LIB)
+SOONG_CONFIG_blissGlobalVars_uses_camera_parameter_lib := $(TARGET_SPECIFIC_CAMERA_PARAMETER_LIBRARY)
+ifneq ($(filter $(UM_PLATFORMS),$(TARGET_BOARD_PLATFORM)),)
+SOONG_CONFIG_blissQcomVars_qcom_soong_namespace := $(QCOM_SOONG_NAMESPACE)
+endif