Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 598f92d7 authored by Wei Li's avatar Wei Li
Browse files

Export Soong module type to LOCAL_SOONG_MODULE_TYPE to Make for SBOM generation.

Bug: 266726655
Test: CI

Change-Id: If5b1a77930a591b6061ca2749c9c5ad29b4491fb
parent edec71ad
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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 {
+3 −0
Original line number Diff line number Diff line
@@ -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) {
+5 −1
Original line number Diff line number Diff line
@@ -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) {
+2 −0
Original line number Diff line number Diff line
@@ -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) {
+5 −0
Original line number Diff line number Diff line
@@ -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) {
Loading