Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.
Bug: 266726655 Test: CI Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
This commit is contained in:
@@ -548,6 +548,7 @@ func (a *AndroidMkEntries) fillInEntries(ctx fillInEntriesContext, mod blueprint
|
|||||||
a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
|
a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
|
||||||
a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
|
a.AddStrings("LOCAL_HOST_REQUIRED_MODULES", a.Host_required...)
|
||||||
a.AddStrings("LOCAL_TARGET_REQUIRED_MODULES", a.Target_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 the install rule was generated by Soong tell Make about it.
|
||||||
if len(base.katiInstalls) > 0 {
|
if len(base.katiInstalls) > 0 {
|
||||||
|
@@ -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 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", "myapex", rule.Args["module_name"])
|
||||||
android.AssertStringEquals(t, "Invalid args", "/system/apex/myapex.apex", rule.Args["install_path"])
|
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) {
|
func TestPrebuiltMissingSrc(t *testing.T) {
|
||||||
|
@@ -15,9 +15,10 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"android/soong/bazel/cquery"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"android/soong/bazel/cquery"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -53,6 +54,9 @@ cc_binary {
|
|||||||
unStrippedFilePath := binMod.(*Module).UnstrippedOutputFile()
|
unStrippedFilePath := binMod.(*Module).UnstrippedOutputFile()
|
||||||
expectedUnStrippedFile := "outputbase/execroot/__main__/foo.unstripped"
|
expectedUnStrippedFile := "outputbase/execroot/__main__/foo.unstripped"
|
||||||
android.AssertStringEquals(t, "Unstripped output file", expectedUnStrippedFile, unStrippedFilePath.String())
|
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) {
|
func TestCcBinaryWithBazelValidations(t *testing.T) {
|
||||||
|
@@ -464,6 +464,7 @@ cc_library_shared {
|
|||||||
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
||||||
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
||||||
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
|
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) {
|
func TestCcLibrarySharedWithBazel(t *testing.T) {
|
||||||
@@ -510,6 +511,7 @@ cc_library_shared {
|
|||||||
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
expectedFlags := []string{"-Ioutputbase/execroot/__main__/include", "-isystem outputbase/execroot/__main__/system_include"}
|
||||||
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
gotFlags := entries.EntryMap["LOCAL_EXPORT_CFLAGS"]
|
||||||
android.AssertDeepEquals(t, "androidmk exported cflags", expectedFlags, gotFlags)
|
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) {
|
func TestWholeStaticLibPrebuilts(t *testing.T) {
|
||||||
|
@@ -169,6 +169,11 @@ func TestPrebuilt(t *testing.T) {
|
|||||||
if !hasDep(crtx, prebuiltCrtx) {
|
if !hasDep(crtx, prebuiltCrtx) {
|
||||||
t.Errorf("crtx missing dependency on prebuilt_crtx")
|
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) {
|
func TestPrebuiltLibraryShared(t *testing.T) {
|
||||||
|
@@ -140,6 +140,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
|
|||||||
"LOCAL_REQUIRED_MODULES": {"modA", "moduleB"},
|
"LOCAL_REQUIRED_MODULES": {"modA", "moduleB"},
|
||||||
"LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"},
|
"LOCAL_HOST_REQUIRED_MODULES": {"hostModA", "hostModB"},
|
||||||
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
|
"LOCAL_TARGET_REQUIRED_MODULES": {"targetModA"},
|
||||||
|
"LOCAL_SOONG_MODULE_TYPE": {"prebuilt_etc"},
|
||||||
}
|
}
|
||||||
|
|
||||||
mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
|
mod := result.Module("foo", "android_arm64_armv8-a").(*PrebuiltEtc)
|
||||||
|
@@ -363,11 +363,14 @@ func TestAndroidAppImport_Filename(t *testing.T) {
|
|||||||
|
|
||||||
a := variant.Module().(*AndroidAppImport)
|
a := variant.Module().(*AndroidAppImport)
|
||||||
expectedValues := []string{test.expected}
|
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) {
|
if !reflect.DeepEqual(actualValues, expectedValues) {
|
||||||
t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
|
t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
|
||||||
actualValues, expectedValues)
|
actualValues, expectedValues)
|
||||||
}
|
}
|
||||||
|
android.AssertStringEquals(t, "unexpected LOCAL_SOONG_MODULE_TYPE", "android_app_import", entries.EntryMap["LOCAL_SOONG_MODULE_TYPE"][0])
|
||||||
|
|
||||||
rule := variant.Rule("genProvenanceMetaData")
|
rule := variant.Rule("genProvenanceMetaData")
|
||||||
android.AssertStringEquals(t, "Invalid input", test.expectedArtifactPath, rule.Inputs[0].String())
|
android.AssertStringEquals(t, "Invalid input", test.expectedArtifactPath, rule.Inputs[0].String())
|
||||||
android.AssertStringEquals(t, "Invalid output", test.expectedMetaDataPath, rule.Output.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 {
|
} else if actualSoongResourceExportPackage[0] != expectedSoongResourceExportPackage {
|
||||||
t.Errorf("LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE mismatch, actual: %s, expected: %s", 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) {
|
func TestAndroidAppImport_relativeInstallPath(t *testing.T) {
|
||||||
|
@@ -615,6 +615,13 @@ func TestPrebuilts(t *testing.T) {
|
|||||||
android.AssertPathRelativeToTopEquals(t, "baz dex jar build path", expectedDexJar, bazDexJar)
|
android.AssertPathRelativeToTopEquals(t, "baz dex jar build path", expectedDexJar, bazDexJar)
|
||||||
|
|
||||||
ctx.ModuleForTests("qux", "android_common").Rule("Cp")
|
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{}) {
|
func assertDeepEquals(t *testing.T, message string, expected interface{}, actual interface{}) {
|
||||||
|
Reference in New Issue
Block a user