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

Commit 162e844c authored by Jiyong Park's avatar Jiyong Park
Browse files

track static deps when gatherint notices for apex

This change fixes a bug that license info for statically linked
libraries are absent in the merged notice for APEX. The problem was that
we were iterating over the apexFiles list that represents actual files
(not Soong modules) that are included in the APEX. The problem is now
fixed by iterarting the all the modules that directly or indirectly
contribute to the APEX using walkPayloadDeps() function.

Bug: 149455933
Test: m
Merged-In: I38655da62b590b669ab4649815b61a5a8e314154
(cherry picked from commit 9918e1af)
Change-Id: I38655da62b590b669ab4649815b61a5a8e314154
parent 79505fbf
Loading
Loading
Loading
Loading
+18 −2
Original line number Diff line number Diff line
@@ -150,6 +150,7 @@ func testApexContext(t *testing.T, bp string, handlers ...testCustomizer) (*andr
		"vendor/foo/devkeys/testkey.pem":             nil,
		"NOTICE":                                     nil,
		"custom_notice":                              nil,
		"custom_notice_for_static_lib":               nil,
		"testkey2.avbpubkey":                         nil,
		"testkey2.pem":                               nil,
		"myapex-arm64.apex":                          nil,
@@ -346,6 +347,20 @@ func TestBasicApex(t *testing.T) {
			system_shared_libs: [],
			stl: "none",
			notice: "custom_notice",
			static_libs: ["libstatic"],
			// TODO: remove //apex_available:platform
			apex_available: [
				"//apex_available:platform",
				"myapex",
			],
		}

		cc_library_static {
			name: "libstatic",
			srcs: ["mylib.cpp"],
			system_shared_libs: [],
			stl: "none",
			notice: "custom_notice_for_static_lib",
			// TODO: remove //apex_available:platform
			apex_available: [
				"//apex_available:platform",
@@ -444,11 +459,12 @@ func TestBasicApex(t *testing.T) {

	mergeNoticesRule := ctx.ModuleForTests("myapex", "android_common_myapex_image").Rule("mergeNoticesRule")
	noticeInputs := mergeNoticesRule.Inputs.Strings()
	if len(noticeInputs) != 2 {
		t.Errorf("number of input notice files: expected = 2, actual = %q", len(noticeInputs))
	if len(noticeInputs) != 3 {
		t.Errorf("number of input notice files: expected = 3, actual = %q", len(noticeInputs))
	}
	ensureListContains(t, noticeInputs, "NOTICE")
	ensureListContains(t, noticeInputs, "custom_notice")
	ensureListContains(t, noticeInputs, "custom_notice_for_static_lib")

	depsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("myapex-deps-info.txt").Args["content"], "\\n")
	ensureListContains(t, depsInfo, "myjar <- myapex")
+10 −12
Original line number Diff line number Diff line
@@ -217,19 +217,17 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
}

func (a *apexBundle) buildNoticeFiles(ctx android.ModuleContext, apexFileName string) android.NoticeOutputs {
	noticeFiles := []android.Path{}
	for _, f := range a.filesInfo {
		if f.module != nil {
			notice := f.module.NoticeFile()
	var noticeFiles android.Paths

	a.walkPayloadDeps(ctx, func(ctx android.ModuleContext, from blueprint.Module, to android.ApexModule, externalDep bool) {
		if externalDep {
			return
		}
		notice := to.NoticeFile()
		if notice.Valid() {
			noticeFiles = append(noticeFiles, notice.Path())
		}
		}
	}
	// append the notice file specified in the apex module itself
	if a.NoticeFile().Valid() {
		noticeFiles = append(noticeFiles, a.NoticeFile().Path())
	}
	})

	if len(noticeFiles) == 0 {
		return android.NoticeOutputs{}