Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.
Bug: 266726655
Test: CI
Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
diff --git a/android/androidmk.go b/android/androidmk.go
index 14b2e82..aa411d1 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -548,6 +548,7 @@
a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
a.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_required...)
+ a.AddStrings("LOCAL_SOONG_MODULE_TYPE", ctx.ModuleType(amod))
// If the install rule was generated by Soong tell Make about it.
if len(base.katiInstalls) > 0 {
diff --git a/apex/apex_test.go b/apex/apex_test.go
index 707cc63..1f33eca 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4809,6 +4809,9 @@
android.AssertStringEquals(t, "Invalid output", "out/soong/.intermediates/provenance_metadata/myapex/provenance_metadata.textproto", rule.Output.String())
android.AssertStringEquals(t, "Invalid args", "myapex", rule.Args["module_name"])
android.AssertStringEquals(t, "Invalid args", "/system/apex/myapex.apex", rule.Args["install_path"])
+
+ entries := android.AndroidMkEntriesForTest(t, ctx, testingModule.Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "prebuilt_apex", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestPrebuiltMissingSrc(t *testing.T) {
diff --git a/cc/binary_test.go b/cc/binary_test.go
index e0b5b5d..2fac002 100644
--- a/cc/binary_test.go
+++ b/cc/binary_test.go
@@ -15,9 +15,10 @@
package cc
import (
- "android/soong/bazel/cquery"
"testing"
+ "android/soong/bazel/cquery"
+
"android/soong/android"
)
@@ -53,6 +54,9 @@
unStrippedFilePath := binMod.(*Module).UnstrippedOutputFile()
expectedUnStrippedFile := "outputbase/execroot/__main__/foo.unstripped"
android.AssertStringEquals(t, "Unstripped output file", expectedUnStrippedFile, unStrippedFilePath.String())
+
+ entries := android.AndroidMkEntriesForTest(t, ctx, binMod)[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "cc_binary", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestCcBinaryWithBazelValidations(t *testing.T) {
diff --git a/cc/library_test.go b/cc/library_test.go
index de3db99..dbe2be8 100644
--- a/cc/library_test.go
+++ b/cc/library_test.go
@@ -464,6 +464,7 @@
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "cc_library_shared", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestCcLibrarySharedWithBazel(t *testing.T) {
@@ -510,6 +511,7 @@
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "cc_library_shared", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestWholeStaticLibPrebuilts(t *testing.T) {
diff --git a/cc/prebuilt_test.go b/cc/prebuilt_test.go
index 405680c..e3ec9d5 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -169,6 +169,11 @@
if !hasDep(crtx, prebuiltCrtx) {
t.Errorf("crtx missing dependency on prebuilt_crtx")
}
+
+ entries := android.AndroidMkEntriesForTest(t, ctx, prebuiltLiba)[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "cc_prebuilt_library_shared", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
+ entries = android.AndroidMkEntriesForTest(t, ctx, prebuiltLibb)[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "cc_prebuilt_library_static", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestPrebuiltLibraryShared(t *testing.T) {
diff --git a/etc/prebuilt_etc_test.go b/etc/prebuilt_etc_test.go
index a6477dd..0d44c31 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -140,6 +140,7 @@
"LOCAL_REQUIRED_MODULES": {"modA", "moduleB"},
"LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"},
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
+ "LOCAL_SOONG_MODULE_TYPE": {"prebuilt_etc"},
}
mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
diff --git a/java/app_import_test.go b/java/app_import_test.go
index a29606f..528fffe 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -363,11 +363,14 @@
a := variant.Module().(*AndroidAppImport)
expectedValues := []string{test.expected}
- actualValues := android.AndroidMkEntriesForTest(t, ctx, a)[0].EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
+ entries := android.AndroidMkEntriesForTest(t, ctx, a)[0]
+ actualValues := entries.EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
if !reflect.DeepEqual(actualValues, expectedValues) {
t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
actualValues, expectedValues)
}
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "android_app_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
+
rule := variant.Rule("genProvenanceMetaData")
android.AssertStringEquals(t, "Invalid input", test.expectedArtifactPath, rule.Inputs[0].String())
android.AssertStringEquals(t, "Invalid output", test.expectedMetaDataPath, rule.Output.String())
@@ -560,6 +563,7 @@
} else if actualSoongResourceExportPackage[0] != expectedSoongResourceExportPackage {
t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE mismatch, actual: %s, expected: %s", actualSoongResourceExportPackage[0], expectedSoongResourceExportPackage)
}
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "android_app_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
diff --git a/java/java_test.go b/java/java_test.go
index 05cc23e..68b749b 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -615,6 +615,13 @@
android.AssertPathRelativeToTopEquals(t, "baz dex jar build path", expectedDexJar, bazDexJar)
ctx.ModuleForTests("qux", "android_common").Rule("Cp")
+
+ entries := android.AndroidMkEntriesForTest(t, ctx, fooModule.Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "java_library", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
+ entries = android.AndroidMkEntriesForTest(t, ctx, barModule.Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "java_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
+ entries = android.AndroidMkEntriesForTest(t, ctx, ctx.ModuleForTests("sdklib", "android_common").Module())[0]
+ android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "java_sdk_library_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
}
func assertDeepEquals(t *testing.T, message string, expected interface{}, actual interface{}) {