Merge "License info for APEXes are correctly gathered"

This commit is contained in:
Treehugger Robot 2020-01-28 18:56:47 +00:00 committed by Gerrit Code Review
commit 76fde9212a
3 changed files with 20 additions and 7 deletions

View file

@ -112,6 +112,11 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexName, moduleDir string)
} }
} else { } else {
fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated) fmt.Fprintln(w, "LOCAL_MODULE_PATH :=", pathWhenActivated)
// For non-flattend APEXes, the merged notice file is attached to the APEX itself.
// We don't need to have notice file for the individual modules in it. Otherwise,
// we will have duplicated notice entries.
fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
} }
fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String()) fmt.Fprintln(w, "LOCAL_PREBUILT_MODULE_FILE :=", fi.builtFile.String())
fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake()) fmt.Fprintln(w, "LOCAL_MODULE_CLASS :=", fi.class.NameInMake())
@ -271,6 +276,11 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
if len(postInstallCommands) > 0 { if len(postInstallCommands) > 0 {
fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && ")) fmt.Fprintln(w, "LOCAL_POST_INSTALL_CMD :=", strings.Join(postInstallCommands, " && "))
} }
if a.mergedNotices.Merged.Valid() {
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", a.mergedNotices.Merged.Path().String())
}
fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w, "include $(BUILD_PREBUILT)")
if apexType == imageApex { if apexType == imageApex {

View file

@ -818,6 +818,9 @@ type apexBundle struct {
// Whether to create symlink to the system file instead of having a file // Whether to create symlink to the system file instead of having a file
// inside the apex or not // inside the apex or not
linkToSystemLib bool linkToSystemLib bool
// Struct holding the merged notice file paths in different formats
mergedNotices android.NoticeOutputs
} }
func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext, func addDependenciesForNativeModules(ctx android.BottomUpMutatorContext,

View file

@ -211,7 +211,7 @@ func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs,
}) })
} }
func (a *apexBundle) buildNoticeFile(ctx android.ModuleContext, apexFileName string) android.OptionalPath { func (a *apexBundle) buildNoticeFiles(ctx android.ModuleContext, apexFileName string) android.NoticeOutputs {
noticeFiles := []android.Path{} noticeFiles := []android.Path{}
for _, f := range a.filesInfo { for _, f := range a.filesInfo {
if f.module != nil { if f.module != nil {
@ -227,10 +227,10 @@ func (a *apexBundle) buildNoticeFile(ctx android.ModuleContext, apexFileName str
} }
if len(noticeFiles) == 0 { if len(noticeFiles) == 0 {
return android.OptionalPath{} return android.NoticeOutputs{}
} }
return android.BuildNoticeOutput(ctx, a.installDir, apexFileName, android.FirstUniquePaths(noticeFiles)).HtmlGzOutput return android.BuildNoticeOutput(ctx, a.installDir, apexFileName, android.FirstUniquePaths(noticeFiles))
} }
func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApex android.Path, imageDir android.Path) android.OutputPath { func (a *apexBundle) buildInstalledFilesFile(ctx android.ModuleContext, builtApex android.Path, imageDir android.Path) android.OutputPath {
@ -394,11 +394,11 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion) optFlags = append(optFlags, "--target_sdk_version "+targetSdkVersion)
optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion) optFlags = append(optFlags, "--min_sdk_version "+minSdkVersion)
noticeFile := a.buildNoticeFile(ctx, a.Name()+suffix) a.mergedNotices = a.buildNoticeFiles(ctx, a.Name()+suffix)
if noticeFile.Valid() { if a.mergedNotices.HtmlGzOutput.Valid() {
// If there's a NOTICE file, embed it as an asset file in the APEX. // If there's a NOTICE file, embed it as an asset file in the APEX.
implicitInputs = append(implicitInputs, noticeFile.Path()) implicitInputs = append(implicitInputs, a.mergedNotices.HtmlGzOutput.Path())
optFlags = append(optFlags, "--assets_dir "+filepath.Dir(noticeFile.String())) optFlags = append(optFlags, "--assets_dir "+filepath.Dir(a.mergedNotices.HtmlGzOutput.String()))
} }
if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && ctx.ModuleDir() != "system/apex/shim/build" && a.testOnlyShouldSkipHashtreeGeneration() { if ctx.ModuleDir() != "system/apex/apexd/apexd_testdata" && ctx.ModuleDir() != "system/apex/shim/build" && a.testOnlyShouldSkipHashtreeGeneration() {