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. 13import("//build/ohos.gni") 14import("//foundation/graphic/graphic_3d/lume/lume_config.gni") 15 16declare_args() { 17 CORE_LOG_ENABLED = true 18 CORE_ROFS = "rofs" 19} 20 21config("lume_base_api") { 22 include_dirs = [ 23 "${LUME_BASE_PATH}/api", 24 ] 25 26 defines = [ 27 "BASE_TESTS_ENABLED=0", 28 "BASE_WARNINGS_AS_ERRORS=0" 29 ] 30 31 if (CORE_LOG_ENABLED) { 32 defines += [ 33 "CORE_LOG_DISABLED=0", 34 "CORE_LOG_DEBUG=1", 35 ] 36 } else { 37 defines += [ 38 "CORE_LOG_DISABLED=1", 39 "CORE_LOG_DEBUG=0", 40 ] 41 } 42 43} 44 45config("lume_engine_api") { 46 include_dirs = [ 47 "api", 48 ] 49 50 if (LUME_OHOS_BUILD) { 51 include_dirs += [ 52 "api/platform/ohos/", 53 ] 54 } 55 56 defines = [ 57 "CORE_BUILD_BASE=1", 58 "CORE_HIDE_SYMBOLS=1", 59 "CORE_PERF_ENABLED=0", 60 "CORE_USE_COMPILER_GENERATED_STATIC=1", 61 ] 62 63 if (BUILDTYPE == "Release") { 64 defines += [ 65 "CORE_LOG_NO_DEBUG=0", 66 ] 67 } 68 if (BUILDTYPE == "MinSizeRel") { 69 defines += [ 70 "CORE_LOG_NO_DEBUG=0" 71 ] 72 } 73 if (BUILDTYPE == "RelWithDebInfo") { 74 defines += [ 75 "CORE_LOG_NO_DEBUG=0" 76 ] 77 } 78} 79 80config("lume_default") { 81 cflags = [ 82 "-Wno-unused-function", 83 "-Wno-unused-parameter", 84 "-Wno-sign-compare", 85 "-Wno-unused-variable", 86 "-Wno-unused-private-field", 87 "-Wno-tautological-unsigned-zero-compare", 88 "-Wno-logical-op-parentheses", 89 "-fno-rtti", 90 "-fvisibility=hidden", 91 "-ffunction-sections", 92 "-fdata-sections", 93 "-fno-asynchronous-unwind-tables", 94 "-fno-unwind-tables", 95 "-fno-exceptions" 96 ] 97 98 cflags_cc = [ 99 "-std=c++17", 100 "-Wno-thread-safety-attributes", 101 "-fvisibility=hidden", 102 "-fdata-sections", 103 "-ffunction-sections", 104 "-fno-rtti", 105 "-fvisibility-inlines-hidden", 106 "-fno-asynchronous-unwind-tables", 107 "-fno-unwind-tables", 108 "-fno-exceptions" 109 ] 110 111 ldflags = [ 112 "-fuse-ld=lld", 113 "-flto=thin", 114 "-Wl,--no-threads", 115 "-Wl,--gc-sections", 116 "-Wl,--exclude-libs,ALL", 117 ] 118 119 if (use_musl) { 120 ldflags -= [ "-Wl,--no-threads" ] 121 } 122 123 if (LUME_OHOS_BUILD) { 124 defines = [ 125 "__OHOS_PLATFORM__", 126 ] 127 } 128 129 defines += [ 130 "LIB_ENGINE_CORE=${LIB_ENGINE_CORE}", 131 "LIB_RENDER=${LIB_RENDER}", 132 "LIB_CORE3D=${LIB_CORE3D}" 133 ] 134} 135 136config("lume_engine_config") { 137 include_dirs = [ 138 "${LUME_CORE_PATH}/3rdparty/", 139 "${LUME_CORE_PATH}/src/", 140 "${LUME_CORE_PATH}/asserts/", 141 "${STB_IMAGE_PATH}", 142 ] 143 144 defines = [ 145 "CORE_TESTS_ENABLED=0", 146 "CORE_HIDE_SYMBOLS=1", 147 "CORE_WARNINGS_AS_ERRORS=0", 148 "CORE_DEV_ENABLED=${CORE_DEV_ENABLED}", 149 "CORE_LOG_TO_CONSOLE=1", 150 "CORE_LOG_TO_DEBUG_OUTPUT=1", 151 "CORE_LOG_TO_FILE=0", 152 "CORE_VALIDATION_ENABLED=0", 153 "CORE_TESTS_ENABLED=0", 154 "CORE_DYNAMIC=0", 155 "CORE_BUILDTYPE=${BUILDTYPE}", 156 "CORE_PUBLIC=__attribute__((visibility(\"default\")))", 157 "USE_STB_IMAGE=$USE_STB_IMAGE", 158 "USE_LIB_PNG_JPEG=$USE_LIB_PNG_JPEG", 159 "CORE_EMBEDDED_ASSETS_ENABLED=1" 160 ] 161} 162 163ohos_source_set("lume_engine_src") { 164 sources = [ 165 # "api/core/property_tools/property_data.cpp", 166 "src/ecs/ecs.cpp", 167 "src/ecs/entity_manager.cpp", 168 "src/ecs/entity_manager.h", 169 "src/engine.cpp", 170 "src/engine.h", 171 "src/engine_factory.cpp", 172 "src/engine_factory.h", 173 "src/image/image_loader_manager.cpp", 174 "src/image/image_loader_manager.h", 175 "src/image/loaders/gl_util.h", 176 "src/image/loaders/image_loader_ktx.cpp", 177 "src/image/loaders/image_loader_ktx.h", 178 "src/io/dev/file_monitor.cpp", 179 "src/io/dev/file_monitor.h", 180 "src/io/filesystem_api.cpp", 181 "src/io/file_manager.cpp", 182 "src/io/file_manager.h", 183 "src/io/memory_file.cpp", 184 "src/io/memory_file.h", 185 "src/io/memory_filesystem.cpp", 186 "src/io/memory_filesystem.h", 187 "src/io/path_tools.cpp", 188 "src/io/path_tools.h", 189 "src/io/proxy_directory.cpp", 190 "src/io/proxy_directory.h", 191 "src/io/proxy_filesystem.cpp", 192 "src/io/proxy_filesystem.h", 193 "src/io/rofs_filesystem.cpp", 194 "src/io/rofs_filesystem.h", 195 "src/io/std_directory.cpp", 196 "src/io/std_directory.h", 197 "src/io/std_file.cpp", 198 "src/io/std_file.h", 199 "src/io/std_filesystem.cpp", 200 "src/io/std_filesystem.h", 201 "src/loader/json_util.h", 202 "src/loader/system_graph_loader.cpp", 203 "src/loader/system_graph_loader.h", 204 "src/log/logger.cpp", 205 "src/log/logger.h", 206 "src/log/logger_output.cpp", 207 "src/log/logger_output.h", 208 "src/os/intf_library.h", 209 "src/os/platform.h", 210 "src/perf/performance_data_manager.cpp", 211 "src/perf/performance_data_manager.h", 212 "src/plugin_registry.cpp", 213 "src/plugin_registry.h", 214 "src/static_plugin_decl.h", 215 "src/threading/dispatcher_impl.cpp", 216 "src/threading/dispatcher_impl.h", 217 "src/threading/dispatcher_task_queue.cpp", 218 "src/threading/dispatcher_task_queue.h", 219 "src/threading/parallel_impl.cpp", 220 "src/threading/parallel_impl.h", 221 "src/threading/parallel_task_queue.cpp", 222 "src/threading/parallel_task_queue.h", 223 "src/threading/sequential_impl.cpp", 224 "src/threading/sequential_impl.h", 225 "src/threading/sequential_task_queue.cpp", 226 "src/threading/sequential_task_queue.h", 227 "src/threading/task_queue.cpp", 228 "src/threading/task_queue.h", 229 "src/threading/task_queue_factory.cpp", 230 "src/threading/task_queue_factory.h", 231 "src/util/frustum_util.cpp", 232 "src/util/frustum_util.h", 233 "src/util/linear_allocator.h", 234 "src/util/string_util.h", 235 "src/version.cpp", 236 ] 237 238 # platform source 239 if (LUME_OHOS_BUILD) { 240 sources += [ 241 "src/os/ohos/library_ohos.cpp", 242 "src/os/ohos/library_ohos.h", 243 "src/os/ohos/logger_output.cpp", 244 "src/os/ohos/ohos_file.cpp", 245 "src/os/ohos/ohos_file.h", 246 "src/os/ohos/ohos_filesystem.cpp", 247 "src/os/ohos/ohos_filesystem.h", 248 "src/os/ohos/platform_ohos.cpp", 249 "src/os/ohos/platform_ohos.h", 250 ] 251 } 252 253 if (USE_STB_IMAGE) { 254 sources += [ 255 "src/image/loaders/image_loader_stb_image.cpp", 256 "src/image/loaders/image_loader_stb_image.h", 257 ] 258 } 259 260 configs = [ 261 ":lume_engine_config", 262 ":lume_default", 263 ":lume_engine_api", 264 ":lume_base_api", 265 ] 266 267 external_deps = [ 268 "bounds_checking_function:libsec_shared", 269 "c_utils:utils", 270 "resource_management:global_resmgr", 271 ] 272 273 if (LUME_OHOS_BUILD) { 274 external_deps += [ "hilog:libhilog" ] 275 } 276 part_name = "graphic_3d" 277 subsystem_name = "graphic" 278} 279 280lume_rofs("lume_engine_rofs") 281{ 282 output_obj= "" 283 if (target_cpu == "arm") { 284 output_obj = "${CORE_ROFS}_32.o" 285 } 286 287 if (target_cpu == "arm64") { 288 output_obj = "${CORE_ROFS}_64.o" 289 } 290 291 if (target_cpu == "x86") { 292 output_obj = "${CORE_ROFS}_x32.o" 293 } 294 295 if (target_cpu == "x64") { 296 output_obj = "${CORE_ROFS}_x64.o" 297 } 298 299 outputs = "${target_gen_dir}/assets/${output_obj}" 300 301 tool_path = "$target_gen_dir/../LumeBinaryCompile/lumeassetcompiler" 302 root = "/" 303 bin_name = "BINARYDATAFORCORE" 304 size_name = "SIZEOFDATAFORCORE" 305 base_name = CORE_ROFS 306 script = "./tools/CompilerAsset.sh" 307 copy_path = "$target_gen_dir/assets" 308 file_extension = "" 309 compileShader_deps=["${LUME_BINARY_PATH}/lumeassetcompiler:lume_binary_assets_compile"] 310 if (ohos_indep_compiler_enable) { 311 tool_path = "//prebuilts/graphics_3d/AGPBinaryCompile/" 312 compileShader_deps -= [ 313 "${LUME_BINARY_PATH}/lumeassetcompiler:lume_binary_assets_compile", 314 ] 315 } 316} 317 318source_set("lume_engine_rofs_obj") { 319 output_obj = "" 320 if (target_cpu == "arm") { 321 output_obj = "${CORE_ROFS}_32.o" 322 } 323 324 if (target_cpu == "arm64") { 325 output_obj = "${CORE_ROFS}_64.o" 326 } 327 328 if (target_cpu == "x86") { 329 output_obj = "${CORE_ROFS}_x32.o" 330 } 331 332 if (target_cpu == "x64") { 333 output_obj = "${CORE_ROFS}_x64.o" 334 } 335 336 sources = [ 337 "${target_gen_dir}/assets/${output_obj}" 338 ] 339 deps = [ 340 ":lume_engine_rofs" 341 ] 342} 343 344ohos_static_library("libAGPEngine") { 345 deps = [ 346 ":lume_engine_src", 347 ":lume_engine_rofs_obj" 348 ] 349 350 part_name = "graphic_3d" 351 subsystem_name = "graphic" 352 353} 354 355config("lume_component_help_config") { 356 include_dirs = [ 357 "ecshelper", 358 ] 359 360 cflags = [ 361 "-Wno-unused-function", 362 ] 363} 364 365ohos_shared_library("AGPBaseApi") { 366 public_configs = [ 367 ":lume_base_api" 368 ] 369 370 part_name = "graphic_3d" 371 subsystem_name = "graphic" 372} 373 374ohos_shared_library("AGPEngineApi") { 375 public_configs = [ 376 ":lume_engine_api" 377 ] 378 379 part_name = "graphic_3d" 380 subsystem_name = "graphic" 381} 382 383ohos_shared_library("AGPEcshelperApi") { 384 public_configs = [ 385 ":lume_component_help_config" 386 ] 387 388 part_name = "graphic_3d" 389 subsystem_name = "graphic" 390} 391 392ohos_source_set("lume_component_help_src") { 393 public_configs = [ 394 ":lume_component_help_config", 395 ":lume_base_api", 396 ":lume_engine_api", 397 ] 398 399 sources = [ 400 "ecshelper/ComponentTools/base_manager.inl", 401 "ecshelper/ComponentTools/base_manager.h", 402 "ecshelper/ComponentTools/component_query.h", 403 "ecshelper/ComponentTools/component_query.cpp", 404 ] 405 406 external_deps = [ "bounds_checking_function:libsec_shared" ] 407 part_name = "graphic_3d" 408 subsystem_name = "graphic" 409} 410 411ohos_static_library("libComponentHelper") { 412 public_configs = [ 413 ":lume_component_help_config", 414 ":lume_base_api", 415 ":lume_engine_api", 416 ":lume_default", 417 ] 418 419 deps = [ 420 ":lume_component_help_src", 421 ] 422 423 part_name = "graphic_3d" 424 subsystem_name = "graphic" 425} 426