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