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