Merge "Add genrule to build *.latest.version build target."
This commit is contained in:
commit
da8ebf235c
1 changed files with 24 additions and 4 deletions
|
@ -135,6 +135,19 @@ func createApiModule(mctx android.LoadHookContext, name string, path string) {
|
|||
mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
|
||||
}
|
||||
|
||||
func createLatestApiModuleExtensionVersionFile(mctx android.LoadHookContext, name string, version string) {
|
||||
genruleProps := struct {
|
||||
Name *string
|
||||
Srcs []string
|
||||
Out []string
|
||||
Cmd *string
|
||||
}{}
|
||||
genruleProps.Name = proptools.StringPtr(name)
|
||||
genruleProps.Out = []string{name}
|
||||
genruleProps.Cmd = proptools.StringPtr("echo " + version + " > $(out)")
|
||||
mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
|
||||
}
|
||||
|
||||
func createEmptyFile(mctx android.LoadHookContext, name string) {
|
||||
props := struct {
|
||||
Name *string
|
||||
|
@ -233,9 +246,10 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||
type latestApiInfo struct {
|
||||
module, scope, path string
|
||||
version int
|
||||
isExtensionApiFile bool
|
||||
}
|
||||
|
||||
getLatest := func(files []string) map[string]latestApiInfo {
|
||||
getLatest := func(files []string, isExtensionApiFile bool) map[string]latestApiInfo {
|
||||
m := make(map[string]latestApiInfo)
|
||||
for _, f := range files {
|
||||
module, version, scope := parseFinalizedPrebuiltPath(mctx, f)
|
||||
|
@ -245,16 +259,16 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||
key := module + "." + scope
|
||||
info, exists := m[key]
|
||||
if !exists || version > info.version {
|
||||
m[key] = latestApiInfo{module, scope, f, version}
|
||||
m[key] = latestApiInfo{module, scope, f, version, isExtensionApiFile}
|
||||
}
|
||||
}
|
||||
return m
|
||||
}
|
||||
|
||||
latest := getLatest(apiLevelFiles)
|
||||
latest := getLatest(apiLevelFiles, false)
|
||||
if p.properties.Extensions_dir != nil {
|
||||
extensionApiFiles := globExtensionDirs(mctx, p, "api/*.txt")
|
||||
for k, v := range getLatest(extensionApiFiles) {
|
||||
for k, v := range getLatest(extensionApiFiles, true) {
|
||||
if _, exists := latest[k]; !exists {
|
||||
mctx.ModuleErrorf("Module %v finalized for extension %d but never during an API level; likely error", v.module, v.version)
|
||||
}
|
||||
|
@ -267,6 +281,12 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||
for _, k := range android.SortedKeys(latest) {
|
||||
info := latest[k]
|
||||
name := PrebuiltApiModuleName(info.module, info.scope, "latest")
|
||||
latestExtensionVersionModuleName := PrebuiltApiModuleName(info.module, info.scope, "latest.extension_version")
|
||||
if info.isExtensionApiFile {
|
||||
createLatestApiModuleExtensionVersionFile(mctx, latestExtensionVersionModuleName, strconv.Itoa(info.version))
|
||||
} else {
|
||||
createLatestApiModuleExtensionVersionFile(mctx, latestExtensionVersionModuleName, "-1")
|
||||
}
|
||||
createApiModule(mctx, name, info.path)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue