Use genrule instead of filegroup for api files
filegroups have the unfortunate limitation that they don't create phony targets for building them in a convenient way. Also, having a single output file fits better with the genrule concept. Test: m framework-sdkextensions.api.public.latest Change-Id: I229410658b04403ff1ff6abd4116a65aaa02b83b
This commit is contained in:
parent
a0516f76ab
commit
c79d412b8a
1 changed files with 20 additions and 16 deletions
|
@ -106,14 +106,18 @@ func createImport(mctx android.LoadHookContext, module, scope, apiver, path, sdk
|
||||||
mctx.CreateModule(ImportFactory, &props)
|
mctx.CreateModule(ImportFactory, &props)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createFilegroup(mctx android.LoadHookContext, name string, path string) {
|
func createApiModule(mctx android.LoadHookContext, name string, path string) {
|
||||||
filegroupProps := struct {
|
genruleProps := struct {
|
||||||
Name *string
|
Name *string
|
||||||
Srcs []string
|
Srcs []string
|
||||||
|
Out []string
|
||||||
|
Cmd *string
|
||||||
}{}
|
}{}
|
||||||
filegroupProps.Name = proptools.StringPtr(name)
|
genruleProps.Name = proptools.StringPtr(name)
|
||||||
filegroupProps.Srcs = []string{path}
|
genruleProps.Srcs = []string{path}
|
||||||
mctx.CreateModule(android.FileGroupFactory, &filegroupProps)
|
genruleProps.Out = []string{name}
|
||||||
|
genruleProps.Cmd = proptools.StringPtr("cp $(in) $(out)")
|
||||||
|
mctx.CreateModule(genrule.GenRuleFactory, &genruleProps)
|
||||||
}
|
}
|
||||||
|
|
||||||
func createEmptyFile(mctx android.LoadHookContext, name string) {
|
func createEmptyFile(mctx android.LoadHookContext, name string) {
|
||||||
|
@ -205,16 +209,16 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create filegroups for all (<module>, <scope, <version>) triplets,
|
// Create modules for all (<module>, <scope, <version>) triplets,
|
||||||
// and a "latest" filegroup variant for each (<module>, <scope>) pair
|
// and a "latest" module variant for each (<module>, <scope>) pair
|
||||||
moduleName := func(module, scope, version string) string {
|
apiModuleName := func(module, scope, version string) string {
|
||||||
return module + ".api." + scope + "." + version
|
return module + ".api." + scope + "." + version
|
||||||
}
|
}
|
||||||
m := make(map[string]latestApiInfo)
|
m := make(map[string]latestApiInfo)
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
localPath := strings.TrimPrefix(f, mydir)
|
localPath := strings.TrimPrefix(f, mydir)
|
||||||
module, apiver, scope := parseApiFilePath(mctx, localPath)
|
module, apiver, scope := parseApiFilePath(mctx, localPath)
|
||||||
createFilegroup(mctx, moduleName(module, scope, apiver), localPath)
|
createApiModule(mctx, apiModuleName(module, scope, apiver), localPath)
|
||||||
|
|
||||||
version, err := strconv.Atoi(apiver)
|
version, err := strconv.Atoi(apiver)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -239,8 +243,8 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
||||||
// Sort the keys in order to make build.ninja stable
|
// Sort the keys in order to make build.ninja stable
|
||||||
for _, k := range android.SortedStringKeys(m) {
|
for _, k := range android.SortedStringKeys(m) {
|
||||||
info := m[k]
|
info := m[k]
|
||||||
name := moduleName(info.module, info.scope, "latest")
|
name := apiModuleName(info.module, info.scope, "latest")
|
||||||
createFilegroup(mctx, name, info.path)
|
createApiModule(mctx, name, info.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create incompatibilities tracking files for all modules, if we have a "next" api.
|
// Create incompatibilities tracking files for all modules, if we have a "next" api.
|
||||||
|
@ -258,14 +262,14 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
||||||
referencedModule = "android"
|
referencedModule = "android"
|
||||||
}
|
}
|
||||||
|
|
||||||
createFilegroup(mctx, moduleName(referencedModule+"-incompatibilities", scope, "latest"), localPath)
|
createApiModule(mctx, apiModuleName(referencedModule+"-incompatibilities", scope, "latest"), localPath)
|
||||||
|
|
||||||
incompatibilities[referencedModule+"."+scope] = true
|
incompatibilities[referencedModule+"."+scope] = true
|
||||||
}
|
}
|
||||||
// Create empty incompatibilities files for remaining modules
|
// Create empty incompatibilities files for remaining modules
|
||||||
for _, k := range android.SortedStringKeys(m) {
|
for _, k := range android.SortedStringKeys(m) {
|
||||||
if _, ok := incompatibilities[k]; !ok {
|
if _, ok := incompatibilities[k]; !ok {
|
||||||
createEmptyFile(mctx, moduleName(m[k].module+"-incompatibilities", m[k].scope, "latest"))
|
createEmptyFile(mctx, apiModuleName(m[k].module+"-incompatibilities", m[k].scope, "latest"))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -279,10 +283,10 @@ func createPrebuiltApiModules(mctx android.LoadHookContext) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// prebuilt_apis is a meta-module that generates filegroup modules for all
|
// prebuilt_apis is a meta-module that generates modules for all API txt files
|
||||||
// API txt files found under the directory where the Android.bp is located.
|
// found under the directory where the Android.bp is located.
|
||||||
// Specifically, an API file located at ./<ver>/<scope>/api/<module>.txt
|
// Specifically, an API file located at ./<ver>/<scope>/api/<module>.txt
|
||||||
// generates a filegroup module named <module>-api.<scope>.<ver>.
|
// generates a module named <module>-api.<scope>.<ver>.
|
||||||
//
|
//
|
||||||
// It also creates <module>-api.<scope>.latest for the latest <ver>.
|
// It also creates <module>-api.<scope>.latest for the latest <ver>.
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in a new issue