platform_build_soong/cc/linkable.go

144 lines
4.3 KiB
Go
Raw Normal View History

package cc
import (
"android/soong/android"
"github.com/google/blueprint"
)
// LinkableInterface is an interface for a type of module that is linkable in a C++ library.
type LinkableInterface interface {
android.Module
Module() android.Module
CcLibrary() bool
CcLibraryInterface() bool
OutputFile() android.OptionalPath
CoverageFiles() android.Paths
NonCcVariants() bool
SelectedStl() string
BuildStaticVariant() bool
BuildSharedVariant() bool
SetStatic()
SetShared()
Static() bool
Shared() bool
Toc() android.OptionalPath
Host() bool
InRamdisk() bool
OnlyInRamdisk() bool
InVendorRamdisk() bool
OnlyInVendorRamdisk() bool
InRecovery() bool
OnlyInRecovery() bool
UseSdk() bool
UseVndk() bool
MustUseVendorVariant() bool
IsVndk() bool
IsVndkExt() bool
IsVndkPrivate(config android.Config) bool
HasVendorVariant() bool
InProduct() bool
SdkVersion() string
AlwaysSdk() bool
Don't create version variants for SDK variants When a lib has sdk_version set, an SDK variant and a platform variant are created by the sdkMutator. Then by the versionMutator, if the library had 'stubs.versions' property, one or more versioned variants and one impl variant are created for each of the two (SDK and platform) variants. As a concrete example, cc_library { name: "foo", sdk_version: "current", stubs: { versions: ["1", "2"], }, } would create 6 variants: 1) (sdk: "", version: "") 2) (sdk: "", version: "1") 3) (sdk: "", version: "2") 4) (sdk: "sdk", version: "") 5) (sdk: "sdk", version: "1") 6) (sdk: "sdk", version: "2") This is somewhat uncessary because the need for the SDK mutator is to have the platform variant (sdk:"") of a lib where sdk_version is unset, which actually makes sens for the impl variant (version:""), but not the versioned variants (version:"1" or version:"2"). This is not only unncessary, but also causes duplicate module definitions in the Make side when doing an unbundled build. Specifically, The #1 and #4 above both are emitted to Make and get the same name "foo". To fix the problem and not to create unnecessary variants, the versioned variants are no longer created for the sdk variant. So, foo now has the following variants only. 1) (sdk: "", version: "") // not emitted to Make (by versionMutator) 2) (sdk: "", version: "1") // not emitted to Make (by versionMutator) 3) (sdk: "", version: "2") // emitted to Make (by versionMutator) 4) (sdk: "sdk", version: "") // not emitted to Make (by versionMutator) Bug: 159106705 Test: Add sdk_version:"minimum" to libnativehelper in libnativehelper/Android.bp. m SOONG_ALLOW_MISSING_DEPENDENCIES=true TARGET_BUILD_UNBUNDLED=true libnativehelper Change-Id: I6f02f4189e5504286174ccff1642166da82d00c9
2020-06-16 20:58:53 +08:00
IsSdkVariant() bool
SplitPerApiLevel() bool
}
var (
// Dependency tag for crtbegin, an object file responsible for initialization.
CrtBeginDepTag = dependencyTag{name: "crtbegin"}
// Dependency tag for crtend, an object file responsible for program termination.
CrtEndDepTag = dependencyTag{name: "crtend"}
// Dependency tag for coverage library.
CoverageDepTag = dependencyTag{name: "coverage"}
)
// SharedDepTag returns the dependency tag for any C++ shared libraries.
func SharedDepTag() blueprint.DependencyTag {
return libraryDependencyTag{Kind: sharedLibraryDependency}
}
// StaticDepTag returns the dependency tag for any C++ static libraries.
func StaticDepTag() blueprint.DependencyTag {
return libraryDependencyTag{Kind: staticLibraryDependency}
}
// HeaderDepTag returns the dependency tag for any C++ "header-only" libraries.
func HeaderDepTag() blueprint.DependencyTag {
return libraryDependencyTag{Kind: headerLibraryDependency}
}
// SharedLibraryInfo is a provider to propagate information about a shared C++ library.
type SharedLibraryInfo struct {
SharedLibrary android.Path
UnstrippedSharedLibrary android.Path
TableOfContents android.OptionalPath
CoverageSharedLibrary android.OptionalPath
StaticAnalogue *StaticLibraryInfo
}
var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{})
// SharedStubLibrary is a struct containing information about a stub shared library.
// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
// library in another APEX, it must depend on the stub version of that library.
type SharedStubLibrary struct {
// The version of the stub (corresponding to the stable version of the shared library being
// stubbed).
Version string
SharedLibraryInfo SharedLibraryInfo
FlagExporterInfo FlagExporterInfo
}
// SharedLibraryStubsInfo is a provider to propagate information about all shared library stubs
// which are dependencies of a library.
// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
// library in another APEX, it must depend on the stub version of that library.
type SharedLibraryStubsInfo struct {
SharedStubLibraries []SharedStubLibrary
IsLLNDK bool
}
var SharedLibraryStubsProvider = blueprint.NewProvider(SharedLibraryStubsInfo{})
// StaticLibraryInfo is a provider to propagate information about a static C++ library.
type StaticLibraryInfo struct {
StaticLibrary android.Path
Objects Objects
ReuseObjects Objects
// This isn't the actual transitive DepSet, shared library dependencies have been
// converted into static library analogues. It is only used to order the static
// library dependencies that were specified for the current module.
TransitiveStaticLibrariesForOrdering *android.DepSet
}
var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
// FlagExporterInfo is a provider to propagate transitive library information
// pertaining to exported include paths and flags.
type FlagExporterInfo struct {
IncludeDirs android.Paths // Include directories to be included with -I
SystemIncludeDirs android.Paths // System include directories to be included with -isystem
Flags []string // Exported raw flags.
Deps android.Paths
GeneratedHeaders android.Paths
}
var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{})