Merge "Add genrule to build *.latest.version build target."
This commit is contained in:
@@ -135,6 +135,19 @@ func createApiModule(mctx android.LoadHookContext, name string, path string) {
|
|||||||
mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
|
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) {
|
func createEmptyFile(mctx android.LoadHookContext, name string) {
|
||||||
props := struct {
|
props := struct {
|
||||||
Name *string
|
Name *string
|
||||||
@@ -233,9 +246,10 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||||||
type latestApiInfo struct {
|
type latestApiInfo struct {
|
||||||
module, scope, path string
|
module, scope, path string
|
||||||
version int
|
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)
|
m := make(map[string]latestApiInfo)
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
module, version, scope := parseFinalizedPrebuiltPath(mctx, f)
|
module, version, scope := parseFinalizedPrebuiltPath(mctx, f)
|
||||||
@@ -245,16 +259,16 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||||||
key := module + "." + scope
|
key := module + "." + scope
|
||||||
info, exists := m[key]
|
info, exists := m[key]
|
||||||
if !exists || version > info.version {
|
if !exists || version > info.version {
|
||||||
m[key] = latestApiInfo{module, scope, f, version}
|
m[key] = latestApiInfo{module, scope, f, version, isExtensionApiFile}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
latest := getLatest(apiLevelFiles)
|
latest := getLatest(apiLevelFiles, false)
|
||||||
if p.properties.Extensions_dir != nil {
|
if p.properties.Extensions_dir != nil {
|
||||||
extensionApiFiles := globExtensionDirs(mctx, p, "api/*.txt")
|
extensionApiFiles := globExtensionDirs(mctx, p, "api/*.txt")
|
||||||
for k, v := range getLatest(extensionApiFiles) {
|
for k, v := range getLatest(extensionApiFiles, true) {
|
||||||
if _, exists := latest[k]; !exists {
|
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)
|
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) {
|
for _, k := range android.SortedKeys(latest) {
|
||||||
info := latest[k]
|
info := latest[k]
|
||||||
name := PrebuiltApiModuleName(info.module, info.scope, "latest")
|
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)
|
createApiModule(mctx, name, info.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user