make: Add support to skip current VNDK install

You can get a system.img without current VNDK libs.
This may help when you want a smaller system.img given that the image
will be used with a specific version (not current) of vendor image.

Bug: 132140714
Test: m TARGET_SKIP_CURRENT_VNDK=true && see if current VNDK is not
installed

Change-Id: Ie0815e6dd6ce2f861b6c42e637da4bb146320673
diff --git a/core/clear_vars.mk b/core/clear_vars.mk
index fafdce6..5973e0e 100644
--- a/core/clear_vars.mk
+++ b/core/clear_vars.mk
@@ -269,6 +269,7 @@
 LOCAL_SOONG_SYMBOL_PATH :=
 LOCAL_SOONG_TOC :=
 LOCAL_SOONG_UNSTRIPPED_BINARY :=
+LOCAL_SOONG_VNDK_VERSION :=
 # '',true
 LOCAL_SOURCE_FILES_ALL_GENERATED:=
 LOCAL_SRC_FILES:=
diff --git a/core/notice_files.mk b/core/notice_files.mk
index c314734..6df570e 100644
--- a/core/notice_files.mk
+++ b/core/notice_files.mk
@@ -61,6 +61,9 @@
     # device-obj or host-obj.
     module_installed_filename := \
         $(patsubst $(PRODUCT_OUT)/%,%,$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_SHARED_LIBRARIES))/$(notdir $(LOCAL_BUILT_MODULE))
+  else ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
+    # Shared modules may be uninstallable(e.g. TARGET_SKIP_CURRENT_VNDK=true)
+    module_installed_filename :=
   else
     ifeq ($(LOCAL_MODULE_CLASS),JAVA_LIBRARIES)
       # Stick the static java libraries with the regular java libraries.
diff --git a/core/soong_cc_prebuilt.mk b/core/soong_cc_prebuilt.mk
index 7a8f46e..55dd077 100644
--- a/core/soong_cc_prebuilt.mk
+++ b/core/soong_cc_prebuilt.mk
@@ -3,6 +3,7 @@
 # LOCAL_SOONG_LINK_TYPE
 # LOCAL_SOONG_TOC
 # LOCAL_SOONG_UNSTRIPPED_BINARY
+# LOCAL_SOONG_VNDK_VERSION : means the version of VNDK where this module belongs
 
 ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
   $(call pretty-error,soong_cc_prebuilt.mk may only be used from Soong)
@@ -51,6 +52,13 @@
   endif
 endif
 
+# Don't install modules of current VNDK when it is told so
+ifeq ($(TARGET_SKIP_CURRENT_VNDK),true)
+  ifeq ($(LOCAL_SOONG_VNDK_VERSION),$(PLATFORM_VNDK_VERSION))
+    LOCAL_UNINSTALLABLE_MODULE := true
+  endif
+endif
+
 #######################################
 include $(BUILD_SYSTEM)/base_rules.mk
 #######################################