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