DO NOT MERGE "Export soong license data to make."
61a55a0344
Test: m nothing
Bug: 180688789
Change-Id: I5fb017c683df18bad42a8e27fb2d7c7c510514e5
This commit is contained in:
parent
5553f7fb61
commit
987f33cafc
|
@ -21,6 +21,7 @@ import (
|
|||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"reflect"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
|
@ -281,6 +282,17 @@ func (a *AndroidMkEntries) GetDistForGoals(mod blueprint.Module) []string {
|
|||
return ret
|
||||
}
|
||||
|
||||
// Write the license variables to Make for AndroidMkData.Custom(..) methods that do not call WriteAndroidMkData(..)
|
||||
// It's required to propagate the license metadata even for module types that have non-standard interfaces to Make.
|
||||
func (a *AndroidMkEntries) WriteLicenseVariables(w io.Writer) {
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_KINDS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_KINDS"], " "))
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_CONDITIONS :=", strings.Join(a.EntryMap["LOCAL_LICENSE_CONDITIONS"], " "))
|
||||
fmt.Fprintln(w, "LOCAL_NOTICE_FILE :=", strings.Join(a.EntryMap["LOCAL_NOTICE_FILE"], " "))
|
||||
if pn, ok := a.EntryMap["LOCAL_LICENSE_PACKAGE_NAME"]; ok {
|
||||
fmt.Fprintln(w, "LOCAL_LICENSE_PACKAGE_NAME :=", strings.Join(pn, " "))
|
||||
}
|
||||
}
|
||||
|
||||
func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod blueprint.Module) {
|
||||
a.EntryMap = make(map[string][]string)
|
||||
amod := mod.(Module).base()
|
||||
|
@ -302,6 +314,13 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
|||
// Collect make variable assignment entries.
|
||||
a.SetString("LOCAL_PATH", filepath.Dir(bpPath))
|
||||
a.SetString("LOCAL_MODULE", name+a.SubName)
|
||||
a.AddStrings("LOCAL_LICENSE_KINDS", amod.commonProperties.Effective_license_kinds...)
|
||||
a.AddStrings("LOCAL_LICENSE_CONDITIONS", amod.commonProperties.Effective_license_conditions...)
|
||||
a.AddStrings("LOCAL_NOTICE_FILE", amod.commonProperties.Effective_license_text...)
|
||||
// TODO(b/151177513): Does this code need to set LOCAL_MODULE_IS_CONTAINER ?
|
||||
if amod.commonProperties.Effective_package_name != nil {
|
||||
a.SetString("LOCAL_LICENSE_PACKAGE_NAME", *amod.commonProperties.Effective_package_name)
|
||||
}
|
||||
a.SetString("LOCAL_MODULE_CLASS", a.Class)
|
||||
a.SetString("LOCAL_PREBUILT_MODULE_FILE", a.OutputFile.String())
|
||||
a.AddStrings("LOCAL_REQUIRED_MODULES", a.Required...)
|
||||
|
@ -512,6 +531,7 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
|
|||
}
|
||||
}()
|
||||
|
||||
// Additional cases here require review for correct license propagation to make.
|
||||
switch x := mod.(type) {
|
||||
case AndroidMkDataProvider:
|
||||
return translateAndroidModule(ctx, w, mod, x)
|
||||
|
@ -520,6 +540,7 @@ func translateAndroidMkModule(ctx SingletonContext, w io.Writer, mod blueprint.M
|
|||
case AndroidMkEntriesProvider:
|
||||
return translateAndroidMkEntriesModule(ctx, w, mod, x)
|
||||
default:
|
||||
// Not exported to make so no make variables to set.
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -531,6 +552,10 @@ func translateGoBinaryModule(ctx SingletonContext, w io.Writer, mod blueprint.Mo
|
|||
fmt.Fprintln(w, ".PHONY:", name)
|
||||
fmt.Fprintln(w, name+":", goBinary.InstallPath())
|
||||
fmt.Fprintln(w, "")
|
||||
// Assuming no rules in make include go binaries in distributables.
|
||||
// If the assumption is wrong, make will fail to build without the necessary .meta_lic and .meta_module files.
|
||||
// In that case, add the targets and rules here to build a .meta_lic file for `name` and a .meta_module for
|
||||
// `goBinary.InstallPath()` pointing to the `name`.meta_lic file.
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -596,6 +621,25 @@ func translateAndroidModule(ctx SingletonContext, w io.Writer, mod blueprint.Mod
|
|||
blueprintDir := filepath.Dir(ctx.BlueprintFile(mod))
|
||||
|
||||
if data.Custom != nil {
|
||||
// List of module types allowed to use .Custom(...)
|
||||
// Additions to the list require careful review for proper license handling.
|
||||
switch reflect.TypeOf(mod).String() { // ctx.ModuleType(mod) doesn't work: aidl_interface creates phony without type
|
||||
case "*aidl.aidlApi": // writes non-custom before adding .phony
|
||||
case "*aidl.aidlMapping": // writes non-custom before adding .phony
|
||||
case "*android.customModule": // appears in tests only
|
||||
case "*apex.apexBundle": // license properties written
|
||||
case "*bpf.bpf": // license properties written (both for module and objs)
|
||||
case "*genrule.Module": // writes non-custom before adding .phony
|
||||
case "*java.SystemModules": // doesn't go through base_rules
|
||||
case "*java.systemModulesImport": // doesn't go through base_rules
|
||||
case "*phony.phony": // license properties written
|
||||
case "*selinux.selinuxContextsModule": // license properties written
|
||||
case "*sysprop.syspropLibrary": // license properties written
|
||||
default:
|
||||
if ctx.Config().IsEnvTrue("ANDROID_REQUIRE_LICENSES") {
|
||||
return fmt.Errorf("custom make rules not allowed for %q (%q) module %q", ctx.ModuleType(mod), reflect.TypeOf(mod), ctx.ModuleName(mod))
|
||||
}
|
||||
}
|
||||
data.Custom(w, name, prefix, blueprintDir, data)
|
||||
} else {
|
||||
WriteAndroidMkData(w, data)
|
||||
|
@ -628,6 +672,7 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blue
|
|||
return nil
|
||||
}
|
||||
|
||||
// Any new or special cases here need review to verify correct propagation of license information.
|
||||
for _, entries := range provider.AndroidMkEntries() {
|
||||
entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod)
|
||||
entries.write(w)
|
||||
|
|
|
@ -767,7 +767,7 @@ type ModuleBase struct {
|
|||
noAddressSanitizer bool
|
||||
installFiles Paths
|
||||
checkbuildFiles Paths
|
||||
noticeFiles Paths
|
||||
noticeFile OptionalPath
|
||||
phonies map[string]Paths
|
||||
|
||||
// Used by buildTargetSingleton to create checkbuild and per-directory build targets
|
||||
|
@ -1365,7 +1365,7 @@ func (m *ModuleBase) GenerateBuildActions(blueprintCtx blueprint.ModuleContext)
|
|||
notice := proptools.StringDefault(m.commonProperties.Notice, "NOTICE")
|
||||
if module := SrcIsModule(notice); module != "" {
|
||||
m.noticeFile = ctx.ExpandOptionalSource(¬ice, "notice")
|
||||
} else {
|
||||
} else if notice != "" {
|
||||
noticePath := filepath.Join(ctx.ModuleDir(), notice)
|
||||
m.noticeFile = ExistentPathForSource(ctx, noticePath)
|
||||
}
|
||||
|
|
|
@ -254,7 +254,7 @@ func (a *apexBundle) androidMkForFiles(w io.Writer, apexBundleName, apexName, mo
|
|||
return moduleNames
|
||||
}
|
||||
|
||||
func (a *apexBundle) writeRequiredModules(w io.Writer) {
|
||||
func (a *apexBundle) writeRequiredModules(w io.Writer, apexBundleName string) {
|
||||
var required []string
|
||||
var targetRequired []string
|
||||
var hostRequired []string
|
||||
|
@ -293,7 +293,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
|||
if len(moduleNames) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES :=", strings.Join(moduleNames, " "))
|
||||
}
|
||||
a.writeRequiredModules(w)
|
||||
a.writeRequiredModules(w, name)
|
||||
fmt.Fprintln(w, "include $(BUILD_PHONY_PACKAGE)")
|
||||
|
||||
} else {
|
||||
|
@ -312,7 +312,7 @@ func (a *apexBundle) androidMkForType() android.AndroidMkData {
|
|||
if len(a.requiredDeps) > 0 {
|
||||
fmt.Fprintln(w, "LOCAL_REQUIRED_MODULES +=", strings.Join(a.requiredDeps, " "))
|
||||
}
|
||||
a.writeRequiredModules(w)
|
||||
a.writeRequiredModules(w, name)
|
||||
var postInstallCommands []string
|
||||
if a.prebuiltFileToDelete != "" {
|
||||
postInstallCommands = append(postInstallCommands, "rm -rf "+
|
||||
|
|
|
@ -192,6 +192,7 @@ func (system *SystemModules) AndroidMk() android.AndroidMkData {
|
|||
|
||||
fmt.Fprintln(w, name+":", "$("+makevar+")")
|
||||
fmt.Fprintln(w, ".PHONY:", name)
|
||||
// TODO(b/151177513): Licenses: Doesn't go through base_rules. May have to generate meta_lic and meta_module here.
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue