SF: Allow SurfaceFlinger creation to be altered
As a first step, we need to be able to build a version of the
/system/binsurfacefligner binary that can (eventually) invoke the
SurfaceFlinger constructor to pass a "factory" class to replace certain
key types.
The unittest will also be able to use it to construct mocks by default.
Bug: None
Test: marlin builds, cheets_x86_64 builds (and overrides default)
Change-Id: Id6d5cabf0dd54e85ac0e6706edf3cbe8a0288bc3
diff --git a/services/surfaceflinger/Android.bp b/services/surfaceflinger/Android.bp
index 744bdba..4f12d3e 100644
--- a/services/surfaceflinger/Android.bp
+++ b/services/surfaceflinger/Android.bp
@@ -4,6 +4,7 @@
"-DLOG_TAG=\"SurfaceFlinger\"",
"-Wall",
"-Werror",
+ "-Wformat",
"-Wthread-safety",
"-Wunused",
"-Wunreachable-code",
@@ -18,6 +19,10 @@
"-DGL_GLEXT_PROTOTYPES",
"-DEGL_EGLEXT_PROTOTYPES",
],
+ include_dirs: [
+ "frameworks/native/vulkan/vkjson",
+ "frameworks/native/vulkan/include",
+ ],
shared_libs: [
"android.frameworks.vr.composer@1.0",
"android.hardware.configstore-utils",
@@ -84,6 +89,18 @@
],
}
+cc_defaults {
+ name: "libsurfaceflinger_production_defaults",
+ defaults: ["libsurfaceflinger_defaults"],
+ cflags: [
+ "-fvisibility=hidden",
+ "-fwhole-program-vtables", // requires ThinLTO
+ ],
+ lto: {
+ thin: true,
+ },
+}
+
cc_library_headers {
name: "libsurfaceflinger_headers",
export_include_dirs: ["."],
@@ -137,33 +154,23 @@
}
cc_library_shared {
+ // Please use libsurfaceflinger_defaults to configure how the sources are
+ // built, so the same settings can be used elsewhere.
name: "libsurfaceflinger",
- defaults: ["libsurfaceflinger_defaults"],
- cflags: [
- "-fvisibility=hidden",
- "-Werror=format",
- ],
+ defaults: ["libsurfaceflinger_production_defaults"],
srcs: [
":libsurfaceflinger_sources",
+
+ // Note: SurfaceFlingerFactory is not in the default sources so that it
+ // can be easily replaced.
+ "SurfaceFlingerFactory.cpp",
],
logtags: ["EventLog/EventLogTags.logtags"],
- include_dirs: [
- "frameworks/native/vulkan/vkjson",
- "frameworks/native/vulkan/include",
- ],
- cppflags: [
- "-fwhole-program-vtables", // requires ThinLTO
- ],
- lto: {
- thin: true,
- },
}
-cc_binary {
- name: "surfaceflinger",
+cc_defaults {
+ name: "libsurfaceflinger_binary",
defaults: ["surfaceflinger_defaults"],
- init_rc: ["surfaceflinger.rc"],
- srcs: ["main_surfaceflinger.cpp"],
whole_static_libs: [
"libsigchain",
],
@@ -180,7 +187,6 @@
"libhidltransport",
"liblayers_proto",
"liblog",
- "libsurfaceflinger",
"libtimestats_proto",
"libutils",
],
@@ -189,19 +195,19 @@
"libtrace_proto",
],
ldflags: ["-Wl,--export-dynamic"],
+}
- // TODO(b/71715793): These version-scripts are required due to the use of
- // whole_static_libs to pull in libsigchain. To work, the files had to be
- // locally duplicated from their original location
- // $ANDROID_ROOT/art/sigchainlib/
- multilib: {
- lib32: {
- version_script: "version-script32.txt",
- },
- lib64: {
- version_script: "version-script64.txt",
- },
- },
+filegroup {
+ name: "surfaceflinger_binary_sources",
+ srcs: ["main_surfaceflinger.cpp"],
+}
+
+cc_binary {
+ name: "surfaceflinger",
+ defaults: ["libsurfaceflinger_binary"],
+ init_rc: ["surfaceflinger.rc"],
+ srcs: [":surfaceflinger_binary_sources"],
+ shared_libs: ["libsurfaceflinger"],
}
cc_library_shared {