Merge "Minor cleanup in prebuilt_apis"
This commit is contained in:
@@ -15,7 +15,7 @@
|
|||||||
package java
|
package java
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"sort"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/google/blueprint/proptools"
|
"github.com/google/blueprint/proptools"
|
||||||
@@ -173,39 +173,38 @@ func prebuiltApiFiles(mctx android.LoadHookContext, p *prebuiltApis) {
|
|||||||
// construct a map to find out the latest api file path
|
// construct a map to find out the latest api file path
|
||||||
// for each (<module>, <scope>) pair.
|
// for each (<module>, <scope>) pair.
|
||||||
type latestApiInfo struct {
|
type latestApiInfo struct {
|
||||||
module string
|
module string
|
||||||
scope string
|
scope string
|
||||||
apiver string
|
version int
|
||||||
path string
|
path string
|
||||||
}
|
}
|
||||||
m := make(map[string]latestApiInfo)
|
|
||||||
|
|
||||||
|
// Create filegroups for all (<module>, <scope, <version>) triplets,
|
||||||
|
// and a "latest" filegroup variant for each (<module>, <scope>) pair
|
||||||
|
m := make(map[string]latestApiInfo)
|
||||||
for _, f := range files {
|
for _, f := range files {
|
||||||
// create a filegroup for each api txt file
|
|
||||||
localPath := strings.TrimPrefix(f, mydir)
|
localPath := strings.TrimPrefix(f, mydir)
|
||||||
module, apiver, scope := parseApiFilePath(mctx, localPath)
|
module, apiver, scope := parseApiFilePath(mctx, localPath)
|
||||||
createFilegroup(mctx, module, scope, apiver, localPath)
|
createFilegroup(mctx, module, scope, apiver, localPath)
|
||||||
|
|
||||||
// find the latest apiver
|
version, err := strconv.Atoi(apiver)
|
||||||
|
if err != nil {
|
||||||
|
mctx.ModuleErrorf("Found finalized API files in non-numeric dir %v", apiver)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
key := module + "." + scope
|
key := module + "." + scope
|
||||||
info, ok := m[key]
|
info, ok := m[key]
|
||||||
if !ok {
|
if !ok {
|
||||||
m[key] = latestApiInfo{module, scope, apiver, localPath}
|
m[key] = latestApiInfo{module, scope, version, localPath}
|
||||||
} else if len(apiver) > len(info.apiver) || (len(apiver) == len(info.apiver) &&
|
} else if version > info.version {
|
||||||
strings.Compare(apiver, info.apiver) > 0) {
|
info.version = version
|
||||||
info.apiver = apiver
|
|
||||||
info.path = localPath
|
info.path = localPath
|
||||||
m[key] = info
|
m[key] = info
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create filegroups for the latest version of (<module>, <scope>) pairs
|
// 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) {
|
||||||
keys := make([]string, 0, len(m))
|
|
||||||
for k := range m {
|
|
||||||
keys = append(keys, k)
|
|
||||||
}
|
|
||||||
sort.Strings(keys)
|
|
||||||
for _, k := range keys {
|
|
||||||
info := m[k]
|
info := m[k]
|
||||||
createFilegroup(mctx, info.module, info.scope, "latest", info.path)
|
createFilegroup(mctx, info.module, info.scope, "latest", info.path)
|
||||||
}
|
}
|
||||||
|
@@ -86,8 +86,11 @@ func prebuiltApisFilesForLibs(apiLevels []string, sdkLibs []string) map[string][
|
|||||||
for _, lib := range sdkLibs {
|
for _, lib := range sdkLibs {
|
||||||
for _, scope := range []string{"public", "system", "module-lib", "system-server", "test"} {
|
for _, scope := range []string{"public", "system", "module-lib", "system-server", "test"} {
|
||||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, scope, lib)] = nil
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/%s.jar", level, scope, lib)] = nil
|
||||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, scope, lib)] = nil
|
// No finalized API files for "current"
|
||||||
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, scope, lib)] = nil
|
if level != "current" {
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s.txt", level, scope, lib)] = nil
|
||||||
|
fs[fmt.Sprintf("prebuilts/sdk/%s/%s/api/%s-removed.txt", level, scope, lib)] = nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs[fmt.Sprintf("prebuilts/sdk/%s/public/framework.aidl", level)] = nil
|
fs[fmt.Sprintf("prebuilts/sdk/%s/public/framework.aidl", level)] = nil
|
||||||
|
Reference in New Issue
Block a user