diff options
author | Jaewoong Jung <jungjw@google.com> | 2019-06-17 17:40:56 -0700 |
---|---|---|
committer | Jaewoong Jung <jungjw@google.com> | 2019-06-25 20:56:17 +0000 |
commit | 5c6572e53fa2810e45215850842b81b8fa9a22ec (patch) | |
tree | 0db20545dd2f0cda070b05d11069bb8f813cd09d /apex | |
parent | 3ad00bf196544f686eaf8b9caf8ef44d3e991744 (diff) | |
download | build_soong-5c6572e53fa2810e45215850842b81b8fa9a22ec.tar.gz build_soong-5c6572e53fa2810e45215850842b81b8fa9a22ec.tar.bz2 build_soong-5c6572e53fa2810e45215850842b81b8fa9a22ec.zip |
Optionally embed NOTICE files in apks.
If embed_notices or ALWAYS_EMBED_NOTICES is set, collect NOTICE files
from all dependencies of the android_app, merge them with the app's own
one (if exists), transform it to HTML, gzip it, and put it as an asset
in the final APK output.
Bug: 135460391
Test: app_test.go + Built Mainline modules
Change-Id: I52d92e2fd19b3f5f396100424665c5cc344190d8
Merged-In: I52d92e2fd19b3f5f396100424665c5cc344190d8
(cherry picked from commit 5b425e2e20c55216c1ed13fcf047b0df33886736)
Diffstat (limited to 'apex')
-rw-r--r-- | apex/apex.go | 20 | ||||
-rw-r--r-- | apex/apex_test.go | 8 |
2 files changed, 5 insertions, 23 deletions
diff --git a/apex/apex.go b/apex/apex.go index fa4cb48c..18df4393 100644 --- a/apex/apex.go +++ b/apex/apex.go @@ -90,12 +90,6 @@ var ( CommandDeps: []string{"${zip2zip}"}, Description: "app bundle", }, "abi") - - apexMergeNoticeRule = pctx.StaticRule("apexMergeNoticeRule", blueprint.RuleParams{ - Command: `${mergenotice} --output $out $inputs`, - CommandDeps: []string{"${mergenotice}"}, - Description: "merge notice files into $out", - }, "inputs") ) var imageApexSuffix = ".apex" @@ -144,8 +138,6 @@ func init() { pctx.HostBinToolVariable("zip2zip", "zip2zip") pctx.HostBinToolVariable("zipalign", "zipalign") - pctx.SourcePathVariable("mergenotice", "build/soong/scripts/mergenotice.py") - android.RegisterModuleType("apex", apexBundleFactory) android.RegisterModuleType("apex_test", testApexBundleFactory) android.RegisterModuleType("apex_defaults", defaultsFactory) @@ -837,32 +829,22 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) { func (a *apexBundle) buildNoticeFile(ctx android.ModuleContext) { noticeFiles := []android.Path{} - noticeFilesString := []string{} for _, f := range a.filesInfo { if f.module != nil { notice := f.module.NoticeFile() if notice.Valid() { noticeFiles = append(noticeFiles, notice.Path()) - noticeFilesString = append(noticeFilesString, notice.Path().String()) } } } // append the notice file specified in the apex module itself if a.NoticeFile().Valid() { noticeFiles = append(noticeFiles, a.NoticeFile().Path()) - noticeFilesString = append(noticeFilesString, a.NoticeFile().Path().String()) } if len(noticeFiles) > 0 { a.mergedNoticeFile = android.PathForModuleOut(ctx, "NOTICE") - ctx.Build(pctx, android.BuildParams{ - Rule: apexMergeNoticeRule, - Inputs: noticeFiles, - Output: a.mergedNoticeFile, - Args: map[string]string{ - "inputs": strings.Join(noticeFilesString, " "), - }, - }) + android.MergeNotices(ctx, a.mergedNoticeFile, noticeFiles) } } diff --git a/apex/apex_test.go b/apex/apex_test.go index a07a89b8..200a1c29 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -347,10 +347,10 @@ func TestBasicApex(t *testing.T) { t.Errorf("Could not find all expected symlinks! foo: %t, foo_link_64: %t. Command was %s", found_foo, found_foo_link_64, copyCmds) } - apexMergeNoticeRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("apexMergeNoticeRule") - noticeInputs := strings.Split(apexMergeNoticeRule.Args["inputs"], " ") - if len(noticeInputs) != 3 { - t.Errorf("number of input notice files: expected = 3, actual = %d", len(noticeInputs)) + mergeNoticesRule := ctx.ModuleForTests("myapex", "android_common_myapex").Rule("mergeNoticesRule") + noticeInputs := mergeNoticesRule.Inputs.Strings() + if len(noticeInputs) != 4 { + t.Errorf("number of input notice files: expected = 4, actual = %q", len(noticeInputs)) } ensureListContains(t, noticeInputs, "NOTICE") ensureListContains(t, noticeInputs, "custom_notice") |