blob: ddf3950098cc7ca0f174231efa67fd2653ce33a0 [file] [log] [blame]
Ivan Lozano183a3212019-10-18 14:18:45 -07001package cc
2
3import (
Ivan Lozano183a3212019-10-18 14:18:45 -07004 "android/soong/android"
Colin Cross6e511a92020-07-27 21:26:48 -07005
6 "github.com/google/blueprint"
Ivan Lozano183a3212019-10-18 14:18:45 -07007)
8
Chris Parsons3c27ca32020-11-20 12:42:07 -05009// LinkableInterface is an interface for a type of module that is linkable in a C++ library.
Ivan Lozano183a3212019-10-18 14:18:45 -070010type LinkableInterface interface {
11 Module() android.Module
12 CcLibrary() bool
13 CcLibraryInterface() bool
14
Ivan Lozano183a3212019-10-18 14:18:45 -070015 OutputFile() android.OptionalPath
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040016 CoverageFiles() android.Paths
Ivan Lozano183a3212019-10-18 14:18:45 -070017
Ivan Lozano2b262972019-11-21 12:30:50 -080018 NonCcVariants() bool
19
Ivan Lozano52767be2019-10-18 14:49:46 -070020 SelectedStl() string
Ivan Lozano183a3212019-10-18 14:18:45 -070021
22 BuildStaticVariant() bool
23 BuildSharedVariant() bool
24 SetStatic()
25 SetShared()
Ivan Lozano52767be2019-10-18 14:49:46 -070026 Static() bool
27 Shared() bool
28 Toc() android.OptionalPath
29
Jooyung Han624d35c2020-04-10 12:57:24 +090030 Host() bool
31
Yifan Hong1b3348d2020-01-21 15:53:22 -080032 InRamdisk() bool
33 OnlyInRamdisk() bool
34
Yifan Hong60e0cfb2020-10-21 15:17:56 -070035 InVendorRamdisk() bool
36 OnlyInVendorRamdisk() bool
37
Ivan Lozano52767be2019-10-18 14:49:46 -070038 InRecovery() bool
39 OnlyInRecovery() bool
40
Colin Crossc511bc52020-04-07 16:50:32 +000041 UseSdk() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070042 UseVndk() bool
43 MustUseVendorVariant() bool
44 IsVndk() bool
45 HasVendorVariant() bool
46
47 SdkVersion() string
Colin Crossc511bc52020-04-07 16:50:32 +000048 AlwaysSdk() bool
Jiyong Park2286afd2020-06-16 21:58:53 +090049 IsSdkVariant() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070050
Colin Cross1348ce32020-10-01 13:37:16 -070051 SplitPerApiLevel() bool
Ivan Lozano183a3212019-10-18 14:18:45 -070052}
53
Colin Cross6e511a92020-07-27 21:26:48 -070054var (
Chris Parsons3c27ca32020-11-20 12:42:07 -050055 // Dependency tag for crtbegin, an object file responsible for initialization.
Colin Cross6e511a92020-07-27 21:26:48 -070056 CrtBeginDepTag = dependencyTag{name: "crtbegin"}
Chris Parsons3c27ca32020-11-20 12:42:07 -050057 // Dependency tag for crtend, an object file responsible for program termination.
58 CrtEndDepTag = dependencyTag{name: "crtend"}
59 // Dependency tag for coverage library.
Colin Cross6e511a92020-07-27 21:26:48 -070060 CoverageDepTag = dependencyTag{name: "coverage"}
61)
Ivan Lozano183a3212019-10-18 14:18:45 -070062
Chris Parsons3c27ca32020-11-20 12:42:07 -050063// SharedDepTag returns the dependency tag for any C++ shared libraries.
Colin Cross6e511a92020-07-27 21:26:48 -070064func SharedDepTag() blueprint.DependencyTag {
65 return libraryDependencyTag{Kind: sharedLibraryDependency}
Ivan Lozano183a3212019-10-18 14:18:45 -070066}
67
Chris Parsons3c27ca32020-11-20 12:42:07 -050068// StaticDepTag returns the dependency tag for any C++ static libraries.
Colin Cross6e511a92020-07-27 21:26:48 -070069func StaticDepTag() blueprint.DependencyTag {
70 return libraryDependencyTag{Kind: staticLibraryDependency}
71}
Colin Cross0de8a1e2020-09-18 14:15:30 -070072
Chris Parsons3c27ca32020-11-20 12:42:07 -050073// HeaderDepTag returns the dependency tag for any C++ "header-only" libraries.
Zach Johnson3df4e632020-11-06 11:56:27 -080074func HeaderDepTag() blueprint.DependencyTag {
75 return libraryDependencyTag{Kind: headerLibraryDependency}
76}
77
Chris Parsons3c27ca32020-11-20 12:42:07 -050078// SharedLibraryInfo is a provider to propagate information about a shared C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -070079type SharedLibraryInfo struct {
80 SharedLibrary android.Path
81 UnstrippedSharedLibrary android.Path
82
83 TableOfContents android.OptionalPath
84 CoverageSharedLibrary android.OptionalPath
85
86 StaticAnalogue *StaticLibraryInfo
87}
88
89var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{})
90
Chris Parsons3c27ca32020-11-20 12:42:07 -050091// SharedStubLibrary is a struct containing information about a stub shared library.
92// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
93// library in another APEX, it must depend on the stub version of that library.
94type SharedStubLibrary struct {
95 // The version of the stub (corresponding to the stable version of the shared library being
96 // stubbed).
Colin Cross0de8a1e2020-09-18 14:15:30 -070097 Version string
98 SharedLibraryInfo SharedLibraryInfo
99 FlagExporterInfo FlagExporterInfo
100}
101
Chris Parsons3c27ca32020-11-20 12:42:07 -0500102// SharedLibraryStubsInfo is a provider to propagate information about all shared library stubs
103// which are dependencies of a library.
104// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
105// library in another APEX, it must depend on the stub version of that library.
106type SharedLibraryStubsInfo struct {
107 SharedStubLibraries []SharedStubLibrary
Colin Cross0de8a1e2020-09-18 14:15:30 -0700108
Chris Parsons3c27ca32020-11-20 12:42:07 -0500109 IsLLNDK bool
110}
111
112var SharedLibraryStubsProvider = blueprint.NewProvider(SharedLibraryStubsInfo{})
113
114// StaticLibraryInfo is a provider to propagate information about a static C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700115type StaticLibraryInfo struct {
116 StaticLibrary android.Path
117 Objects Objects
118 ReuseObjects Objects
119
120 // This isn't the actual transitive DepSet, shared library dependencies have been
121 // converted into static library analogues. It is only used to order the static
122 // library dependencies that were specified for the current module.
123 TransitiveStaticLibrariesForOrdering *android.DepSet
124}
125
126var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
127
Chris Parsons3c27ca32020-11-20 12:42:07 -0500128// FlagExporterInfo is a provider to propagate transitive library information
129// pertaining to exported include paths and flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700130type FlagExporterInfo struct {
Chris Parsons3c27ca32020-11-20 12:42:07 -0500131 IncludeDirs android.Paths // Include directories to be included with -I
132 SystemIncludeDirs android.Paths // System include directories to be included with -isystem
133 Flags []string // Exported raw flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700134 Deps android.Paths
135 GeneratedHeaders android.Paths
136}
137
138var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{})