blob: d0109856a8dde046adb0c3963d689b89db7c6bb5 [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 {
Ivan Lozanof9e21722020-12-02 09:00:51 -050011 android.Module
12
Ivan Lozano183a3212019-10-18 14:18:45 -070013 Module() android.Module
14 CcLibrary() bool
15 CcLibraryInterface() bool
16
Ivan Lozano183a3212019-10-18 14:18:45 -070017 OutputFile() android.OptionalPath
Ivan Lozanoa0cd8f92020-04-09 09:56:02 -040018 CoverageFiles() android.Paths
Ivan Lozano183a3212019-10-18 14:18:45 -070019
Ivan Lozano2b262972019-11-21 12:30:50 -080020 NonCcVariants() bool
21
Ivan Lozano52767be2019-10-18 14:49:46 -070022 SelectedStl() string
Ivan Lozano183a3212019-10-18 14:18:45 -070023
24 BuildStaticVariant() bool
25 BuildSharedVariant() bool
26 SetStatic()
27 SetShared()
Ivan Lozano52767be2019-10-18 14:49:46 -070028 Static() bool
29 Shared() bool
30 Toc() android.OptionalPath
31
Jooyung Han624d35c2020-04-10 12:57:24 +090032 Host() bool
33
Yifan Hong1b3348d2020-01-21 15:53:22 -080034 InRamdisk() bool
35 OnlyInRamdisk() bool
36
Yifan Hong60e0cfb2020-10-21 15:17:56 -070037 InVendorRamdisk() bool
38 OnlyInVendorRamdisk() bool
39
Ivan Lozano52767be2019-10-18 14:49:46 -070040 InRecovery() bool
41 OnlyInRecovery() bool
42
Colin Crossc511bc52020-04-07 16:50:32 +000043 UseSdk() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070044 UseVndk() bool
45 MustUseVendorVariant() bool
46 IsVndk() bool
Ivan Lozanof9e21722020-12-02 09:00:51 -050047 IsVndkExt() bool
48 IsVndkPrivate(config android.Config) bool
Ivan Lozano52767be2019-10-18 14:49:46 -070049 HasVendorVariant() bool
Ivan Lozanof9e21722020-12-02 09:00:51 -050050 InProduct() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070051
52 SdkVersion() string
Colin Crossc511bc52020-04-07 16:50:32 +000053 AlwaysSdk() bool
Jiyong Park2286afd2020-06-16 21:58:53 +090054 IsSdkVariant() bool
Ivan Lozano52767be2019-10-18 14:49:46 -070055
Colin Cross1348ce32020-10-01 13:37:16 -070056 SplitPerApiLevel() bool
Ivan Lozano183a3212019-10-18 14:18:45 -070057}
58
Colin Cross6e511a92020-07-27 21:26:48 -070059var (
Chris Parsons3c27ca32020-11-20 12:42:07 -050060 // Dependency tag for crtbegin, an object file responsible for initialization.
Colin Cross6e511a92020-07-27 21:26:48 -070061 CrtBeginDepTag = dependencyTag{name: "crtbegin"}
Chris Parsons3c27ca32020-11-20 12:42:07 -050062 // Dependency tag for crtend, an object file responsible for program termination.
63 CrtEndDepTag = dependencyTag{name: "crtend"}
64 // Dependency tag for coverage library.
Colin Cross6e511a92020-07-27 21:26:48 -070065 CoverageDepTag = dependencyTag{name: "coverage"}
66)
Ivan Lozano183a3212019-10-18 14:18:45 -070067
Chris Parsons3c27ca32020-11-20 12:42:07 -050068// SharedDepTag returns the dependency tag for any C++ shared libraries.
Colin Cross6e511a92020-07-27 21:26:48 -070069func SharedDepTag() blueprint.DependencyTag {
70 return libraryDependencyTag{Kind: sharedLibraryDependency}
Ivan Lozano183a3212019-10-18 14:18:45 -070071}
72
Chris Parsons3c27ca32020-11-20 12:42:07 -050073// StaticDepTag returns the dependency tag for any C++ static libraries.
Colin Cross6e511a92020-07-27 21:26:48 -070074func StaticDepTag() blueprint.DependencyTag {
75 return libraryDependencyTag{Kind: staticLibraryDependency}
76}
Colin Cross0de8a1e2020-09-18 14:15:30 -070077
Chris Parsons3c27ca32020-11-20 12:42:07 -050078// HeaderDepTag returns the dependency tag for any C++ "header-only" libraries.
Zach Johnson3df4e632020-11-06 11:56:27 -080079func HeaderDepTag() blueprint.DependencyTag {
80 return libraryDependencyTag{Kind: headerLibraryDependency}
81}
82
Chris Parsons3c27ca32020-11-20 12:42:07 -050083// SharedLibraryInfo is a provider to propagate information about a shared C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -070084type SharedLibraryInfo struct {
85 SharedLibrary android.Path
86 UnstrippedSharedLibrary android.Path
87
88 TableOfContents android.OptionalPath
89 CoverageSharedLibrary android.OptionalPath
90
91 StaticAnalogue *StaticLibraryInfo
92}
93
94var SharedLibraryInfoProvider = blueprint.NewProvider(SharedLibraryInfo{})
95
Chris Parsons3c27ca32020-11-20 12:42:07 -050096// SharedStubLibrary is a struct containing information about a stub shared library.
97// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
98// library in another APEX, it must depend on the stub version of that library.
99type SharedStubLibrary struct {
100 // The version of the stub (corresponding to the stable version of the shared library being
101 // stubbed).
Colin Cross0de8a1e2020-09-18 14:15:30 -0700102 Version string
103 SharedLibraryInfo SharedLibraryInfo
104 FlagExporterInfo FlagExporterInfo
105}
106
Chris Parsons3c27ca32020-11-20 12:42:07 -0500107// SharedLibraryStubsInfo is a provider to propagate information about all shared library stubs
108// which are dependencies of a library.
109// Stub libraries are used for cross-APEX dependencies; when a library is to depend on a shared
110// library in another APEX, it must depend on the stub version of that library.
111type SharedLibraryStubsInfo struct {
112 SharedStubLibraries []SharedStubLibrary
Colin Cross0de8a1e2020-09-18 14:15:30 -0700113
Chris Parsons3c27ca32020-11-20 12:42:07 -0500114 IsLLNDK bool
115}
116
117var SharedLibraryStubsProvider = blueprint.NewProvider(SharedLibraryStubsInfo{})
118
119// StaticLibraryInfo is a provider to propagate information about a static C++ library.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700120type StaticLibraryInfo struct {
121 StaticLibrary android.Path
122 Objects Objects
123 ReuseObjects Objects
124
125 // This isn't the actual transitive DepSet, shared library dependencies have been
126 // converted into static library analogues. It is only used to order the static
127 // library dependencies that were specified for the current module.
128 TransitiveStaticLibrariesForOrdering *android.DepSet
129}
130
131var StaticLibraryInfoProvider = blueprint.NewProvider(StaticLibraryInfo{})
132
Colin Cross649d8172020-12-10 12:30:21 -0800133// HeaderLibraryInfo is a marker provider that identifies a module as a header library.
134type HeaderLibraryInfo struct {
135}
136
137// HeaderLibraryInfoProvider is a marker provider that identifies a module as a header library.
138var HeaderLibraryInfoProvider = blueprint.NewProvider(HeaderLibraryInfo{})
139
Chris Parsons3c27ca32020-11-20 12:42:07 -0500140// FlagExporterInfo is a provider to propagate transitive library information
141// pertaining to exported include paths and flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700142type FlagExporterInfo struct {
Chris Parsons3c27ca32020-11-20 12:42:07 -0500143 IncludeDirs android.Paths // Include directories to be included with -I
144 SystemIncludeDirs android.Paths // System include directories to be included with -isystem
145 Flags []string // Exported raw flags.
Colin Cross0de8a1e2020-09-18 14:15:30 -0700146 Deps android.Paths
147 GeneratedHeaders android.Paths
148}
149
150var FlagExporterInfoProvider = blueprint.NewProvider(FlagExporterInfo{})