1# Copyright (C) 2023-2024 Huawei Device Co., Ltd.
2# Licensed under the Apache License, Version 2.0 (the "License");
3# you may not use this file except in compliance with the License.
4# You may obtain a copy of the License at
5#
6#     http://www.apache.org/licenses/LICENSE-2.0
7#
8# Unless required by applicable law or agreed to in writing, software
9# distributed under the License is distributed on an "AS IS" BASIS,
10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11# See the License for the specific language governing permissions and
12# limitations under the License.
13
14import("//build/ohos.gni")
15import("//foundation/graphic/graphic_3d/lume/lume_config.gni")
16
17declare_args() {
18  MULTI_ECS_UPDATE_AT_ONCE = "0"
19  UNIFY_RENDER = "1"
20  DBG_DRAW_PIXEL = "0"
21  WIDGET_TRACE_ENABLE = "1"
22}
23
24config("lume3d_config") {
25  visibility = [ ":*" ]
26
27  include_dirs = [
28    "${LUME_BASE_PATH}/api",
29    "${LUME_CORE_PATH}/api",
30    "${LUME_RENDER_PATH}/api",
31    "${LUME_CORE3D_PATH}/api",
32  ]
33
34  if (current_os == "ohos") {
35    include_dirs += [ "${LUME_CORE_PATH}/api/platform/ohos" ]
36  }
37
38  configs = []
39
40  cflags = [
41    "-Wall",
42    "-fexceptions",
43    "-Wno-sign-compare",
44    "-Wno-unused-variable",
45    "-Wno-unused-private-field",
46    "-Wno-implicit-fallthrough",
47    "-Wno-reorder",
48    "-Wno-unused-function",
49    "-Wno-tautological-unsigned-zero-compare",
50
51    "-Wno-nullability-completeness",
52    "-Wno-ignored-qualifiers",
53    "-Wno-switch",
54
55    "-DCORE_PUBLIC=__attribute__((visibility(\"default\")))",
56    "-DCORE_BUILD_2D = 0",
57    "-DCORE_BUILD_VULKAN=0",
58    "-DCORE_BUILD_GL=0",
59    "-DCORE_BUILD_GLES=1",
60    "-DCORE_DEV_ENABLED=0",
61    "-DCORE_TESTS_ENABLED=0",
62    "-DCORE_GL_DEBUG=0",
63    "-DCORE_VALIDATION_ENABLED = 0",
64    "-DCORE_VULKAN_VALIDATION_ENABLED = 0",
65    "-DCORE_EMBEDDED_ASSETS_ENABLED = 2",
66    "-DCORE_ENABLE_GPU_QUERIES=0",
67    "-DCORE_DEBUG_GPU_RESOURCE_IDS = 0",
68    "-DCORE_DEBUG_COMMAND_MARKERS_ENABLED = 0",
69    "-DCORE_DEBUG_MARKERS_ENABLED = 0",
70    "-DRENDER_HAS_GL_BACKEND=0",
71    "-DRENDER_HAS_GLES_BACKEND = 1",
72    "-DRENDER_HAS_VULKAN_BACKEND = 1",
73    "-DVK_USE_PLATFORM_ANDROID_KHR = 1",
74    "-DCORE_LOG_NO_DEBUG=0",
75    "-DCORE_LOG_TO_DEBUG_OUTPUT=1",
76    "-DCORE_LOG_TO_CONSOLE",
77    "-DCORE_LOG_DISABLED=0",
78    "-DCORE_DYNAMIC=1",
79  ]
80}
81
82config("widget_adapter_config") {
83  defines = [
84    "MULTI_ECS_UPDATE_AT_ONCE=${MULTI_ECS_UPDATE_AT_ONCE}",
85    "EGL_EGLEXT_PROTOTYPES",
86    "GL_GLEXT_PROTOTYPES",
87    "UNIFY_RENDER=${UNIFY_RENDER}",
88    "WIDGET_TRACE_ENABLE=${WIDGET_TRACE_ENABLE}",
89    "DBG_DRAW_PIXEL=${DBG_DRAW_PIXEL}",
90  ]
91
92  if (current_os == "ohos") {
93    defines += [ "__OHOS_PLATFORM__" ]
94  }
95
96  include_dirs = [ "include" ]
97
98  if (current_os == "ohos") {
99    include_dirs += [ "include/ohos" ]
100  }
101
102  if (MULTI_ECS_UPDATE_AT_ONCE == "1") {
103    cflags_cc += [ "-Wno-user-defined-warnings" ]
104  }
105}
106
107ohos_source_set("widget_adapter_source") {
108  sources = [
109    "core/src/engine_factory.cpp",
110    "core/src/lume/custom/lume_custom_render.cpp",
111    "core/src/lume/custom/shader_input_buffer.cpp",
112    "core/src/lume/lume_common.cpp",
113    "src/graphics_manager_common.cpp",
114    "src/graphics_task.cpp",
115    "src/offscreen_context_helper.cpp",
116    "src/widget_adapter.cpp",
117  ]
118
119  include_dirs = [
120    "core/include",
121    "core/include/lume",
122    "//foundation/graphic/graphic_2d/rosen/modules/",
123  ]
124
125  defines = [
126    "CORE_HAS_GLES_BACKEND=1",
127    "CORE_HAS_VULKAN_BACKEND=1",
128  ]
129
130  configs = [
131    ":widget_adapter_config",
132    ":lume3d_config",
133  ]
134
135  public_configs = [ ":widget_adapter_config" ]
136
137  if (defined(use_new_skia) && use_new_skia) {
138    #external_deps = [ "skia:skia_canvaskit" ]
139    deps = [ "//third_party/skia:skia_ohos" ]
140  } else {
141    #external_deps = [ "flutter:ace_skia_ohos" ]
142    deps = [ "$ace_flutter_engine_root/skia:ace_skia_ohos" ]
143  }
144  if (defined(use_rosen_drawing) && use_rosen_drawing) {
145    defines += [ "USE_ROSEN_DRAWING" ]
146  }
147
148  if (current_os == "ohos") {
149    sources += [
150      "core/src/lume/ohos/lume.cpp",
151      "src/ohos/graphics_manager.cpp",
152      "src/ohos/texture_layer.cpp",
153    ]
154
155    include_dirs += [
156      "core/include/ohos",
157      "core/include/lume/ohos",
158    ]
159
160    external_deps = [ "vulkan-headers:vulkan_headers" ]
161    external_deps += [
162      "c_utils:utils",
163      "graphic_2d:EGL",
164      "graphic_2d:GLESv3",
165      "graphic_2d:librender_service_client",
166      "graphic_surface:surface",
167      "hilog:libhilog",
168      "hitrace:hitrace_meter",
169      "init:libbegetutil",
170    ]
171
172    defines += [ "LIB_ENGINE_CORE=${LIB_ENGINE_CORE}.z" ]
173
174    if (target_cpu == "arm") {
175      defines += [
176        "PLATFORM_CORE_ROOT_PATH=/system/lib/",
177        "PLATFORM_APP_ROOT_PATH=/system/lib/",
178        "PLATFORM_APP_PLUGIN_PATH=/system/lib/",
179      ]
180    }
181
182    if (target_cpu == "arm64") {
183      defines += [
184        "PLATFORM_CORE_ROOT_PATH=/system/lib64/",
185        "PLATFORM_APP_ROOT_PATH=/system/lib64/",
186        "PLATFORM_APP_PLUGIN_PATH=/system/lib64/",
187      ]
188    }
189  }
190
191  part_name = "graphic_3d"
192  subsystem_name = "graphic"
193}
194
195group("3dWidgetAdapterInterface") {
196  public_configs = [
197    ":widget_adapter_config",
198    "../3d_scene_adapter:scene_adapter_config",
199    "../kits/js:napi_config",
200  ]
201}
202
203ohos_shared_library("lib3dWidgetAdapter") {
204  deps = [
205    ":widget_adapter_source",
206    "../3d_scene_adapter:scene_adapter_static",
207  ]
208
209  public_deps = []
210
211  public_configs = [
212    ":widget_adapter_config",
213    "../3d_scene_adapter:scene_adapter_config",
214    "../kits/js:napi_config",
215  ]
216  part_name = "graphic_3d"
217  subsystem_name = "graphic"
218}
219