1# Copyright (c) 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 defines = 27 [ "USE_LIB_PNG_JPEG_DYNAMIC_PLUGIN=$USE_LIB_PNG_JPEG_DYNAMIC_PLUGIN" ] 28 include_dirs = [ 29 "${LUME_BASE_PATH}/api", 30 "${LUME_CORE_PATH}/api", 31 "${LUME_RENDER_PATH}/api", 32 "${LUME_CORE3D_PATH}/api", 33 ] 34 35 if (current_os == "ohos") { 36 include_dirs += [ "${LUME_CORE_PATH}/api/platform/ohos" ] 37 } 38 if (USE_LIB_PNG_JPEG_DYNAMIC_PLUGIN) { 39 include_dirs += [ 40 "${LUME_PNG_PATH}/api", 41 "${LUME_JPG_PATH}/api", 42 ] 43 } 44 configs = [] 45 46 cflags = [ 47 "-Wall", 48 "-fexceptions", 49 "-Wno-sign-compare", 50 "-Wno-unused-variable", 51 "-Wno-unused-private-field", 52 "-Wno-implicit-fallthrough", 53 "-Wno-reorder", 54 "-Wno-unused-function", 55 "-Wno-tautological-unsigned-zero-compare", 56 57 "-Wno-nullability-completeness", 58 "-Wno-ignored-qualifiers", 59 "-Wno-switch", 60 61 "-DCORE_PUBLIC=__attribute__((visibility(\"default\")))", 62 "-DCORE_BUILD_2D = 0", 63 "-DCORE_BUILD_VULKAN=0", 64 "-DCORE_BUILD_GL=0", 65 "-DCORE_BUILD_GLES=1", 66 "-DCORE_DEV_ENABLED=0", 67 "-DCORE_TESTS_ENABLED=0", 68 "-DCORE_GL_DEBUG=0", 69 "-DCORE_VALIDATION_ENABLED = 0", 70 "-DCORE_VULKAN_VALIDATION_ENABLED = 0", 71 "-DCORE_EMBEDDED_ASSETS_ENABLED = 2", 72 "-DCORE_ENABLE_GPU_QUERIES=0", 73 "-DCORE_DEBUG_GPU_RESOURCE_IDS = 0", 74 "-DCORE_DEBUG_COMMAND_MARKERS_ENABLED = 0", 75 "-DCORE_DEBUG_MARKERS_ENABLED = 0", 76 "-DRENDER_HAS_GL_BACKEND=0", 77 "-DRENDER_HAS_GLES_BACKEND = 1", 78 "-DRENDER_HAS_VULKAN_BACKEND = 1", 79 "-DVK_USE_PLATFORM_OHOS = 1", 80 "-DCORE_LOG_NO_DEBUG=0", 81 "-DCORE_LOG_TO_DEBUG_OUTPUT=1", 82 "-DCORE_LOG_TO_CONSOLE", 83 "-DCORE_LOG_DISABLED=0", 84 "-DCORE_DYNAMIC=1", 85 ] 86} 87 88config("widget_adapter_config") { 89 defines = [ 90 "MULTI_ECS_UPDATE_AT_ONCE=${MULTI_ECS_UPDATE_AT_ONCE}", 91 "EGL_EGLEXT_PROTOTYPES", 92 "GL_GLEXT_PROTOTYPES", 93 "UNIFY_RENDER=${UNIFY_RENDER}", 94 "WIDGET_TRACE_ENABLE=${WIDGET_TRACE_ENABLE}", 95 "DBG_DRAW_PIXEL=${DBG_DRAW_PIXEL}", 96 ] 97 98 if (ohos_indep_compiler_enable) { 99 defines += [ "GRAPHIC_2D_INDEP_BUILD" ] 100 } 101 102 if (current_os == "ohos") { 103 defines += [ "__OHOS_PLATFORM__" ] 104 } 105 106 include_dirs = [ "include" ] 107 108 if (current_os == "ohos") { 109 include_dirs += [ "include/ohos" ] 110 } 111 112 if (MULTI_ECS_UPDATE_AT_ONCE == "1") { 113 cflags_cc += [ "-Wno-user-defined-warnings" ] 114 } 115} 116 117ohos_source_set("widget_adapter_source") { 118 defines = [ 119 "CORE_HAS_GLES_BACKEND=1", 120 "CORE_HAS_VULKAN_BACKEND=1", 121 ] 122 123 if (defined(global_parts_info.graphic_graphics_3d_ext)) { 124 defines += [ "_OPEN_BASIS_=1" ] 125 } 126 127 sources = [ 128 "core/src/engine_factory.cpp", 129 "core/src/lume/custom/lume_custom_render.cpp", 130 "core/src/lume/custom/shader_input_buffer.cpp", 131 "core/src/lume/lume_common.cpp", 132 "core/src/lume_render_config.cpp", 133 "src/graphics_manager_common.cpp", 134 "src/graphics_task.cpp", 135 "src/offscreen_context_helper.cpp", 136 "src/widget_adapter.cpp", 137 ] 138 139 include_dirs = [ 140 "core/include", 141 "core/include/lume", 142 ] 143 144 defines += [ 145 "CORE_HAS_GLES_BACKEND=1", 146 "CORE_HAS_VULKAN_BACKEND=1", 147 ] 148 149 configs = [ 150 ":widget_adapter_config", 151 ":lume3d_config", 152 ] 153 154 public_configs = [ ":widget_adapter_config" ] 155 156 external_deps = [] 157 158 if (current_os == "ohos") { 159 sources += [ 160 "core/src/lume/ohos/lume.cpp", 161 "src/ohos/graphics_manager.cpp", 162 "src/ohos/texture_layer.cpp", 163 ] 164 165 include_dirs += [ 166 "core/include/ohos", 167 "core/include/lume/ohos", 168 ] 169 170 external_deps += [ 171 "graphic_surface:surface", 172 "vulkan-headers:vulkan_headers", 173 "vulkan-loader:vulkan_loader", 174 ] 175 176 external_deps += [ 177 "ability_runtime:ability_manager", 178 "ability_runtime:app_context", 179 "ability_runtime:data_ability_helper", 180 "ability_runtime:napi_base_context", 181 "ability_runtime:napi_common", 182 "bundle_framework:appexecfwk_base", 183 "bundle_framework:appexecfwk_core", 184 "c_utils:utils", 185 "graphic_2d:EGL", 186 "graphic_2d:GLESv3", 187 "graphic_2d:librender_service_base", 188 "graphic_2d:librender_service_client", 189 "hilog:libhilog", 190 "hitrace:hitrace_meter", 191 "init:libbegetutil", 192 "ipc:ipc_single", 193 "napi:ace_napi", 194 "qos_manager:qos", 195 ] 196 197 defines += [ "LIB_ENGINE_CORE=${LIB_ENGINE_CORE}.z" ] 198 199 if (target_cpu == "arm" || target_cpu == "x86") { 200 defines += [ 201 "PLATFORM_CORE_ROOT_PATH=/system/lib/", 202 "PLATFORM_CORE_PLUGIN_PATH=/system/lib/graphics3d/", 203 "PLATFORM_APP_ROOT_PATH=/system/lib/", 204 "PLATFORM_APP_PLUGIN_PATH=/system/lib/graphics3d", 205 ] 206 } 207 208 if (target_cpu == "arm64" || target_cpu == "x64") { 209 defines += [ 210 "PLATFORM_CORE_ROOT_PATH=/system/lib64/", 211 "PLATFORM_CORE_PLUGIN_PATH=/system/lib64/graphics3d/", 212 "PLATFORM_APP_ROOT_PATH=/system/lib64/", 213 "PLATFORM_APP_PLUGIN_PATH=/system/lib64/graphics3d/", 214 ] 215 } 216 } 217 218 if (current_os == "android") { 219 sources += [ 220 "core/src/lume/android/lume.cpp", 221 "src/android/graphics_manager.cpp", 222 "src/android/skia_texture.cpp", 223 "src/android/texture_layer.cpp", 224 ] 225 226 include_dirs += [ 227 "core/include/android", 228 "core/include/lume/android", 229 ] 230 231 aosp_deps = [ 232 "shared_library:libEGL", 233 "shared_library:libGLESv2", 234 "shared_library:libandroid", 235 ] 236 237 deps += [ "$ace_flutter_engine_root:third_party_flutter_engine_android" ] 238 defines += [ "LIB_ENGINE_CORE=${LIB_ENGINE_CORE}" ] 239 } 240 241 part_name = "graphic_3d" 242 subsystem_name = "graphic" 243} 244 245group("3dWidgetAdapterInterface") { 246 public_configs = [ 247 ":widget_adapter_config", 248 "../3d_scene_adapter:scene_adapter_config", 249 "../kits/js:napi_config", 250 ] 251} 252 253ohos_shared_library("lib3dWidgetAdapter") { 254 deps = [ 255 ":widget_adapter_source", 256 "../3d_scene_adapter:scene_adapter_static", 257 ] 258 259 if (defined(global_parts_info.graphic_graphics_3d_ext)) { 260 deps += [ "../mbasis_vfx_plugin/app:3d_particles_app" ] 261 } 262 external_deps = [ "hilog:libhilog" ] 263 264 public_deps = [] 265 266 public_configs = [ 267 ":widget_adapter_config", 268 "../3d_scene_adapter:scene_adapter_config", 269 "../kits/js:napi_config", 270 ] 271 part_name = "graphic_3d" 272 subsystem_name = "graphic" 273} 274