aboutsummaryrefslogtreecommitdiffstats
path: root/apex/apex.go
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2019-03-18 12:01:38 +0900
committerJiyong Park <jiyong@google.com>2019-03-21 08:05:50 +0900
commit52818fcde8265fd43ad5f331f57122ecdbe7a6be (patch)
tree9c0edd5e4f9dfcae48cb3f87ff0f10c11b3fa776 /apex/apex.go
parent5a3f31b28451717dd7e9d948bcaa5644de759b17 (diff)
downloadbuild_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.gz
build_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.tar.bz2
build_soong-52818fcde8265fd43ad5f331f57122ecdbe7a6be.zip
Notice support for APEX
Notice file for an APEX is created by merging notice files for the modules included in it (plus the notice file for the APEX itself if specified). Notice files having the same content are not duplicated; it is emitted only once. Bug: 128701495 Test: m (apex_test is amended) Test: m and inspect $(PRODUCT_OUT)/obj/NOTICE.txt to check there are license entries for /system/apex/*.apex files Change-Id: I169d91038291a6c71615de97cf5b03174afab5d4
Diffstat (limited to 'apex/apex.go')
-rw-r--r--apex/apex.go50
1 files changed, 50 insertions, 0 deletions
diff --git a/apex/apex.go b/apex/apex.go
index ad1ef74f..c1f52a60 100644
--- a/apex/apex.go
+++ b/apex/apex.go
@@ -90,6 +90,12 @@ 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"
@@ -138,6 +144,8 @@ 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)
@@ -394,6 +402,8 @@ type apexBundle struct {
container_certificate_file android.Path
container_private_key_file android.Path
+ mergedNoticeFile android.WritablePath
+
// list of files to be included in this apex
filesInfo []apexFile
@@ -814,6 +824,8 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.installDir = android.PathForModuleInstall(ctx, "apex")
a.filesInfo = filesInfo
+ a.buildNoticeFile(ctx)
+
if a.apexTypes.zip() {
a.buildUnflattenedApex(ctx, zipApex)
}
@@ -827,6 +839,37 @@ 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, " "),
+ },
+ })
+ }
+}
+
func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext, apexType apexPackaging) {
cert := String(a.properties.Certificate)
if cert != "" && android.SrcIsModule(cert) == "" {
@@ -1078,6 +1121,10 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, name, moduleDir string, apex
if len(fi.symlinks) > 0 {
fmt.Fprintln(w, "LOCAL_MODULE_SYMLINKS :=", strings.Join(fi.symlinks, " "))
}
+
+ if fi.module != nil && fi.module.NoticeFile().Valid() {
+ fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", fi.module.NoticeFile().Path().String())
+ }
} else {
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated)
}
@@ -1168,6 +1215,9 @@ func (a *apexBundle) androidMkForType(apexType apexPackaging) android.AndroidMkD
fmt.Fprintln(w, "LOCAL_MODULE_STEM :=", name+apexType.suffix())
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE :=", !a.installable())
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", String(a.properties.Key))
+ if a.installable() && a.mergedNoticeFile != nil {
+ fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNoticeFile.String())
+ }
if len(moduleNames) > 0 {
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(moduleNames, " "))
}