1package {
2    // See: http://go/android-license-faq
3    // A large-scale-change added 'default_applicable_licenses' to import
4    // all of the 'license_kinds' from "frameworks_native_license"
5    // to get the below license kinds:
6    //   SPDX-license-identifier-Apache-2.0
7    default_applicable_licenses: ["frameworks_native_license"],
8    default_team: "trendy_team_android_core_graphics_stack",
9}
10
11aconfig_declarations {
12    name: "surfaceflinger_flags",
13    package: "com.android.graphics.surfaceflinger.flags",
14    container: "system",
15    srcs: [
16        "surfaceflinger_flags.aconfig",
17        "surfaceflinger_flags_new.aconfig",
18    ],
19}
20
21cc_aconfig_library {
22    name: "libsurfaceflingerflags",
23    aconfig_declarations: "surfaceflinger_flags",
24}
25
26cc_defaults {
27    name: "surfaceflinger_defaults",
28    cflags: [
29        "-Wall",
30        "-Werror",
31        "-Wextra",
32        "-Wformat",
33        "-Wthread-safety",
34        "-Wunused",
35        "-Wunreachable-code",
36        "-Wconversion",
37        "-DANDROID_UTILS_REF_BASE_DISABLE_IMPLICIT_CONSTRUCTION",
38    ],
39}
40
41cc_defaults {
42    name: "libsurfaceflinger_defaults",
43    defaults: [
44        "android.hardware.graphics.composer3-ndk_shared",
45        "android.hardware.power-ndk_shared",
46        "librenderengine_deps",
47        "libtimestats_deps",
48        "libsurfaceflinger_common_deps",
49        "surfaceflinger_defaults",
50    ],
51    cflags: [
52        "-DLOG_TAG=\"SurfaceFlinger\"",
53        "-DGL_GLEXT_PROTOTYPES",
54        "-DEGL_EGLEXT_PROTOTYPES",
55    ],
56    shared_libs: [
57        "android.hardware.configstore-utils",
58        "android.hardware.configstore@1.0",
59        "android.hardware.configstore@1.1",
60        "android.hardware.graphics.allocator@2.0",
61        "android.hardware.graphics.allocator@3.0",
62        "android.hardware.graphics.common@1.2",
63        "android.hardware.common-V2-ndk",
64        "android.hardware.common.fmq-V1-ndk",
65        "android.hardware.graphics.composer@2.1",
66        "android.hardware.graphics.composer@2.2",
67        "android.hardware.graphics.composer@2.3",
68        "android.hardware.graphics.composer@2.4",
69        "libbase",
70        "libbinder",
71        "libbinder_ndk",
72        "libcutils",
73        "libEGL",
74        "libfmq",
75        "libGLESv1_CM",
76        "libGLESv2",
77        "libgui",
78        "libhidlbase",
79        "liblog",
80        "libnativewindow",
81        "libpowermanager",
82        "libprocessgroup",
83        "libprotobuf-cpp-lite",
84        "libsync",
85        "libui",
86        "libutils",
87        "libSurfaceFlingerProp",
88        "libaconfig_storage_read_api_cc"
89    ],
90    static_libs: [
91        "iinputflinger_aidl_lib_static",
92        "libaidlcommonsupport",
93        "libcompositionengine",
94        "libframetimeline",
95        "libgui_aidl_static",
96        "liblayers_proto",
97        "libperfetto_client_experimental",
98        "librenderengine",
99        "libscheduler",
100        "libserviceutils",
101        "libshaders",
102        "libsurfaceflingerflags",
103        "libtimestats",
104        "libtonemap",
105    ],
106    header_libs: [
107        "android.hardware.graphics.composer@2.1-command-buffer",
108        "android.hardware.graphics.composer@2.2-command-buffer",
109        "android.hardware.graphics.composer@2.3-command-buffer",
110        "android.hardware.graphics.composer@2.4-command-buffer",
111        "android.hardware.graphics.composer3-command-buffer",
112    ],
113    export_static_lib_headers: [
114        "libcompositionengine",
115        "librenderengine",
116        "libserviceutils",
117        "libtimestats",
118    ],
119    export_shared_lib_headers: [
120        "android.hardware.graphics.allocator@2.0",
121        "android.hardware.graphics.allocator@3.0",
122        "android.hardware.graphics.common@1.2",
123        "android.hardware.graphics.composer@2.1",
124        "android.hardware.graphics.composer@2.2",
125        "android.hardware.graphics.composer@2.3",
126        "android.hardware.graphics.composer@2.4",
127        "libpowermanager",
128        "libhidlbase",
129    ],
130    // TODO (marissaw): this library is not used by surfaceflinger. This is here so
131    // the library compiled in a way that is accessible to system partition when running
132    // IMapper's VTS.
133    required: ["libgralloctypes"],
134}
135
136cc_defaults {
137    name: "libsurfaceflinger_production_defaults",
138    defaults: ["libsurfaceflinger_defaults"],
139    lto: {
140        thin: true,
141    },
142    whole_program_vtables: true, // Requires ThinLTO
143    afdo: true,
144    // TODO(b/131771163): Fix broken fuzzer support with LTO.
145    sanitize: {
146        fuzzer: false,
147    },
148}
149
150cc_library_headers {
151    name: "libsurfaceflinger_headers",
152    export_include_dirs: ["."],
153    static_libs: ["libserviceutils"],
154    export_static_lib_headers: ["libserviceutils"],
155}
156
157filegroup {
158    name: "libsurfaceflinger_sources",
159    srcs: [
160        "BackgroundExecutor.cpp",
161        "Client.cpp",
162        "ClientCache.cpp",
163        "Display/DisplayModeController.cpp",
164        "Display/DisplaySnapshot.cpp",
165        "DisplayDevice.cpp",
166        "DisplayHardware/AidlComposerHal.cpp",
167        "DisplayHardware/ComposerHal.cpp",
168        "DisplayHardware/FramebufferSurface.cpp",
169        "DisplayHardware/HWC2.cpp",
170        "DisplayHardware/HWComposer.cpp",
171        "DisplayHardware/HidlComposerHal.cpp",
172        "DisplayHardware/PowerAdvisor.cpp",
173        "DisplayHardware/VirtualDisplaySurface.cpp",
174        "DisplayRenderArea.cpp",
175        "Effects/Daltonizer.cpp",
176        "EventLog/EventLog.cpp",
177        "FrontEnd/LayerCreationArgs.cpp",
178        "FrontEnd/LayerHandle.cpp",
179        "FrontEnd/LayerSnapshot.cpp",
180        "FrontEnd/LayerSnapshotBuilder.cpp",
181        "FrontEnd/LayerHierarchy.cpp",
182        "FrontEnd/LayerLifecycleManager.cpp",
183        "FrontEnd/RequestedLayerState.cpp",
184        "FrontEnd/TransactionHandler.cpp",
185        "FpsReporter.cpp",
186        "FrameTracer/FrameTracer.cpp",
187        "FrameTracker.cpp",
188        "HdrLayerInfoReporter.cpp",
189        "HdrSdrRatioOverlay.cpp",
190        "WindowInfosListenerInvoker.cpp",
191        "Layer.cpp",
192        "LayerFE.cpp",
193        "LayerProtoHelper.cpp",
194        "LayerRenderArea.cpp",
195        "LayerVector.cpp",
196        "NativeWindowSurface.cpp",
197        "RefreshRateOverlay.cpp",
198        "RegionSamplingThread.cpp",
199        "RenderArea.cpp",
200        "Scheduler/EventThread.cpp",
201        "Scheduler/FrameRateOverrideMappings.cpp",
202        "Scheduler/OneShotTimer.cpp",
203        "Scheduler/LayerHistory.cpp",
204        "Scheduler/LayerInfo.cpp",
205        "Scheduler/MessageQueue.cpp",
206        "Scheduler/RefreshRateSelector.cpp",
207        "Scheduler/Scheduler.cpp",
208        "Scheduler/SmallAreaDetectionAllowMappings.cpp",
209        "Scheduler/VSyncDispatchTimerQueue.cpp",
210        "Scheduler/VSyncPredictor.cpp",
211        "Scheduler/VSyncReactor.cpp",
212        "Scheduler/VsyncConfiguration.cpp",
213        "Scheduler/VsyncModulator.cpp",
214        "Scheduler/VsyncSchedule.cpp",
215        "ScreenCaptureOutput.cpp",
216        "SurfaceFlinger.cpp",
217        "SurfaceFlingerDefaultFactory.cpp",
218        "Tracing/LayerDataSource.cpp",
219        "Tracing/LayerTracing.cpp",
220        "Tracing/TransactionDataSource.cpp",
221        "Tracing/TransactionTracing.cpp",
222        "Tracing/TransactionProtoParser.cpp",
223        "Tracing/tools/LayerTraceGenerator.cpp",
224        "TransactionCallbackInvoker.cpp",
225        "TunnelModeEnabledReporter.cpp",
226    ],
227}
228
229cc_defaults {
230    name: "libsurfaceflinger_binary",
231    defaults: [
232        "surfaceflinger_defaults",
233        "libsurfaceflinger_production_defaults",
234    ],
235    cflags: [
236        "-DLOG_TAG=\"SurfaceFlinger\"",
237    ],
238    shared_libs: [
239        "android.hardware.configstore-utils",
240        "android.hardware.configstore@1.0",
241        "android.hardware.graphics.allocator@2.0",
242        "android.hardware.graphics.allocator@3.0",
243        "libbinder",
244        "libcutils",
245        "libhidlbase",
246        "liblog",
247        "libprocessgroup",
248        "libsync",
249        "libutils",
250    ],
251    static_libs: [
252        "android.frameworks.displayservice@1.0",
253        "libc++fs",
254        "libdisplayservicehidl",
255        "libserviceutils",
256    ],
257}
258
259filegroup {
260    name: "surfaceflinger_binary_sources",
261    srcs: [
262        ":libsurfaceflinger_sources",
263        "main_surfaceflinger.cpp",
264    ],
265}
266
267cc_binary {
268    name: "surfaceflinger",
269    defaults: ["libsurfaceflinger_binary"],
270    init_rc: ["surfaceflinger.rc"],
271    srcs: [
272        ":surfaceflinger_binary_sources",
273        // Note: SurfaceFlingerFactory is not in the filegroup so that it
274        // can be easily replaced.
275        "SurfaceFlingerFactory.cpp",
276    ],
277    shared_libs: [
278        "libSurfaceFlingerProp",
279    ],
280
281    logtags: ["EventLog/EventLogTags.logtags"],
282}
283
284subdirs = [
285    "layerproto",
286    "tests",
287]
288
289cc_library_shared {
290    name: "libSurfaceFlingerProp",
291    srcs: [
292        "SurfaceFlingerProperties.cpp",
293    ],
294    shared_libs: [
295        "android.hardware.configstore-utils",
296        "android.hardware.configstore@1.0",
297        "android.hardware.configstore@1.1",
298        "android.hardware.graphics.common@1.2",
299        "libhidlbase",
300        "libui",
301        "libutils",
302        "liblog",
303    ],
304    static_libs: [
305        "libSurfaceFlingerProperties",
306    ],
307    export_shared_lib_headers: [
308        "android.hardware.graphics.common@1.2",
309        "libhidlbase",
310        "libui",
311    ],
312    export_static_lib_headers: [
313        "libSurfaceFlingerProperties",
314    ],
315}
316