Merge changes Idc985c52,Ibbbde323,I51417cf6,I9886498d,I195d99c9 am: 6ddb81b0db
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1451109 Change-Id: I354aa7fd48ba6b269edf8ef2fc24c9811f567ab8
This commit is contained in:
@@ -442,6 +442,11 @@ func (c *stubDecorator) AndroidMkEntries(ctx AndroidMkContext, entries *android.
|
|||||||
entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
|
entries.SubName = ndkLibrarySuffix + "." + c.apiLevel.String()
|
||||||
entries.Class = "SHARED_LIBRARIES"
|
entries.Class = "SHARED_LIBRARIES"
|
||||||
|
|
||||||
|
if !c.buildStubs() {
|
||||||
|
entries.Disabled = true
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
|
||||||
path, file := filepath.Split(c.installPath.String())
|
path, file := filepath.Split(c.installPath.String())
|
||||||
stem, suffix, _ := android.SplitFileExt(file)
|
stem, suffix, _ := android.SplitFileExt(file)
|
||||||
|
123
cc/cc.go
123
cc/cc.go
@@ -45,7 +45,6 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
|
|||||||
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
ctx.BottomUp("sdk", sdkMutator).Parallel()
|
||||||
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
ctx.BottomUp("vndk", VndkMutator).Parallel()
|
||||||
ctx.BottomUp("link", LinkageMutator).Parallel()
|
ctx.BottomUp("link", LinkageMutator).Parallel()
|
||||||
ctx.BottomUp("ndk_api", NdkApiMutator).Parallel()
|
|
||||||
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
ctx.BottomUp("test_per_src", TestPerSrcMutator).Parallel()
|
||||||
ctx.BottomUp("version_selector", versionSelectorMutator).Parallel()
|
ctx.BottomUp("version_selector", versionSelectorMutator).Parallel()
|
||||||
ctx.BottomUp("version", versionMutator).Parallel()
|
ctx.BottomUp("version", versionMutator).Parallel()
|
||||||
@@ -718,14 +717,9 @@ func (c *Module) AlwaysSdk() bool {
|
|||||||
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
return c.Properties.AlwaysSdk || Bool(c.Properties.Sdk_variant_only)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) StubsVersions() []string {
|
func (c *Module) StubsVersions(ctx android.BaseMutatorContext) []string {
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
return versioned.stubsVersions(ctx)
|
||||||
return library.Properties.Stubs.Versions
|
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return library.Properties.Stubs.Versions
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
|
panic(fmt.Errorf("StubsVersions called on non-library module: %q", c.BaseModuleName()))
|
||||||
}
|
}
|
||||||
@@ -754,100 +748,48 @@ func (c *Module) NonCcVariants() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) SetBuildStubs() {
|
func (c *Module) SetBuildStubs() {
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
versioned.setBuildStubs()
|
||||||
library.MutatedProperties.BuildStubs = true
|
|
||||||
c.Properties.HideFromMake = true
|
c.Properties.HideFromMake = true
|
||||||
c.sanitize = nil
|
c.sanitize = nil
|
||||||
c.stl = nil
|
c.stl = nil
|
||||||
c.Properties.PreventInstall = true
|
c.Properties.PreventInstall = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
library.MutatedProperties.BuildStubs = true
|
|
||||||
c.Properties.HideFromMake = true
|
|
||||||
c.sanitize = nil
|
|
||||||
c.stl = nil
|
|
||||||
c.Properties.PreventInstall = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if _, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
c.Properties.HideFromMake = true
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
|
panic(fmt.Errorf("SetBuildStubs called on non-library module: %q", c.BaseModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) BuildStubs() bool {
|
func (c *Module) BuildStubs() bool {
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
return versioned.buildStubs()
|
||||||
return library.buildStubs()
|
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return library.buildStubs()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
|
panic(fmt.Errorf("BuildStubs called on non-library module: %q", c.BaseModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) SetAllStubsVersions(versions []string) {
|
func (c *Module) SetAllStubsVersions(versions []string) {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
library.MutatedProperties.AllStubsVersions = versions
|
versioned.setAllStubsVersions(versions)
|
||||||
return
|
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
library.MutatedProperties.AllStubsVersions = versions
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
llndk.libraryDecorator.MutatedProperties.AllStubsVersions = versions
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) AllStubsVersions() []string {
|
func (c *Module) AllStubsVersions() []string {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
return library.MutatedProperties.AllStubsVersions
|
return versioned.allStubsVersions()
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return library.MutatedProperties.AllStubsVersions
|
|
||||||
}
|
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
return llndk.libraryDecorator.MutatedProperties.AllStubsVersions
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) SetStubsVersion(version string) {
|
func (c *Module) SetStubsVersion(version string) {
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
versioned.setStubsVersion(version)
|
||||||
library.MutatedProperties.StubsVersion = version
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
library.MutatedProperties.StubsVersion = version
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
llndk.libraryDecorator.MutatedProperties.StubsVersion = version
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("SetStubsVersion called on non-library module: %q", c.BaseModuleName()))
|
panic(fmt.Errorf("SetStubsVersion called on non-library module: %q", c.BaseModuleName()))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) StubsVersion() string {
|
func (c *Module) StubsVersion() string {
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
return versioned.stubsVersion()
|
||||||
return library.MutatedProperties.StubsVersion
|
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return library.MutatedProperties.StubsVersion
|
|
||||||
}
|
|
||||||
if llndk, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
return llndk.libraryDecorator.MutatedProperties.StubsVersion
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName()))
|
panic(fmt.Errorf("StubsVersion called on non-library module: %q", c.BaseModuleName()))
|
||||||
}
|
}
|
||||||
@@ -1085,22 +1027,15 @@ func (c *Module) getVndkExtendsModuleName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) IsStubs() bool {
|
func (c *Module) IsStubs() bool {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
return library.buildStubs()
|
return versioned.buildStubs()
|
||||||
} else if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return library.buildStubs()
|
|
||||||
} else if _, ok := c.linker.(*llndkStubDecorator); ok {
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Module) HasStubsVariants() bool {
|
func (c *Module) HasStubsVariants() bool {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
return len(library.Properties.Stubs.Versions) > 0
|
return versioned.hasStubsVariants()
|
||||||
}
|
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
return len(library.Properties.Stubs.Versions) > 0
|
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
@@ -1752,7 +1687,7 @@ func GetCrtVariations(ctx android.BottomUpMutatorContext,
|
|||||||
if m.UseSdk() {
|
if m.UseSdk() {
|
||||||
return []blueprint.Variation{
|
return []blueprint.Variation{
|
||||||
{Mutator: "sdk", Variation: "sdk"},
|
{Mutator: "sdk", Variation: "sdk"},
|
||||||
{Mutator: "ndk_api", Variation: m.SdkVersion()},
|
{Mutator: "version", Variation: m.SdkVersion()},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return []blueprint.Variation{
|
return []blueprint.Variation{
|
||||||
@@ -1872,18 +1807,11 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buildStubs := false
|
buildStubs := false
|
||||||
if c.linker != nil {
|
if versioned, ok := c.linker.(versionedInterface); ok {
|
||||||
if library, ok := c.linker.(*libraryDecorator); ok {
|
if versioned.buildStubs() {
|
||||||
if library.buildStubs() {
|
|
||||||
buildStubs = true
|
buildStubs = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if library, ok := c.linker.(*prebuiltLibraryLinker); ok {
|
|
||||||
if library.buildStubs() {
|
|
||||||
buildStubs = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
rewriteSnapshotLibs := func(lib string, snapshotMap *snapshotMap) string {
|
||||||
// only modules with BOARD_VNDK_VERSION uses snapshot.
|
// only modules with BOARD_VNDK_VERSION uses snapshot.
|
||||||
@@ -2025,11 +1953,10 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
actx.AddDependency(c, depTag, gen)
|
actx.AddDependency(c, depTag, gen)
|
||||||
}
|
}
|
||||||
|
|
||||||
actx.AddVariationDependencies(nil, objDepTag, deps.ObjFiles...)
|
|
||||||
|
|
||||||
vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
|
vendorSnapshotObjects := vendorSnapshotObjects(actx.Config())
|
||||||
|
|
||||||
crtVariations := GetCrtVariations(ctx, c)
|
crtVariations := GetCrtVariations(ctx, c)
|
||||||
|
actx.AddVariationDependencies(crtVariations, objDepTag, deps.ObjFiles...)
|
||||||
if deps.CrtBegin != "" {
|
if deps.CrtBegin != "" {
|
||||||
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
|
actx.AddVariationDependencies(crtVariations, CrtBeginDepTag,
|
||||||
rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
|
rewriteSnapshotLibs(deps.CrtBegin, vendorSnapshotObjects))
|
||||||
@@ -2049,13 +1976,13 @@ func (c *Module) DepsMutator(actx android.BottomUpMutatorContext) {
|
|||||||
|
|
||||||
ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version}
|
ndkStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, ndk: true, makeSuffix: "." + version}
|
||||||
actx.AddVariationDependencies([]blueprint.Variation{
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
{Mutator: "ndk_api", Variation: version},
|
{Mutator: "version", Variation: version},
|
||||||
{Mutator: "link", Variation: "shared"},
|
{Mutator: "link", Variation: "shared"},
|
||||||
}, ndkStubDepTag, variantNdkLibs...)
|
}, ndkStubDepTag, variantNdkLibs...)
|
||||||
|
|
||||||
ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version}
|
ndkLateStubDepTag := libraryDependencyTag{Kind: sharedLibraryDependency, Order: lateLibraryDependency, ndk: true, makeSuffix: "." + version}
|
||||||
actx.AddVariationDependencies([]blueprint.Variation{
|
actx.AddVariationDependencies([]blueprint.Variation{
|
||||||
{Mutator: "ndk_api", Variation: version},
|
{Mutator: "version", Variation: version},
|
||||||
{Mutator: "link", Variation: "shared"},
|
{Mutator: "link", Variation: "shared"},
|
||||||
}, ndkLateStubDepTag, variantLateNdkLibs...)
|
}, ndkLateStubDepTag, variantLateNdkLibs...)
|
||||||
|
|
||||||
|
@@ -349,7 +349,7 @@ type libraryDecorator struct {
|
|||||||
// Location of the file that should be copied to dist dir when requested
|
// Location of the file that should be copied to dist dir when requested
|
||||||
distFile android.Path
|
distFile android.Path
|
||||||
|
|
||||||
versionScriptPath android.ModuleGenPath
|
versionScriptPath android.OptionalPath
|
||||||
|
|
||||||
post_install_cmds []string
|
post_install_cmds []string
|
||||||
|
|
||||||
@@ -358,6 +358,8 @@ type libraryDecorator struct {
|
|||||||
useCoreVariant bool
|
useCoreVariant bool
|
||||||
checkSameCoreVariant bool
|
checkSameCoreVariant bool
|
||||||
|
|
||||||
|
skipAPIDefine bool
|
||||||
|
|
||||||
// Decorated interfaces
|
// Decorated interfaces
|
||||||
*baseCompiler
|
*baseCompiler
|
||||||
*baseLinker
|
*baseLinker
|
||||||
@@ -611,7 +613,7 @@ func (library *libraryDecorator) shouldCreateSourceAbiDump(ctx ModuleContext) bo
|
|||||||
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
|
||||||
if library.buildStubs() {
|
if library.buildStubs() {
|
||||||
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
|
objs, versionScript := compileStubLibrary(ctx, flags, String(library.Properties.Stubs.Symbol_file), library.MutatedProperties.StubsVersion, "--apex")
|
||||||
library.versionScriptPath = versionScript
|
library.versionScriptPath = android.OptionalPathForPath(versionScript)
|
||||||
return objs
|
return objs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -661,6 +663,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
|
|||||||
}
|
}
|
||||||
|
|
||||||
type libraryInterface interface {
|
type libraryInterface interface {
|
||||||
|
versionedInterface
|
||||||
|
|
||||||
static() bool
|
static() bool
|
||||||
shared() bool
|
shared() bool
|
||||||
objs() Objects
|
objs() Objects
|
||||||
@@ -681,6 +685,21 @@ type libraryInterface interface {
|
|||||||
availableFor(string) bool
|
availableFor(string) bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type versionedInterface interface {
|
||||||
|
buildStubs() bool
|
||||||
|
setBuildStubs()
|
||||||
|
hasStubsVariants() bool
|
||||||
|
setStubsVersion(string)
|
||||||
|
stubsVersion() string
|
||||||
|
|
||||||
|
stubsVersions(ctx android.BaseMutatorContext) []string
|
||||||
|
setAllStubsVersions([]string)
|
||||||
|
allStubsVersions() []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var _ libraryInterface = (*libraryDecorator)(nil)
|
||||||
|
var _ versionedInterface = (*libraryDecorator)(nil)
|
||||||
|
|
||||||
func (library *libraryDecorator) getLibNameHelper(baseModuleName string, useVndk bool) string {
|
func (library *libraryDecorator) getLibNameHelper(baseModuleName string, useVndk bool) string {
|
||||||
name := library.libName
|
name := library.libName
|
||||||
if name == "" {
|
if name == "" {
|
||||||
@@ -916,10 +935,10 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
|
|||||||
linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
|
linkerDeps = append(linkerDeps, forceWeakSymbols.Path())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if library.buildStubs() {
|
if library.versionScriptPath.Valid() {
|
||||||
linkerScriptFlags := "-Wl,--version-script," + library.versionScriptPath.String()
|
linkerScriptFlags := "-Wl,--version-script," + library.versionScriptPath.String()
|
||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlags)
|
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlags)
|
||||||
linkerDeps = append(linkerDeps, library.versionScriptPath)
|
linkerDeps = append(linkerDeps, library.versionScriptPath.Path())
|
||||||
}
|
}
|
||||||
|
|
||||||
fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
|
fileName := library.getLibName(ctx) + flags.Toolchain.ShlibSuffix()
|
||||||
@@ -1185,8 +1204,8 @@ func (library *libraryDecorator) link(ctx ModuleContext,
|
|||||||
library.addExportedGeneratedHeaders(library.baseCompiler.pathDeps...)
|
library.addExportedGeneratedHeaders(library.baseCompiler.pathDeps...)
|
||||||
}
|
}
|
||||||
|
|
||||||
if library.buildStubs() {
|
if library.buildStubs() && !library.skipAPIDefine {
|
||||||
library.reexportFlags("-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion())
|
library.reexportFlags("-D" + versioningMacroName(ctx.baseModuleName()) + "=" + library.stubsVersion())
|
||||||
}
|
}
|
||||||
|
|
||||||
library.flagExporter.setProvider(ctx)
|
library.flagExporter.setProvider(ctx)
|
||||||
@@ -1353,10 +1372,34 @@ func (library *libraryDecorator) symbolFileForAbiCheck(ctx ModuleContext) *strin
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) hasStubsVariants() bool {
|
||||||
|
return len(library.Properties.Stubs.Versions) > 0
|
||||||
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) stubsVersions(ctx android.BaseMutatorContext) []string {
|
||||||
|
return library.Properties.Stubs.Versions
|
||||||
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) setStubsVersion(version string) {
|
||||||
|
library.MutatedProperties.StubsVersion = version
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) stubsVersion() string {
|
func (library *libraryDecorator) stubsVersion() string {
|
||||||
return library.MutatedProperties.StubsVersion
|
return library.MutatedProperties.StubsVersion
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) setBuildStubs() {
|
||||||
|
library.MutatedProperties.BuildStubs = true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) setAllStubsVersions(versions []string) {
|
||||||
|
library.MutatedProperties.AllStubsVersions = versions
|
||||||
|
}
|
||||||
|
|
||||||
|
func (library *libraryDecorator) allStubsVersions() []string {
|
||||||
|
return library.MutatedProperties.AllStubsVersions
|
||||||
|
}
|
||||||
|
|
||||||
func (library *libraryDecorator) isLatestStubVersion() bool {
|
func (library *libraryDecorator) isLatestStubVersion() bool {
|
||||||
versions := library.Properties.Stubs.Versions
|
versions := library.Properties.Stubs.Versions
|
||||||
return versions[len(versions)-1] == library.stubsVersion()
|
return versions[len(versions)-1] == library.stubsVersion()
|
||||||
@@ -1573,20 +1616,33 @@ func createVersionVariations(mctx android.BottomUpMutatorContext, versions []str
|
|||||||
mctx.CreateAliasVariation("latest", latestVersion)
|
mctx.CreateAliasVariation("latest", latestVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func createPerApiVersionVariations(mctx android.BottomUpMutatorContext, minSdkVersion string) {
|
||||||
|
from, err := nativeApiLevelFromUser(mctx, minSdkVersion)
|
||||||
|
if err != nil {
|
||||||
|
mctx.PropertyErrorf("min_sdk_version", err.Error())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
versionStrs := ndkLibraryVersions(mctx, from)
|
||||||
|
modules := mctx.CreateLocalVariations(versionStrs...)
|
||||||
|
|
||||||
|
for i, module := range modules {
|
||||||
|
module.(*Module).Properties.Sdk_version = StringPtr(versionStrs[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func CanBeOrLinkAgainstVersionVariants(module interface {
|
func CanBeOrLinkAgainstVersionVariants(module interface {
|
||||||
Host() bool
|
Host() bool
|
||||||
InRamdisk() bool
|
InRamdisk() bool
|
||||||
InRecovery() bool
|
InRecovery() bool
|
||||||
UseSdk() bool
|
|
||||||
}) bool {
|
}) bool {
|
||||||
return !module.Host() && !module.InRamdisk() && !module.InRecovery() && !module.UseSdk()
|
return !module.Host() && !module.InRamdisk() && !module.InRecovery()
|
||||||
}
|
}
|
||||||
|
|
||||||
func CanBeVersionVariant(module interface {
|
func CanBeVersionVariant(module interface {
|
||||||
Host() bool
|
Host() bool
|
||||||
InRamdisk() bool
|
InRamdisk() bool
|
||||||
InRecovery() bool
|
InRecovery() bool
|
||||||
UseSdk() bool
|
|
||||||
CcLibraryInterface() bool
|
CcLibraryInterface() bool
|
||||||
Shared() bool
|
Shared() bool
|
||||||
Static() bool
|
Static() bool
|
||||||
@@ -1599,9 +1655,9 @@ func CanBeVersionVariant(module interface {
|
|||||||
// and propagates the value from implementation libraries to llndk libraries with the same name.
|
// and propagates the value from implementation libraries to llndk libraries with the same name.
|
||||||
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
||||||
if library.CcLibrary() && library.BuildSharedVariant() && len(library.StubsVersions()) > 0 {
|
if library.CcLibraryInterface() && library.BuildSharedVariant() {
|
||||||
|
versions := library.StubsVersions(mctx)
|
||||||
versions := library.StubsVersions()
|
if len(versions) > 0 {
|
||||||
normalizeVersions(mctx, versions)
|
normalizeVersions(mctx, versions)
|
||||||
if mctx.Failed() {
|
if mctx.Failed() {
|
||||||
return
|
return
|
||||||
@@ -1611,15 +1667,6 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
library.SetAllStubsVersions(versions)
|
library.SetAllStubsVersions(versions)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if c, ok := library.(*Module); ok && c.IsStubs() {
|
|
||||||
// Get the versions from the implementation module.
|
|
||||||
impls := mctx.GetDirectDepsWithTag(llndkImplDep)
|
|
||||||
if len(impls) > 1 {
|
|
||||||
panic(fmt.Errorf("Expected single implmenetation library, got %d", len(impls)))
|
|
||||||
} else if len(impls) == 1 {
|
|
||||||
c.SetAllStubsVersions(impls[0].(*Module).AllStubsVersions())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1629,6 +1676,16 @@ func versionSelectorMutator(mctx android.BottomUpMutatorContext) {
|
|||||||
func versionMutator(mctx android.BottomUpMutatorContext) {
|
func versionMutator(mctx android.BottomUpMutatorContext) {
|
||||||
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
if library, ok := mctx.Module().(LinkableInterface); ok && CanBeVersionVariant(library) {
|
||||||
createVersionVariations(mctx, library.AllStubsVersions())
|
createVersionVariations(mctx, library.AllStubsVersions())
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if m, ok := mctx.Module().(*Module); ok {
|
||||||
|
if m.SplitPerApiLevel() && m.IsSdkVariant() {
|
||||||
|
if mctx.Os() != android.Android {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
createPerApiVersionVariations(mctx, m.MinSdkVersion())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@ type LinkableInterface interface {
|
|||||||
|
|
||||||
NonCcVariants() bool
|
NonCcVariants() bool
|
||||||
|
|
||||||
StubsVersions() []string
|
StubsVersions(android.BaseMutatorContext) []string
|
||||||
BuildStubs() bool
|
BuildStubs() bool
|
||||||
SetBuildStubs()
|
SetBuildStubs()
|
||||||
SetStubsVersion(string)
|
SetStubsVersion(string)
|
||||||
|
@@ -15,17 +15,14 @@
|
|||||||
package cc
|
package cc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"android/soong/android"
|
"android/soong/android"
|
||||||
|
|
||||||
"github.com/google/blueprint"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var llndkImplDep = struct {
|
var llndkImplDep = dependencyTag{name: "llndk impl"}
|
||||||
blueprint.DependencyTag
|
|
||||||
}{}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
llndkLibrarySuffix = ".llndk"
|
llndkLibrarySuffix = ".llndk"
|
||||||
@@ -72,9 +69,6 @@ type llndkStubDecorator struct {
|
|||||||
|
|
||||||
Properties llndkLibraryProperties
|
Properties llndkLibraryProperties
|
||||||
|
|
||||||
exportHeadersTimestamp android.OptionalPath
|
|
||||||
versionScriptPath android.ModuleGenPath
|
|
||||||
|
|
||||||
movedToApex bool
|
movedToApex bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,7 +87,9 @@ func (stub *llndkStubDecorator) compile(ctx ModuleContext, flags Flags, deps Pat
|
|||||||
vndkVer = stub.stubsVersion()
|
vndkVer = stub.stubsVersion()
|
||||||
}
|
}
|
||||||
objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), vndkVer, "--llndk")
|
objs, versionScript := compileStubLibrary(ctx, flags, String(stub.Properties.Symbol_file), vndkVer, "--llndk")
|
||||||
stub.versionScriptPath = versionScript
|
if !Bool(stub.Properties.Unversioned) {
|
||||||
|
stub.versionScriptPath = android.OptionalPathForPath(versionScript)
|
||||||
|
}
|
||||||
return objs
|
return objs
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,12 +138,6 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
|
|||||||
stub.movedToApex = implApexModule.DirectlyInAnyApex()
|
stub.movedToApex = implApexModule.DirectlyInAnyApex()
|
||||||
}
|
}
|
||||||
|
|
||||||
if !Bool(stub.Properties.Unversioned) {
|
|
||||||
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
|
|
||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
|
|
||||||
flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
|
|
||||||
}
|
|
||||||
|
|
||||||
if len(stub.Properties.Export_preprocessed_headers) > 0 {
|
if len(stub.Properties.Export_preprocessed_headers) > 0 {
|
||||||
genHeaderOutDir := android.PathForModuleGen(ctx, "include")
|
genHeaderOutDir := android.PathForModuleGen(ctx, "include")
|
||||||
|
|
||||||
@@ -170,10 +160,6 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
|
|||||||
stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{}
|
stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{}
|
||||||
}
|
}
|
||||||
|
|
||||||
if stub.stubsVersion() != "" {
|
|
||||||
stub.reexportFlags("-D" + versioningMacroName(ctx.baseModuleName()) + "=" + stub.stubsVersion())
|
|
||||||
}
|
|
||||||
|
|
||||||
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +167,21 @@ func (stub *llndkStubDecorator) nativeCoverage() bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (stub *llndkStubDecorator) buildStubs() bool {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
func (stub *llndkStubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string {
|
||||||
|
// Get the versions from the implementation module.
|
||||||
|
impls := ctx.GetDirectDepsWithTag(llndkImplDep)
|
||||||
|
if len(impls) > 1 {
|
||||||
|
panic(fmt.Errorf("Expected single implmenetation library, got %d", len(impls)))
|
||||||
|
} else if len(impls) == 1 {
|
||||||
|
return impls[0].(*Module).AllStubsVersions()
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func NewLLndkStubLibrary() *Module {
|
func NewLLndkStubLibrary() *Module {
|
||||||
module, library := NewLibrary(android.DeviceSupported)
|
module, library := NewLibrary(android.DeviceSupported)
|
||||||
library.BuildOnlyShared()
|
library.BuildOnlyShared()
|
||||||
|
@@ -80,9 +80,6 @@ type libraryProperties struct {
|
|||||||
// https://github.com/android-ndk/ndk/issues/265.
|
// https://github.com/android-ndk/ndk/issues/265.
|
||||||
Unversioned_until *string
|
Unversioned_until *string
|
||||||
|
|
||||||
// Use via apiLevel on the stubDecorator.
|
|
||||||
ApiLevel string `blueprint:"mutated"`
|
|
||||||
|
|
||||||
// True if this API is not yet ready to be shipped in the NDK. It will be
|
// True if this API is not yet ready to be shipped in the NDK. It will be
|
||||||
// available in the platform for testing, but will be excluded from the
|
// available in the platform for testing, but will be excluded from the
|
||||||
// sysroot provided to the NDK proper.
|
// sysroot provided to the NDK proper.
|
||||||
@@ -107,9 +104,7 @@ func shouldUseVersionScript(ctx BaseModuleContext, stub *stubDecorator) bool {
|
|||||||
return stub.apiLevel.GreaterThanOrEqualTo(stub.unversionedUntil)
|
return stub.apiLevel.GreaterThanOrEqualTo(stub.unversionedUntil)
|
||||||
}
|
}
|
||||||
|
|
||||||
func generatePerApiVariants(ctx android.BottomUpMutatorContext, m *Module,
|
func ndkLibraryVersions(ctx android.BaseMutatorContext, from android.ApiLevel) []string {
|
||||||
from android.ApiLevel, perSplit func(*Module, android.ApiLevel)) {
|
|
||||||
|
|
||||||
var versions []android.ApiLevel
|
var versions []android.ApiLevel
|
||||||
versionStrs := []string{}
|
versionStrs := []string{}
|
||||||
for _, version := range ctx.Config().AllSupportedApiLevels() {
|
for _, version := range ctx.Config().AllSupportedApiLevels() {
|
||||||
@@ -118,56 +113,26 @@ func generatePerApiVariants(ctx android.BottomUpMutatorContext, m *Module,
|
|||||||
versionStrs = append(versionStrs, version.String())
|
versionStrs = append(versionStrs, version.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
versions = append(versions, android.FutureApiLevel)
|
|
||||||
versionStrs = append(versionStrs, android.FutureApiLevel.String())
|
versionStrs = append(versionStrs, android.FutureApiLevel.String())
|
||||||
|
|
||||||
modules := ctx.CreateVariations(versionStrs...)
|
return versionStrs
|
||||||
for i, module := range modules {
|
|
||||||
perSplit(module.(*Module), versions[i])
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func NdkApiMutator(ctx android.BottomUpMutatorContext) {
|
func (this *stubDecorator) stubsVersions(ctx android.BaseMutatorContext) []string {
|
||||||
if m, ok := ctx.Module().(*Module); ok {
|
if !ctx.Module().Enabled() {
|
||||||
if m.Enabled() {
|
return nil
|
||||||
if compiler, ok := m.compiler.(*stubDecorator); ok {
|
|
||||||
if ctx.Os() != android.Android {
|
|
||||||
// These modules are always android.DeviceEnabled only, but
|
|
||||||
// those include Fuchsia devices, which we don't support.
|
|
||||||
ctx.Module().Disable()
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
firstVersion, err := nativeApiLevelFromUser(ctx,
|
firstVersion, err := nativeApiLevelFromUser(ctx,
|
||||||
String(compiler.properties.First_version))
|
String(this.properties.First_version))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ctx.PropertyErrorf("first_version", err.Error())
|
ctx.PropertyErrorf("first_version", err.Error())
|
||||||
return
|
return nil
|
||||||
}
|
|
||||||
generatePerApiVariants(ctx, m, firstVersion,
|
|
||||||
func(m *Module, version android.ApiLevel) {
|
|
||||||
m.compiler.(*stubDecorator).properties.ApiLevel =
|
|
||||||
version.String()
|
|
||||||
})
|
|
||||||
} else if m.SplitPerApiLevel() && m.IsSdkVariant() {
|
|
||||||
if ctx.Os() != android.Android {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
from, err := nativeApiLevelFromUser(ctx, m.MinSdkVersion())
|
|
||||||
if err != nil {
|
|
||||||
ctx.PropertyErrorf("min_sdk_version", err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
generatePerApiVariants(ctx, m, from,
|
|
||||||
func(m *Module, version android.ApiLevel) {
|
|
||||||
m.Properties.Sdk_version = StringPtr(version.String())
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return ndkLibraryVersions(ctx, firstVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
func (this *stubDecorator) initializeProperties(ctx BaseModuleContext) bool {
|
||||||
this.apiLevel = nativeApiLevelOrPanic(ctx, this.properties.ApiLevel)
|
this.apiLevel = nativeApiLevelOrPanic(ctx, this.stubsVersion())
|
||||||
|
|
||||||
var err error
|
var err error
|
||||||
this.firstVersion, err = nativeApiLevelFromUser(ctx,
|
this.firstVersion, err = nativeApiLevelFromUser(ctx,
|
||||||
@@ -280,6 +245,11 @@ func (c *stubDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) O
|
|||||||
ctx.PropertyErrorf("symbol_file", "must end with .map.txt")
|
ctx.PropertyErrorf("symbol_file", "must end with .map.txt")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if !c.buildStubs() {
|
||||||
|
// NDK libraries have no implementation variant, nothing to do
|
||||||
|
return Objects{}
|
||||||
|
}
|
||||||
|
|
||||||
if !c.initializeProperties(ctx) {
|
if !c.initializeProperties(ctx) {
|
||||||
// Emits its own errors, so we don't need to.
|
// Emits its own errors, so we don't need to.
|
||||||
return Objects{}
|
return Objects{}
|
||||||
@@ -311,12 +281,18 @@ func (stub *stubDecorator) linkerFlags(ctx ModuleContext, flags Flags) Flags {
|
|||||||
func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
|
||||||
objs Objects) android.Path {
|
objs Objects) android.Path {
|
||||||
|
|
||||||
|
if !stub.buildStubs() {
|
||||||
|
// NDK libraries have no implementation variant, nothing to do
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
if shouldUseVersionScript(ctx, stub) {
|
if shouldUseVersionScript(ctx, stub) {
|
||||||
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
|
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
|
||||||
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
|
flags.Local.LdFlags = append(flags.Local.LdFlags, linkerScriptFlag)
|
||||||
flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
|
flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stub.libraryDecorator.skipAPIDefine = true
|
||||||
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
return stub.libraryDecorator.link(ctx, flags, deps, objs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -131,7 +131,7 @@ func (n *ndkSingleton) GenerateBuildActions(ctx android.SingletonContext) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if m, ok := module.(*Module); ok {
|
if m, ok := module.(*Module); ok {
|
||||||
if installer, ok := m.installer.(*stubDecorator); ok {
|
if installer, ok := m.installer.(*stubDecorator); ok && m.BuildStubs() {
|
||||||
if ctx.Config().ExcludeDraftNdkApis() &&
|
if ctx.Config().ExcludeDraftNdkApis() &&
|
||||||
installer.properties.Draft {
|
installer.properties.Draft {
|
||||||
return
|
return
|
||||||
|
@@ -500,7 +500,7 @@ func (mod *Module) Module() android.Module {
|
|||||||
return mod
|
return mod
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mod *Module) StubsVersions() []string {
|
func (mod *Module) StubsVersions(ctx android.BaseMutatorContext) []string {
|
||||||
// For now, Rust has no stubs versions.
|
// For now, Rust has no stubs versions.
|
||||||
if mod.compiler != nil {
|
if mod.compiler != nil {
|
||||||
if _, ok := mod.compiler.(libraryInterface); ok {
|
if _, ok := mod.compiler.(libraryInterface); ok {
|
||||||
|
Reference in New Issue
Block a user