Generate "current" API level.

Support for using this coming in an upcoming patch.

Test: nose2
      readelf to check the following:
      * bsd_signal unversioned before current
      * bsd_signal versioned in current
      * catclose missing before current
      * catclose present and versioned in current
Bug: None
Change-Id: I861862161426d3ec5b530e3156d3a8ae96fed468
This commit is contained in:
Dan Albert
2016-11-08 13:35:12 -08:00
parent 073379e549
commit fd86e9ee21
4 changed files with 33 additions and 14 deletions

View File

@@ -88,7 +88,7 @@ type libraryProperties struct {
First_version string
// Private property for use by the mutator that splits per-API level.
ApiLevel int `blueprint:"mutated"`
ApiLevel string `blueprint:"mutated"`
}
type stubDecorator struct {
@@ -147,14 +147,15 @@ func generateStubApiVariants(mctx android.BottomUpMutatorContext, c *stubDecorat
mctx.PropertyErrorf("first_version", err.Error())
}
versionStrs := make([]string, maxVersion-firstVersion+1)
var versionStrs []string
for version := firstVersion; version <= maxVersion; version++ {
versionStrs[version-firstVersion] = strconv.Itoa(version)
versionStrs = append(versionStrs, strconv.Itoa(version))
}
versionStrs = append(versionStrs, "current")
modules := mctx.CreateVariations(versionStrs...)
for i, module := range modules {
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = firstVersion + i
module.(*Module).compiler.(*stubDecorator).properties.ApiLevel = versionStrs[i]
}
}
@@ -188,7 +189,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
ndkLibrarySuffix)
}
libName := strings.TrimSuffix(ctx.ModuleName(), ndkLibrarySuffix)
fileBase := fmt.Sprintf("%s.%s.%d", libName, arch, c.properties.ApiLevel)
fileBase := fmt.Sprintf("%s.%s.%s", libName, arch, c.properties.ApiLevel)
stubSrcName := fileBase + ".c"
stubSrcPath := android.PathForModuleGen(ctx, stubSrcName)
versionScriptName := fileBase + ".map"
@@ -201,7 +202,7 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
Input: symbolFilePath,
Args: map[string]string{
"arch": arch,
"apiLevel": strconv.Itoa(c.properties.ApiLevel),
"apiLevel": c.properties.ApiLevel,
},
})
@@ -252,7 +253,7 @@ func (stub *stubDecorator) install(ctx ModuleContext, path android.Path) {
}
installDir := getNdkInstallBase(ctx).Join(ctx, fmt.Sprintf(
"platforms/android-%d/arch-%s/usr/%s", apiLevel, arch, libDir))
"platforms/android-%s/arch-%s/usr/%s", apiLevel, arch, libDir))
stub.installPath = ctx.InstallFile(installDir, path).String()
}