# Copyright (c) 2024 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("//build/ohos.gni") import("//foundation/graphic/graphic_2d/graphic_config.gni") import("//foundation/graphic/graphic_3d/lume/lume_config.gni") declare_args() { CORE_ROFS = "rofs" CORE_EMBEDDED_ASSETS_ENABLED = true } config("lume_base_api") { include_dirs = [ "${LUME_BASE_PATH}/api", "//third_party/bounds_checking_function/include", ] defines = [ "BASE_TESTS_ENABLED=0", "BASE_WARNINGS_AS_ERRORS=0", ] if (BUILDTYPE == "Release") { defines += [ "BASE_LOG_NO_DEBUG=0" ] } if (BUILDTYPE == "MinSizeRel") { defines += [ "BASE_LOG_NO_DEBUG=0" ] } if (BUILDTYPE == "RelWithDebInfo") { defines += [ "BASE_LOG_NO_DEBUG=0" ] } } config("lume_engine_api") { include_dirs = [ "${LUME_CORE_PATH}/api" ] if (LUME_OHOS_BUILD) { include_dirs += [ "${LUME_CORE_PATH}/api/platform/ohos/" ] } defines = [ "CORE_BUILD_BASE=1", "CORE_HIDE_SYMBOLS=1", "CORE_PERF_ENABLED=0", "CORE_USE_COMPILER_GENERATED_STATIC=1", ] if (BUILDTYPE == "Release") { defines += [ "CORE_LOG_NO_DEBUG=0" ] } if (BUILDTYPE == "MinSizeRel") { defines += [ "CORE_LOG_NO_DEBUG=0" ] } if (BUILDTYPE == "RelWithDebInfo") { defines += [ "CORE_LOG_NO_DEBUG=0" ] } } config("lume_default") { cflags = [ "-Wno-unused-function", "-Wno-unused-parameter", "-Wno-sign-compare", "-Wno-unused-variable", "-Wno-unused-private-field", "-Wno-tautological-unsigned-zero-compare", "-Wno-logical-op-parentheses", "-fno-rtti", "-fvisibility=hidden", "-ffunction-sections", "-fdata-sections", ] cflags_cc = [ "-std=c++17", "-Wno-thread-safety-attributes", ] ldflags = [ "-fuse-ld=lld", "-flto=thin", "-Wl,--no-threads", "-Wl,--gc-sections", "-Wl,--exclude-libs,ALL", ] if (use_musl) { ldflags -= [ "-Wl,--no-threads" ] } if (LUME_OHOS_BUILD) { defines = [ "__OHOS_PLATFORM__" ] } defines += [ "LIB_ENGINE_CORE=${LIB_ENGINE_CORE}", "LIB_RENDER=${LIB_RENDER}", "LIB_CORE3D=${LIB_CORE3D}", ] } config("lume_engine_config") { include_dirs = [ "${LUME_CORE_PATH}/3rdparty/", "${LUME_CORE_PATH}/src/", "${LUME_CORE_PATH}/asserts/", "//commonlibrary/c_utils/base/include", "${STB_IMAGE_PATH}", ] defines = [ "CORE_TESTS_ENABLED=0", "CORE_HIDE_SYMBOLS=1", "CORE_WARNINGS_AS_ERRORS=0", "CORE_DEV_ENABLED=${CORE_DEV_ENABLED}", "CORE_LOG_TO_CONSOLE=1", "CORE_LOG_TO_DEBUG_OUTPUT=1", "CORE_LOG_TO_FILE=0", "CORE_VALIDATION_ENABLED=0", "CORE_TESTS_ENABLED=0", "CORE_DYNAMIC=0", "CORE_BUILDTYPE=${BUILDTYPE}", "CORE_PUBLIC=__attribute__((visibility(\"default\")))", "USE_STB_IMAGE=$USE_STB_IMAGE", "USE_LIB_PNG_JPEG=$USE_LIB_PNG_JPEG", ] if (CORE_EMBEDDED_ASSETS_ENABLED) { defines += [ "CORE_EMBEDDED_ASSETS_ENABLED=1" ] } } ohos_source_set("lume_engine_src") { sources = [ "src/ecs/ecs.cpp", "src/ecs/entity_manager.cpp", "src/ecs/entity_manager.h", "src/engine.cpp", "src/engine.h", "src/engine_factory.cpp", "src/engine_factory.h", "src/image/image_loader_manager.cpp", "src/image/image_loader_manager.h", "src/image/loaders/gl_util.h", "src/image/loaders/image_loader_common.cpp", "src/image/loaders/image_loader_ktx.cpp", "src/image/loaders/image_loader_ktx.h", "src/image/loaders/image_loader_libjpeg.h", "src/image/loaders/image_loader_libpng.h", "src/image/loaders/image_loader_stb_image.h", "src/io/dev/file_monitor.cpp", "src/io/dev/file_monitor.h", "src/io/file_manager.cpp", "src/io/file_manager.h", "src/io/filesystem_api.cpp", "src/io/memory_file.cpp", "src/io/memory_file.h", "src/io/memory_filesystem.cpp", "src/io/memory_filesystem.h", "src/io/path_tools.cpp", "src/io/path_tools.h", "src/io/proxy_directory.cpp", "src/io/proxy_directory.h", "src/io/proxy_filesystem.cpp", "src/io/proxy_filesystem.h", "src/io/rofs_filesystem.cpp", "src/io/rofs_filesystem.h", "src/io/std_directory.cpp", "src/io/std_directory.h", "src/io/std_file.cpp", "src/io/std_file.h", "src/io/std_filesystem.cpp", "src/io/std_filesystem.h", "src/loader/json_util.h", "src/loader/system_graph_loader.cpp", "src/loader/system_graph_loader.h", "src/log/logger.cpp", "src/log/logger.h", "src/log/logger_output.cpp", "src/log/logger_output.h", "src/os/ohos/ohos_file.cpp", "src/os/ohos/ohos_file.h", "src/os/ohos/ohos_filesystem.cpp", "src/os/ohos/ohos_filesystem.h", "src/os/platform.h", "src/perf/performance_data_manager.cpp", "src/perf/performance_data_manager.h", "src/plugin_registry.cpp", "src/plugin_registry.h", "src/static_plugin_decl.h", "src/threading/dispatcher_impl.cpp", "src/threading/dispatcher_impl.h", "src/threading/dispatcher_task_queue.cpp", "src/threading/dispatcher_task_queue.h", "src/threading/parallel_impl.cpp", "src/threading/parallel_impl.h", "src/threading/parallel_task_queue.cpp", "src/threading/parallel_task_queue.h", "src/threading/sequential_impl.cpp", "src/threading/sequential_impl.h", "src/threading/sequential_task_queue.cpp", "src/threading/sequential_task_queue.h", "src/threading/task_queue.cpp", "src/threading/task_queue.h", "src/threading/task_queue_factory.cpp", "src/threading/task_queue_factory.h", "src/util/frustum_util.cpp", "src/util/frustum_util.h", "src/util/linear_allocator.h", "src/util/string_util.h", "src/version.cpp", ] # platform source if (LUME_OHOS_BUILD) { sources += [ "src/os/ohos/library_ohos.cpp", "src/os/ohos/logger_output.cpp", "src/os/ohos/platform_ohos.cpp", ] } if (USE_STB_IMAGE) { sources += [ "src/image/loaders/image_loader_stb_image.cpp" ] } if (USE_LIB_PNG_JPEG) { sources += [ "src/image/loaders/image_loader_libjpeg.cpp", "src/image/loaders/image_loader_libpng.cpp", ] } configs = [ ":lume_engine_config", ":lume_default", ":lume_engine_api", ":lume_base_api", ] external_deps = [ "c_utils:utils", "libpng:libpng", "resource_management:global_resmgr", "zlib:shared_libz", ] if (defined(ohos_lite)) { external_deps += [ "libjpeg-turbo:libjpeg" ] } else { external_deps += [ "libjpeg-turbo:turbojpeg" ] } public_deps = [] if (LUME_OHOS_BUILD) { external_deps += [ "hilog:libhilog" ] } part_name = "graphic_3d" subsystem_name = "graphic" } lume_rofs("lume_engine_rofs") { output_obj = "" if (target_cpu == "arm") { output_obj = "${CORE_ROFS}_32.o" } if (target_cpu == "arm64") { output_obj = "${CORE_ROFS}_64.o" } outputs = "${target_gen_dir}/assets/${output_obj}" tool_path = "$target_gen_dir" root = "/" bin_name = "BINARYDATAFORCORE" size_name = "SIZEOFDATAFORCORE" base_name = CORE_ROFS script = "./tools/CompilerAsset.sh" copy_path = "$target_gen_dir/assets" file_extension = "" compileShader_deps = [ "${LUME_BINARY_PATH}/lumeassetcompiler:lume_binary_assets_compile" ] } source_set("lume_engine_rofs_obj") { output_obj = "" if (target_cpu == "arm") { output_obj = "${CORE_ROFS}_32.o" } if (target_cpu == "arm64") { output_obj = "${CORE_ROFS}_64.o" } sources = [ "${target_gen_dir}/assets/${output_obj}" ] deps = [ ":lume_engine_rofs" ] } ohos_static_library("libAGPEngine") { deps = [ ":lume_engine_src" ] if (CORE_EMBEDDED_ASSETS_ENABLED) { deps += [ ":lume_engine_rofs_obj" ] } part_name = "graphic_3d" subsystem_name = "graphic" } config("lume_component_help_config") { include_dirs = [ "ecshelper" ] cflags = [ "-Wno-unused-function" ] } ohos_source_set("lume_component_help_src") { public_configs = [ ":lume_component_help_config", ":lume_base_api", ":lume_engine_api", ] sources = [ "ecshelper/ComponentTools/base_manager.h", "ecshelper/ComponentTools/base_manager.inl", "ecshelper/ComponentTools/component_query.cpp", "ecshelper/ComponentTools/component_query.h", "ecshelper/PropertyTools/core_metadata.inl", "ecshelper/PropertyTools/property_api_impl.h", "ecshelper/PropertyTools/property_api_impl.inl", "ecshelper/PropertyTools/property_data.cpp", "ecshelper/PropertyTools/property_data.h", "ecshelper/PropertyTools/property_macros.h", "ecshelper/PropertyTools/property_value.h", ] }