summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Wei Li <weiwli@google.com> 2023-01-04 17:12:24 -0800
committer Wei Li <weiwli@google.com> 2023-03-06 22:51:03 +0000
commit598f92d7048b670c209977bf12c67d2c47d056a6 (patch)
tree8a71875b9f42b33dfdb23ab23ee1524a20d6d038
parentedec71adae47232e967d3ba8f1a6a1c78afcee90 (diff)
Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.
Bug: 266726655 Test: CI Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
-rw-r--r--android/androidmk.go1
-rw-r--r--apex/apex_test.go3
-rw-r--r--cc/binary_test.go6
-rw-r--r--cc/library_test.go2
-rw-r--r--cc/prebuilt_test.go5
-rw-r--r--etc/prebuilt_etc_test.go1
-rw-r--r--java/app_import_test.go6
-rw-r--r--java/java_test.go7
8 files changed, 29 insertions, 2 deletions
diff --git a/android/androidmk.go b/android/androidmk.go
index 14b2e8237..aa411d116 100644
--- a/android/androidmk.go
+++ b/android/androidmk.go
@@ -548,6 +548,7 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint
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 707cc632a..1f33eca70 100644
--- a/apex/apex_test.go
+++ b/apex/apex_test.go
@@ -4809,6 +4809,9 @@ func TestPrebuilt(t *testing.T) {
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 e0b5b5d20..2fac0023b 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 @@ cc_binary {
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 de3db99db..dbe2be899 100644
--- a/cc/library_test.go
+++ b/cc/library_test.go
@@ -464,6 +464,7 @@ cc_library_shared {
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 @@ cc_library_shared {
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 405680c39..e3ec9d5d4 100644
--- a/cc/prebuilt_test.go
+++ b/cc/prebuilt_test.go
@@ -169,6 +169,11 @@ func TestPrebuilt(t *testing.T) {
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 a6477dd6a..0d44c31ef 100644
--- a/etc/prebuilt_etc_test.go
+++ b/etc/prebuilt_etc_test.go
@@ -140,6 +140,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
"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 a29606f89..528fffe94 100644
--- a/java/app_import_test.go
+++ b/java/app_import_test.go
@@ -363,11 +363,14 @@ func TestAndroidAppImport_Filename(t *testing.T) {
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 @@ func TestAndroidAppImport_frameworkRes(t *testing.T) {
} 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 05cc23e29..68b749b6d 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -615,6 +615,13 @@ func TestPrebuilts(t *testing.T) {
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{}) {