1e9297d28Sopenharmony_ci# Copyright (c) 2021-2023 Huawei Device Co., Ltd.
2e9297d28Sopenharmony_ci# Licensed under the Apache License, Version 2.0 (the "License");
3e9297d28Sopenharmony_ci# you may not use this file except in compliance with the License.
4e9297d28Sopenharmony_ci# You may obtain a copy of the License at
5e9297d28Sopenharmony_ci#
6e9297d28Sopenharmony_ci#     http://www.apache.org/licenses/LICENSE-2.0
7e9297d28Sopenharmony_ci#
8e9297d28Sopenharmony_ci# Unless required by applicable law or agreed to in writing, software
9e9297d28Sopenharmony_ci# distributed under the License is distributed on an "AS IS" BASIS,
10e9297d28Sopenharmony_ci# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11e9297d28Sopenharmony_ci# See the License for the specific language governing permissions and
12e9297d28Sopenharmony_ci# limitations under the License.
13e9297d28Sopenharmony_ciimport("//build/ohos.gni")
14e9297d28Sopenharmony_ciimport("//foundation/graphic/graphic_2d/graphic_config.gni")
15e9297d28Sopenharmony_ci
16e9297d28Sopenharmony_ci## Build libEGL.so {{{
17e9297d28Sopenharmony_ciconfig("egl_config") {
18e9297d28Sopenharmony_ci  visibility = [ ":*" ]
19e9297d28Sopenharmony_ci
20e9297d28Sopenharmony_ci  defines = []
21e9297d28Sopenharmony_ci
22e9297d28Sopenharmony_ci  # defines += [ "EGL_WRAPPER_DEBUG_ENABLE" ]
23e9297d28Sopenharmony_ci  if (graphic_2d_feature_use_igraphics_extend_hooks) {
24e9297d28Sopenharmony_ci    defines += [ "USE_IGRAPHICS_EXTENDS_HOOKS=1" ]
25e9297d28Sopenharmony_ci  } else {
26e9297d28Sopenharmony_ci    defines += [ "USE_IGRAPHICS_EXTENDS_HOOKS=0" ]
27e9297d28Sopenharmony_ci  }
28e9297d28Sopenharmony_ci  if (graphic_2d_feature_use_aps_igameservice_func) {
29e9297d28Sopenharmony_ci    defines += [ "USE_APS_IGAMESERVICE_FUNC=1" ]
30e9297d28Sopenharmony_ci  } else {
31e9297d28Sopenharmony_ci    defines += [ "USE_APS_IGAMESERVICE_FUNC=0" ]
32e9297d28Sopenharmony_ci  }
33e9297d28Sopenharmony_ci
34e9297d28Sopenharmony_ci  cflags = [
35e9297d28Sopenharmony_ci    "-Wall",
36e9297d28Sopenharmony_ci    "-Werror",
37e9297d28Sopenharmony_ci    "-g3",
38e9297d28Sopenharmony_ci  ]
39e9297d28Sopenharmony_ci}
40e9297d28Sopenharmony_ci
41e9297d28Sopenharmony_ciconfig("egl_public_config") {
42e9297d28Sopenharmony_ci  include_dirs = [ "include" ]
43e9297d28Sopenharmony_ci  if (graphic_2d_feature_use_igraphics_extend_hooks) {
44e9297d28Sopenharmony_ci    include_dirs += egl_igraphics_extend_hooks_include_dirs
45e9297d28Sopenharmony_ci  }
46e9297d28Sopenharmony_ci  if (graphic_2d_feature_use_aps_igameservice_func) {
47e9297d28Sopenharmony_ci    include_dirs += aps_client_include_dirs
48e9297d28Sopenharmony_ci    include_dirs += gameservice_render_slice_report_include_dirs
49e9297d28Sopenharmony_ci  }
50e9297d28Sopenharmony_ci}
51e9297d28Sopenharmony_ci
52e9297d28Sopenharmony_ciif (current_os != "ohos") {
53e9297d28Sopenharmony_ci  group("EGL") {
54e9297d28Sopenharmony_ci    public_external_deps = [
55e9297d28Sopenharmony_ci      "egl:libEGL",
56e9297d28Sopenharmony_ci      "opengles:libGLES",
57e9297d28Sopenharmony_ci    ]
58e9297d28Sopenharmony_ci  }
59e9297d28Sopenharmony_ci} else {
60e9297d28Sopenharmony_ci  ohos_shared_library("EGL") {
61e9297d28Sopenharmony_ci    defines = [ "EGL_ERROR_ENABLE" ]
62e9297d28Sopenharmony_ci    sources = [
63e9297d28Sopenharmony_ci      "src/EGL/egl.cpp",
64e9297d28Sopenharmony_ci      "src/EGL/egl_blob_cache.cpp",
65e9297d28Sopenharmony_ci      "src/EGL/egl_bundle_mgr_helper.cpp",
66e9297d28Sopenharmony_ci      "src/EGL/egl_core.cpp",
67e9297d28Sopenharmony_ci      "src/EGL/egl_system_layers_manager.cpp",
68e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_context.cpp",
69e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_display.cpp",
70e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_entry.cpp",
71e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_layer.cpp",
72e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_loader.cpp",
73e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_object.cpp",
74e9297d28Sopenharmony_ci      "src/EGL/egl_wrapper_surface.cpp",
75e9297d28Sopenharmony_ci      "src/thread_private_data_ctl.cpp",
76e9297d28Sopenharmony_ci    ]
77e9297d28Sopenharmony_ci    if (graphic_2d_feature_use_igraphics_extend_hooks) {
78e9297d28Sopenharmony_ci      sources += egl_igraphics_extend_hooks_sources
79e9297d28Sopenharmony_ci    }
80e9297d28Sopenharmony_ci    if (graphic_2d_feature_use_aps_igameservice_func) {
81e9297d28Sopenharmony_ci      sources += aps_client_sources
82e9297d28Sopenharmony_ci      sources += gameservice_render_slice_report_sources
83e9297d28Sopenharmony_ci    }
84e9297d28Sopenharmony_ci    configs = [ ":egl_config" ]
85e9297d28Sopenharmony_ci
86e9297d28Sopenharmony_ci    public_configs = [ ":egl_public_config" ]
87e9297d28Sopenharmony_ci
88e9297d28Sopenharmony_ci    public_external_deps = [
89e9297d28Sopenharmony_ci      "egl:libEGL",
90e9297d28Sopenharmony_ci      "jsoncpp:jsoncpp",
91e9297d28Sopenharmony_ci      "opengles:libGLES",
92e9297d28Sopenharmony_ci    ]
93e9297d28Sopenharmony_ci    external_deps = [
94e9297d28Sopenharmony_ci      "bundle_framework:appexecfwk_base",
95e9297d28Sopenharmony_ci      "bundle_framework:appexecfwk_core",
96e9297d28Sopenharmony_ci      "c_utils:utils",
97e9297d28Sopenharmony_ci      "config_policy:configpolicy_util",
98e9297d28Sopenharmony_ci      "graphic_surface:surface",
99e9297d28Sopenharmony_ci      "hilog:libhilog",
100e9297d28Sopenharmony_ci      "init:libbeget_proxy",
101e9297d28Sopenharmony_ci      "init:libbegetutil",
102e9297d28Sopenharmony_ci      "ipc:ipc_core",
103e9297d28Sopenharmony_ci      "samgr:samgr_proxy",
104e9297d28Sopenharmony_ci    ]
105e9297d28Sopenharmony_ci
106e9297d28Sopenharmony_ci    if (graphic_2d_feature_use_aps_igameservice_func) {
107e9297d28Sopenharmony_ci      external_deps += aps_client_external_deps
108e9297d28Sopenharmony_ci      external_deps += gameservice_render_slice_report_external_deps
109e9297d28Sopenharmony_ci    }
110e9297d28Sopenharmony_ci
111e9297d28Sopenharmony_ci    if (is_emulator) {
112e9297d28Sopenharmony_ci      defines += [ "IS_EMULATOR" ]
113e9297d28Sopenharmony_ci    }
114e9297d28Sopenharmony_ci    output_name = "EGL"
115e9297d28Sopenharmony_ci    output_extension = "so"
116e9297d28Sopenharmony_ci
117e9297d28Sopenharmony_ci    part_name = "graphic_2d"
118e9297d28Sopenharmony_ci    subsystem_name = "graphic"
119e9297d28Sopenharmony_ci  }
120e9297d28Sopenharmony_ci}
121e9297d28Sopenharmony_ci
122e9297d28Sopenharmony_ci## Build libEGL.so }}}
123e9297d28Sopenharmony_ci
124e9297d28Sopenharmony_ci## Build libGLESv1.so {{{
125e9297d28Sopenharmony_ciconfig("glesv1_config") {
126e9297d28Sopenharmony_ci  visibility = [ ":*" ]
127e9297d28Sopenharmony_ci
128e9297d28Sopenharmony_ci  cflags = [
129e9297d28Sopenharmony_ci    "-Wall",
130e9297d28Sopenharmony_ci    "-Werror",
131e9297d28Sopenharmony_ci    "-g3",
132e9297d28Sopenharmony_ci  ]
133e9297d28Sopenharmony_ci}
134e9297d28Sopenharmony_ci
135e9297d28Sopenharmony_ciconfig("glesv1_public_config") {
136e9297d28Sopenharmony_ci  include_dirs = [ "include" ]
137e9297d28Sopenharmony_ci}
138e9297d28Sopenharmony_ci
139e9297d28Sopenharmony_ciohos_shared_library("GLESv1") {
140e9297d28Sopenharmony_ci  sources = [
141e9297d28Sopenharmony_ci    "src/GLES1/gles1.cpp",
142e9297d28Sopenharmony_ci    "src/thread_private_data_ctl.cpp",
143e9297d28Sopenharmony_ci  ]
144e9297d28Sopenharmony_ci  configs = [ ":glesv1_config" ]
145e9297d28Sopenharmony_ci
146e9297d28Sopenharmony_ci  public_configs = [ ":glesv1_public_config" ]
147e9297d28Sopenharmony_ci
148e9297d28Sopenharmony_ci  public_external_deps = [
149e9297d28Sopenharmony_ci    "egl:libEGL",
150e9297d28Sopenharmony_ci    "opengles:libGLES",
151e9297d28Sopenharmony_ci  ]
152e9297d28Sopenharmony_ci
153e9297d28Sopenharmony_ci  external_deps = [ "hilog:libhilog" ]
154e9297d28Sopenharmony_ci
155e9297d28Sopenharmony_ci  output_name = "GLESv1"
156e9297d28Sopenharmony_ci  output_extension = "so"
157e9297d28Sopenharmony_ci
158e9297d28Sopenharmony_ci  part_name = "graphic_2d"
159e9297d28Sopenharmony_ci  subsystem_name = "graphic"
160e9297d28Sopenharmony_ci}
161e9297d28Sopenharmony_ci
162e9297d28Sopenharmony_ci## Build libGLESv1.so }}}
163e9297d28Sopenharmony_ci
164e9297d28Sopenharmony_ci## Build libGLESv2.so {{{
165e9297d28Sopenharmony_ciconfig("glesv2_config") {
166e9297d28Sopenharmony_ci  visibility = [ ":*" ]
167e9297d28Sopenharmony_ci
168e9297d28Sopenharmony_ci  cflags = [
169e9297d28Sopenharmony_ci    "-Wall",
170e9297d28Sopenharmony_ci    "-Werror",
171e9297d28Sopenharmony_ci    "-g3",
172e9297d28Sopenharmony_ci  ]
173e9297d28Sopenharmony_ci}
174e9297d28Sopenharmony_ci
175e9297d28Sopenharmony_ciconfig("glesv2_public_config") {
176e9297d28Sopenharmony_ci  include_dirs = [ "include" ]
177e9297d28Sopenharmony_ci}
178e9297d28Sopenharmony_ci
179e9297d28Sopenharmony_ciohos_shared_library("GLESv2") {
180e9297d28Sopenharmony_ci  sources = [
181e9297d28Sopenharmony_ci    "src/GLES2/gles2.cpp",
182e9297d28Sopenharmony_ci    "src/thread_private_data_ctl.cpp",
183e9297d28Sopenharmony_ci  ]
184e9297d28Sopenharmony_ci  configs = [ ":glesv2_config" ]
185e9297d28Sopenharmony_ci
186e9297d28Sopenharmony_ci  public_configs = [ ":glesv2_public_config" ]
187e9297d28Sopenharmony_ci
188e9297d28Sopenharmony_ci  public_external_deps = [
189e9297d28Sopenharmony_ci    "egl:libEGL",
190e9297d28Sopenharmony_ci    "opengles:libGLES",
191e9297d28Sopenharmony_ci  ]
192e9297d28Sopenharmony_ci
193e9297d28Sopenharmony_ci  external_deps = [ "hilog:libhilog" ]
194e9297d28Sopenharmony_ci
195e9297d28Sopenharmony_ci  output_name = "GLESv2"
196e9297d28Sopenharmony_ci  output_extension = "so"
197e9297d28Sopenharmony_ci  innerapi_tags = [ "ndk" ]
198e9297d28Sopenharmony_ci  part_name = "graphic_2d"
199e9297d28Sopenharmony_ci  subsystem_name = "graphic"
200e9297d28Sopenharmony_ci}
201e9297d28Sopenharmony_ci
202e9297d28Sopenharmony_ci## Build libGLESv2.so }}}
203e9297d28Sopenharmony_ci
204e9297d28Sopenharmony_ci## Build libGLESv3.so {{{
205e9297d28Sopenharmony_ciconfig("glesv3_config") {
206e9297d28Sopenharmony_ci  visibility = [ ":*" ]
207e9297d28Sopenharmony_ci
208e9297d28Sopenharmony_ci  cflags = [
209e9297d28Sopenharmony_ci    "-Wall",
210e9297d28Sopenharmony_ci    "-Werror",
211e9297d28Sopenharmony_ci    "-g3",
212e9297d28Sopenharmony_ci  ]
213e9297d28Sopenharmony_ci}
214e9297d28Sopenharmony_ci
215e9297d28Sopenharmony_ciconfig("glesv3_public_config") {
216e9297d28Sopenharmony_ci  include_dirs = [ "include" ]
217e9297d28Sopenharmony_ci}
218e9297d28Sopenharmony_ci
219e9297d28Sopenharmony_ciif (current_os != "ohos") {
220e9297d28Sopenharmony_ci  group("GLESv3") {
221e9297d28Sopenharmony_ci    public_external_deps = [
222e9297d28Sopenharmony_ci      "egl:libEGL",
223e9297d28Sopenharmony_ci      "opengles:libGLES",
224e9297d28Sopenharmony_ci    ]
225e9297d28Sopenharmony_ci  }
226e9297d28Sopenharmony_ci} else {
227e9297d28Sopenharmony_ci  ohos_shared_library("GLESv3") {
228e9297d28Sopenharmony_ci    sources = [ "src/GLES3/gles3.cpp" ]
229e9297d28Sopenharmony_ci    configs = [ ":glesv3_config" ]
230e9297d28Sopenharmony_ci
231e9297d28Sopenharmony_ci    public_configs = [ ":glesv3_public_config" ]
232e9297d28Sopenharmony_ci
233e9297d28Sopenharmony_ci    public_external_deps = [
234e9297d28Sopenharmony_ci      "egl:libEGL",
235e9297d28Sopenharmony_ci      "opengles:libGLES",
236e9297d28Sopenharmony_ci    ]
237e9297d28Sopenharmony_ci
238e9297d28Sopenharmony_ci    external_deps = [ "hilog:libhilog" ]
239e9297d28Sopenharmony_ci
240e9297d28Sopenharmony_ci    output_name = "GLESv3"
241e9297d28Sopenharmony_ci    output_extension = "so"
242e9297d28Sopenharmony_ci
243e9297d28Sopenharmony_ci    part_name = "graphic_2d"
244e9297d28Sopenharmony_ci    subsystem_name = "graphic"
245e9297d28Sopenharmony_ci  }
246e9297d28Sopenharmony_ci}
247e9297d28Sopenharmony_ci
248e9297d28Sopenharmony_ci## Build libGLESv3.so }}}
249e9297d28Sopenharmony_ci
250e9297d28Sopenharmony_ci## Build opengl_wrapper_native_test {{{
251e9297d28Sopenharmony_ciohos_executable("opengl_wrapper_native_test") {
252e9297d28Sopenharmony_ci  install_enable = true
253e9297d28Sopenharmony_ci
254e9297d28Sopenharmony_ci  sources = [ "test/opengl_wrapper_native_test.cpp" ]
255e9297d28Sopenharmony_ci
256e9297d28Sopenharmony_ci  include_dirs = [
257e9297d28Sopenharmony_ci    "$graphic_2d_root/interfaces/inner_api/common",
258e9297d28Sopenharmony_ci    "$graphic_2d_root/rosen/modules/render_service_client",
259e9297d28Sopenharmony_ci  ]
260e9297d28Sopenharmony_ci
261e9297d28Sopenharmony_ci  deps = [
262e9297d28Sopenharmony_ci    ":EGL",
263e9297d28Sopenharmony_ci    ":GLESv3",
264e9297d28Sopenharmony_ci    "$graphic_2d_root/rosen/modules/render_service_client:librender_service_client",
265e9297d28Sopenharmony_ci  ]
266e9297d28Sopenharmony_ci
267e9297d28Sopenharmony_ci  external_deps = [
268e9297d28Sopenharmony_ci    "c_utils:utils",
269e9297d28Sopenharmony_ci    "graphic_surface:surface_headers",
270e9297d28Sopenharmony_ci    "hilog:libhilog",
271e9297d28Sopenharmony_ci  ]
272e9297d28Sopenharmony_ci
273e9297d28Sopenharmony_ci  part_name = "graphic_2d"
274e9297d28Sopenharmony_ci  subsystem_name = "graphic"
275e9297d28Sopenharmony_ci}
276e9297d28Sopenharmony_ci
277e9297d28Sopenharmony_ci## Build opengl_wrapper_native_test }}}
278e9297d28Sopenharmony_ci
279e9297d28Sopenharmony_ci## Build libdebug_layer_test.so {{{
280e9297d28Sopenharmony_ciconfig("debug_layer_test_config") {
281e9297d28Sopenharmony_ci  visibility = [ ":*" ]
282e9297d28Sopenharmony_ci
283e9297d28Sopenharmony_ci  defines = [ "EGL_WRAPPER_DEBUG_ENABLE" ]
284e9297d28Sopenharmony_ci
285e9297d28Sopenharmony_ci  cflags = [
286e9297d28Sopenharmony_ci    "-Wall",
287e9297d28Sopenharmony_ci    "-Werror",
288e9297d28Sopenharmony_ci    "-g3",
289e9297d28Sopenharmony_ci  ]
290e9297d28Sopenharmony_ci}
291e9297d28Sopenharmony_ci
292e9297d28Sopenharmony_ciconfig("debug_layer_test_public_config") {
293e9297d28Sopenharmony_ci  include_dirs = [ "include" ]
294e9297d28Sopenharmony_ci}
295e9297d28Sopenharmony_ci
296e9297d28Sopenharmony_ciohos_shared_library("debug_layer_test1") {
297e9297d28Sopenharmony_ci  sources = [ "test/debug_layer_test1.cpp" ]
298e9297d28Sopenharmony_ci  configs = [ ":debug_layer_test_config" ]
299e9297d28Sopenharmony_ci
300e9297d28Sopenharmony_ci  public_configs = [ ":debug_layer_test_public_config" ]
301e9297d28Sopenharmony_ci
302e9297d28Sopenharmony_ci  public_external_deps = [ "egl:libEGL" ]
303e9297d28Sopenharmony_ci
304e9297d28Sopenharmony_ci  external_deps = [ "hilog:libhilog" ]
305e9297d28Sopenharmony_ci
306e9297d28Sopenharmony_ci  symlink_target_name = [ "libdebug_layer_test1.so" ]
307e9297d28Sopenharmony_ci
308e9297d28Sopenharmony_ci  part_name = "graphic_2d"
309e9297d28Sopenharmony_ci  subsystem_name = "graphic"
310e9297d28Sopenharmony_ci}
311e9297d28Sopenharmony_ci
312e9297d28Sopenharmony_ciohos_shared_library("debug_layer_test2") {
313e9297d28Sopenharmony_ci  sources = [ "test/debug_layer_test2.cpp" ]
314e9297d28Sopenharmony_ci  configs = [ ":debug_layer_test_config" ]
315e9297d28Sopenharmony_ci
316e9297d28Sopenharmony_ci  public_configs = [ ":debug_layer_test_public_config" ]
317e9297d28Sopenharmony_ci
318e9297d28Sopenharmony_ci  public_external_deps = [ "egl:libEGL" ]
319e9297d28Sopenharmony_ci
320e9297d28Sopenharmony_ci  external_deps = [ "hilog:libhilog" ]
321e9297d28Sopenharmony_ci
322e9297d28Sopenharmony_ci  symlink_target_name = [ "libdebug_layer_test2.so" ]
323e9297d28Sopenharmony_ci
324e9297d28Sopenharmony_ci  part_name = "graphic_2d"
325e9297d28Sopenharmony_ci  subsystem_name = "graphic"
326e9297d28Sopenharmony_ci}
327e9297d28Sopenharmony_ci## Build libdebug_layer_test.so }}}
328