summaryrefslogtreecommitdiff
path: root/apex/apex.go
diff options
context:
space:
mode:
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 ad1ef74f7..c1f52a603 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, " "))
}