-
Notifications
You must be signed in to change notification settings - Fork 135
/
Copy pathbuild.cmake
287 lines (260 loc) · 11 KB
/
build.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
cmake_minimum_required(VERSION 3.10)
# The platform-dependent definitions such as EGLNativeDisplayType and
# EGLNativeWindowType depend on related include files or define such as gbm.h
# or "__GBM__". So, need to avoid a link error which is caused by the
# include order of related header files. See: /usr/include/EGL/eglplatform.h
if(${BACKEND_TYPE} STREQUAL "DRM-GBM")
add_definitions(-D__GBM__)
elseif(${BACKEND_TYPE} STREQUAL "DRM-EGLSTREAM")
add_definitions(-DEGL_NO_X11)
elseif(${BACKEND_TYPE} STREQUAL "X11")
add_definitions(-DUSE_X11)
else()
add_definitions(-DWL_EGL_PLATFORM)
endif()
# display backend type.
set(DISPLAY_BACKEND_SRC "")
if(${BACKEND_TYPE} STREQUAL "DRM-GBM")
add_definitions(-DDISPLAY_BACKEND_TYPE_DRM_GBM)
add_definitions(-DFLUTTER_TARGET_BACKEND_GBM)
set(DISPLAY_BACKEND_SRC
"src/flutter/shell/platform/linux_embedded/window/native_window_drm.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_drm_gbm.cc")
elseif(${BACKEND_TYPE} STREQUAL "DRM-EGLSTREAM")
add_definitions(-DDISPLAY_BACKEND_TYPE_DRM_EGLSTREAM)
add_definitions(-DFLUTTER_TARGET_BACKEND_EGLSTREAM)
set(DISPLAY_BACKEND_SRC
"src/flutter/shell/platform/linux_embedded/surface/context_egl_stream.cc"
"src/flutter/shell/platform/linux_embedded/surface/environment_egl_stream.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_drm.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_drm_eglstream.cc")
elseif(${BACKEND_TYPE} STREQUAL "X11")
add_definitions(-DDISPLAY_BACKEND_TYPE_X11)
add_definitions(-DFLUTTER_TARGET_BACKEND_X11)
set(DISPLAY_BACKEND_SRC
"src/flutter/shell/platform/linux_embedded/window/elinux_window_x11.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_x11.cc")
else()
include(cmake/generate_wayland_protocols.cmake)
pkg_get_variable(WAYLAND_PROTOCOLS_DATADIR wayland-protocols pkgdatadir)
set(_wayland_protocols_xml_dir "${WAYLAND_PROTOCOLS_DATADIR}")
set(_wayland_protocols_src_dir "${CMAKE_CURRENT_SOURCE_DIR}/src/third_party/wayland/protocols")
file(MAKE_DIRECTORY "${_wayland_protocols_src_dir}")
generate_wayland_client_protocol(
PROTOCOL_FILE "${_wayland_protocols_xml_dir}/stable/xdg-shell/xdg-shell.xml"
CODE_FILE "${_wayland_protocols_src_dir}/xdg-shell-protocol.c"
HEADER_FILE "${_wayland_protocols_src_dir}/xdg-shell-client-protocol.h")
generate_wayland_client_protocol(
PROTOCOL_FILE "${_wayland_protocols_xml_dir}/unstable/text-input/text-input-unstable-v1.xml"
CODE_FILE "${_wayland_protocols_src_dir}/text-input-unstable-v1-protocol.c"
HEADER_FILE "${_wayland_protocols_src_dir}/text-input-unstable-v1-client-protocol.h")
generate_wayland_client_protocol(
PROTOCOL_FILE "${_wayland_protocols_xml_dir}/unstable/text-input/text-input-unstable-v3.xml"
CODE_FILE "${_wayland_protocols_src_dir}/text-input-unstable-v3-protocol.c"
HEADER_FILE "${_wayland_protocols_src_dir}/text-input-unstable-v3-client-protocol.h")
generate_wayland_client_protocol(
PROTOCOL_FILE "${_wayland_protocols_xml_dir}/stable/presentation-time/presentation-time.xml"
CODE_FILE "${_wayland_protocols_src_dir}/presentation-time-protocol.c"
HEADER_FILE "${_wayland_protocols_src_dir}/presentation-time-protocol.h")
generate_wayland_client_protocol(
PROTOCOL_FILE "${_wayland_protocols_xml_dir}/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml"
CODE_FILE "${_wayland_protocols_src_dir}/xdg-decoration-unstable-v1-protocol.c"
HEADER_FILE "${_wayland_protocols_src_dir}/xdg-decoration-unstable-v1-protocol.h")
add_definitions(-DFLUTTER_TARGET_BACKEND_WAYLAND)
add_definitions(-DDISPLAY_BACKEND_TYPE_WAYLAND)
set(DISPLAY_BACKEND_SRC
"${_wayland_protocols_src_dir}/xdg-shell-protocol.c"
"${_wayland_protocols_src_dir}/text-input-unstable-v1-protocol.c"
"${_wayland_protocols_src_dir}/text-input-unstable-v3-protocol.c"
"${_wayland_protocols_src_dir}/presentation-time-protocol.c"
"${_wayland_protocols_src_dir}/xdg-decoration-unstable-v1-protocol.c"
"src/flutter/shell/platform/linux_embedded/window/elinux_window_wayland.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_wayland.cc"
"src/flutter/shell/platform/linux_embedded/window/native_window_wayland_decoration.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/elinux_shader.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/elinux_shader_context.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/elinux_shader_program.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/window_decoration_button.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/window_decoration_titlebar.cc"
"src/flutter/shell/platform/linux_embedded/window/renderer/window_decorations_wayland.cc")
endif()
# Use flutter dirty region management
if(USE_DIRTY_REGION_MANAGEMENT)
add_definitions(-DUSE_OPENGL_DIRTY_REGION_MANAGEMENT)
endif()
# OpenGL ES version.
if(USE_GLES3)
add_definitions(-DUSE_GLES3)
endif()
# Flutter embedder runtime mode.
if(FLUTTER_RELEASE)
add_definitions(
-DFLUTTER_RELEASE # release mode
)
endif()
# Enable logger of eLinux embedder.
if(ENABLE_ELINUX_EMBEDDER_LOG)
add_definitions(
-DENABLE_ELINUX_EMBEDDER_LOG
)
endif()
# Enable embedder vsync.
if(ENABLE_VSYNC)
add_definitions(
-DENABLE_VSYNC
)
endif()
# Enable alpha component of the egl color buffer.
if(ENABLE_EGL_ALPHA_COMPONENT_OF_COLOR_BUFFER)
add_definitions(
-DENABLE_EGL_ALPHA_COMPONENT_OF_COLOR_BUFFER
)
endif()
set(CPP_WRAPPER_SOURCES_CORE
"src/flutter/shell/platform/common/client_wrapper/engine_method_result.cc"
"src/flutter/shell/platform/common/client_wrapper/standard_codec.cc"
"src/flutter/shell/platform/common/client_wrapper/string_message_codec.cc"
)
set(CPP_WRAPPER_SOURCES_PLUGIN
"src/flutter/shell/platform/common/client_wrapper/plugin_registrar.cc"
)
set(CPP_WRAPPER_SOURCES_APP
"src/client_wrapper/flutter_engine.cc"
"src/client_wrapper/flutter_view_controller.cc"
)
set(ELINUX_COMMON_SRC
"src/flutter/shell/platform/linux_embedded/flutter_elinux.cc"
"src/flutter/shell/platform/linux_embedded/flutter_elinux_engine.cc"
"src/flutter/shell/platform/linux_embedded/flutter_elinux_view.cc"
"src/flutter/shell/platform/linux_embedded/flutter_project_bundle.cc"
"src/flutter/shell/platform/linux_embedded/task_runner.cc"
"src/flutter/shell/platform/linux_embedded/system_utils.cc"
"src/flutter/shell/platform/linux_embedded/logger.cc"
"src/flutter/shell/platform/linux_embedded/external_texture_pixelbuffer.cc"
"src/flutter/shell/platform/linux_embedded/external_texture_egl_image.cc"
"src/flutter/shell/platform/linux_embedded/vsync_waiter.cc"
"src/flutter/shell/platform/linux_embedded/flutter_elinux_texture_registrar.cc"
"src/flutter/shell/platform/linux_embedded/plugins/keyboard_glfw_util.cc"
"src/flutter/shell/platform/linux_embedded/plugins/key_event_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/lifecycle_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/mouse_cursor_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/navigation_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/platform_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/platform_views_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/settings_plugin.cc"
"src/flutter/shell/platform/linux_embedded/plugins/text_input_plugin.cc"
"src/flutter/shell/platform/linux_embedded/surface/context_egl.cc"
"src/flutter/shell/platform/linux_embedded/surface/egl_utils.cc"
"src/flutter/shell/platform/linux_embedded/surface/elinux_egl_surface.cc"
"src/flutter/shell/platform/linux_embedded/surface/surface_base.cc"
"src/flutter/shell/platform/linux_embedded/surface/surface_gl.cc"
"src/flutter/shell/platform/linux_embedded/surface/surface_decoration.cc"
"${DISPLAY_BACKEND_SRC}"
## The following file were copied from:
## https://github.com/flutter/engine/blob/master/shell/platform/glfw/
"src/flutter/shell/platform/linux_embedded/system_utils.cc"
## Following files were imported from:
## https://github.com/flutter/engine/tree/master/shell/platform/common
"src/flutter/shell/platform/common/text_input_model.cc"
"src/flutter/shell/platform/common/json_message_codec.cc"
"src/flutter/shell/platform/common/json_method_codec.cc"
"src/flutter/shell/platform/common/engine_switches.cc"
"src/flutter/shell/platform/common/incoming_message_dispatcher.cc"
)
if(NOT BUILD_ELINUX_SO)
# cmake script for developers.
include(${USER_PROJECT_PATH}/cmake/user_build.cmake)
add_executable(${TARGET}
${ELINUX_COMMON_SRC}
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
${CPP_WRAPPER_SOURCES_APP}
${USER_APP_SRCS}
)
else()
add_library(${TARGET}
SHARED
${ELINUX_COMMON_SRC}
${CPP_WRAPPER_SOURCES_CORE}
${CPP_WRAPPER_SOURCES_PLUGIN}
)
target_include_directories(${TARGET}
PUBLIC
"src/flutter/shell/platform/linux_embedded/public"
)
target_include_directories(${TARGET}
PRIVATE
"src/client_wrapper/include"
"src/flutter/shell/platform/common/client_wrapper"
"src/flutter/shell/platform/common/client_wrapper/include"
"src/flutter/shell/platform/common/client_wrapper/include/flutter"
"src/flutter/shell/platform/common/public"
)
endif()
set(THIRD_PARTY_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/third_party")
set(RAPIDJSON_INCLUDE_DIRS "${THIRD_PARTY_DIRS}/rapidjson/include/")
target_include_directories(${TARGET}
PRIVATE
"src"
## third-party libraries.
${THIRD_PARTY_DIRS}
${RAPIDJSON_INCLUDE_DIRS}
${XKBCOMMON_INCLUDE_DIRS}
${WAYLAND_CLIENT_INCLUDE_DIRS}
${WAYLAND_CURSOR_INCLUDE_DIRS}
${WAYLAND_EGL_INCLUDE_DIRS}
${EGL_INCLUDE_DIRS}
${GLES_INCLUDE_DIRS}
${DRM_INCLUDE_DIRS}
${GBM_INCLUDE_DIRS}
${LIBINPUT_INCLUDE_DIRS}
${LIBUDEV_INCLUDE_DIRS}
${LIBSYSTEMD_INCLUDE_DIRS}
${X11_INCLUDE_DIRS}
${LIBWESTON_INCLUDE_DIRS}
## User libraries
${USER_APP_INCLUDE_DIRS}
)
target_link_libraries(${TARGET}
PRIVATE
${XKBCOMMON_LIBRARIES}
${WAYLAND_CLIENT_LIBRARIES}
${WAYLAND_CURSOR_LIBRARIES}
${WAYLAND_EGL_LIBRARIES}
${EGL_LIBRARIES}
${DRM_LIBRARIES}
${GBM_LIBRARIES}
${LIBINPUT_LIBRARIES}
${LIBUDEV_LIBRARIES}
${LIBSYSTEMD_LIBRARIES}
${LIBUV_LIBRARIES}
${X11_LIBRARIES}
${LIBWESTON_LIBRARIES}
${FLUTTER_EMBEDDER_LIB}
## User libraries
${USER_APP_LIBRARIES}
)
if(${BACKEND_TYPE} MATCHES "^DRM-(GBM|EGLSTREAM)$")
target_link_libraries(${TARGET}
PRIVATE
Threads::Threads
)
# Indicate whether libsystemd must replace libuv
if("${LIBSYSTEMD_FOUND}" STREQUAL "1")
add_definitions(-DUSE_LIBSYSTEMD)
endif()
endif()
set(FLUTTER_EMBEDDER_LIB "${CMAKE_CURRENT_SOURCE_DIR}/build/libflutter_engine.so")
set(CMAKE_SKIP_RPATH true)
target_link_libraries(${TARGET}
PRIVATE
${FLUTTER_EMBEDDER_LIB}
)
target_compile_options(${TARGET}
PUBLIC
${EGL_CFLAGS}
)
if(NOT BUILD_ELINUX_SO)
# Generated plugin build rules
include(${USER_PROJECT_PATH}/flutter/generated_plugins.cmake)
endif()