From 43d009254805cf8c782fb8f3e769d385689ca412 Mon Sep 17 00:00:00 2001 From: shegangbin Date: Mon, 15 Jan 2024 11:09:50 +0800 Subject: [PATCH] vulkan-loader component Signed-off-by: shegangbin --- BUILD.gn | 286 +++++++++++-------------------------------- bundle.json | 43 +++++++ openharmony/BUILD.gn | 113 ----------------- 3 files changed, 117 insertions(+), 325 deletions(-) create mode 100644 bundle.json delete mode 100644 openharmony/BUILD.gn diff --git a/BUILD.gn b/BUILD.gn index 87537551..a1d776ce 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,6 +1,4 @@ -# Copyright (C) 2018-2019 The ANGLE Project Authors. -# Copyright (C) 2019 LunarG, Inc. -# +# Copyright (c) 2023 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 @@ -13,238 +11,102 @@ # See the License for the specific language governing permissions and # limitations under the License. -import("//build_overrides/build.gni") -import("//build_overrides/vulkan_loader.gni") +import("//build/ohos.gni") -declare_args() { - custom_vulkan_loader_library_name = "" -} +vulkan_headers_dir = "//third_party/vulkan-headers" -if (is_fuchsia) { - import("//build/cpp/sdk_shared_library.gni") - import("//build/sdk/sdk_documentation.gni") -} +# Vulkan loader build options -if (!is_android) { - vulkan_undefine_configs = [] -} -if (is_win) { - vulkan_undefine_configs += [ - "//build/config/win:nominmax", - "//build/config/win:unicode", - ] -} +## Build libvulkan.so {{{ config("vulkan_internal_config") { defines = [ + "VULKAN_NON_CMAKE_BUILD", "VK_ENABLE_BETA_EXTENSIONS", ] - if (is_clang || !is_win) { - cflags = [ - "-Wno-conversion", - "-Wno-extra-semi", - "-Wno-implicit-fallthrough", - "-Wno-sign-compare", - "-Wno-unreachable-code", - "-Wno-unused-function", - "-Wno-unused-variable", - ] - } - if (is_fuchsia) { - defines += [ - "SYSCONFDIR=\"/config\"", - "EXTRASYSCONFDIR=\"/pkg/data\"", - ] - } - if (is_linux || is_chromeos || is_mac) { - defines += [ - "SYSCONFDIR=\"/etc\"", - "FALLBACK_CONFIG_DIRS=\"/etc/xdg\"", - "FALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"", - ] - } -} + cflags = [ + "-Wno-conversion", + "-Wno-extra-semi", + "-Wno-implicit-fallthrough", + "-Wno-sign-compare", + "-Wno-unreachable-code", + "-Wno-unused-function", + "-Wno-unused-variable", + "-fPIC", + ] + ldflags = [ "-Wl,-Bsymbolic" ] -# Vulkan loader -# ------------- + defines += [ + "SYSCONFDIR=\"/system/etc\"", + "FALLBACK_CONFIG_DIRS=\"/vendor/etc\"", + "FALLBACK_DATA_DIRS=\"/data\"", + "VK_USE_PLATFORM_OHOS", + ] +} config("vulkan_loader_config") { include_dirs = [ "loader/generated", "loader", + "openharmony", ] defines = [ "API_NAME=\"Vulkan\"", "USE_UNSAFE_FILE_SEARCH=1", ] - - if (is_win) { - cflags = [ "/wd4201" ] - } - if (is_linux || is_chromeos) { - # assume secure_getenv() is available - defines += [ - "HAVE_SECURE_GETENV", - "LOADER_ENABLE_LINUX_SORT", - ] - } -} - -if (!is_android) { - if (is_fuchsia) { - library_type = "sdk_shared_library" - } else if (vulkan_loader_shared) { - library_type = "shared_library" - } else { - library_type = "static_library" - } - - target(library_type, "libvulkan") { - sources = [ - "loader/adapters.h", - "loader/allocation.c", - "loader/allocation.h", - "loader/asm_offset.c", - "loader/cJSON.c", - "loader/cJSON.h", - "loader/debug_utils.c", - "loader/debug_utils.h", - "loader/dev_ext_trampoline.c", - "loader/extension_manual.c", - "loader/extension_manual.h", - "loader/get_environment.c", - "loader/get_environment.h", - "loader/generated/vk_layer_dispatch_table.h", - "loader/generated/vk_loader_extensions.h", - "loader/generated/vk_object_types.h", - "loader/gpa_helper.h", - "loader/gpa_helper.c", - "loader/loader_common.h", - "loader/loader.c", - "loader/loader.h", - "loader/log.c", - "loader/log.h", - "loader/phys_dev_ext.c", - "loader/stack_allocation.h", - "loader/terminator.c", - "loader/trampoline.c", - "loader/unknown_function_handling.h", - "loader/unknown_function_handling.c", - "loader/vk_loader_layer.h", - - # TODO(jmadill): Use assembler where available. - "loader/unknown_ext_chain.c", - "loader/vk_loader_platform.h", - "loader/wsi.c", - "loader/wsi.h", - ] - - if (custom_vulkan_loader_library_name != "") { - output_name = custom_vulkan_loader_library_name - } else { - if (is_win) { - output_name = "vulkan-1" - } else { - output_name = "vulkan" - - # Create libvulkan.so.1 on Linux instead of libvulkan.so - if ((is_linux || is_chromeos) && vulkan_loader_shared) { - output_extension = "so.1" - } - } - } - - if (is_win) { - sources += [ - "loader/dirent_on_windows.c", - "loader/dirent_on_windows.h", - "loader/loader_windows.c", - "loader/loader_windows.h", - "loader/loader.rc", - "loader/vulkan-1.def", - ] - if (!is_clang) { - cflags = [ - "/wd4054", # Type cast from function pointer - "/wd4055", # Type cast from data pointer - "/wd4100", # Unreferenced formal parameter - "/wd4152", # Nonstandard extension used (pointer conversion) - "/wd4201", # Nonstandard extension used: nameless struct/union - "/wd4214", # Nonstandard extension used: bit field types other than - # int - "/wd4232", # Nonstandard extension used: address of dllimport is not - # static - "/wd4305", # Type cast truncation - "/wd4706", # Assignment within conditional expression - "/wd4996", # Unsafe stdlib function - ] - } - if (is_clang) { - cflags = [ "-Wno-incompatible-pointer-types" ] - } - libs = [ "Cfgmgr32.lib" ] - } - if (is_linux || is_chromeos) { - sources += [ - "loader/loader_linux.c", - "loader/loader_linux.h", - ] - } - if (is_mac) { - frameworks = [ "CoreFoundation.framework" ] - } - public_deps = [ "$vulkan_headers_dir:vulkan_headers" ] - configs -= [ "//build/config/compiler:chromium_code" ] - configs += [ "//build/config/compiler:no_chromium_code" ] - configs += [ ":vulkan_internal_config" ] - public_configs = [ ":vulkan_loader_config" ] - configs -= vulkan_undefine_configs - - if (is_fuchsia) { - category = "partner" - - # The Vulkan loader's interface is defined by standard Khronos vulkan headers - # which can be obtained separately from the loader implementation itself. - no_headers = true - - deps = [ - ":dlopen_fuchsia", - "//sdk/lib/fdio", - ] - - runtime_deps = [ "//sdk/lib/fdio:fdio_sdk" ] - } - } } -if (is_fuchsia) { - config("fuchsia_config") { - include_dirs = [ "fuchsia" ] - } - - source_set("dlopen_fuchsia") { - public_configs = [ ":fuchsia_config" ] +ohos_shared_library("vulkan_loader") { + sources = [ + "loader/adapters.h", + "loader/allocation.c", + "loader/allocation.h", + "loader/asm_offset.c", + "loader/cJSON.c", + "loader/cJSON.h", + "loader/debug_utils.c", + "loader/debug_utils.h", + "loader/dev_ext_trampoline.c", + "loader/extension_manual.c", + "loader/extension_manual.h", + "loader/generated/vk_layer_dispatch_table.h", + "loader/generated/vk_loader_extensions.h", + "loader/generated/vk_object_types.h", + "loader/get_environment.c", + "loader/get_environment.h", + "loader/gpa_helper.c", + "loader/gpa_helper.h", + "loader/loader.c", + "loader/loader.h", + "loader/loader_common.h", + "loader/log.c", + "loader/log.h", + "loader/phys_dev_ext.c", + "loader/stack_allocation.h", + "loader/terminator.c", + "loader/trampoline.c", + "loader/unknown_function_handling.c", + "loader/unknown_function_handling.h", + "loader/vk_loader_layer.h", + + # TODO(jmadill): Use assembler where available. + "loader/unknown_ext_chain.c", + "loader/vk_loader_platform.h", + "loader/wsi.c", + "loader/wsi.h", + ] - sources = [ - "fuchsia/dlopen_fuchsia.c", - "fuchsia/dlopen_fuchsia.h", - ] + public_deps = [ "$vulkan_headers_dir:vulkan_headers" ] + configs = [ ":vulkan_internal_config" ] + public_configs = [ ":vulkan_loader_config" ] + external_deps = [ "hilog:libhilog" ] - deps = [ - "//sdk/fidl/fuchsia.vulkan.loader:fuchsia.vulkan.loader_c_client", - "//sdk/lib/fdio", - ] - } + output_name = "vulkan" + output_extension = "so" - sdk_documentation("vulkan_license") { - name = "vulkan_license" - category = "public" + part_name = "graphic_2d" + subsystem_name = "graphic" - files = [ - { - source = "LICENSE.txt" - dest = "LICENSE.vulkan" - }, - ] - } + license_file = "//third_party/vulkan-loader/LICENSE.txt" } +## Build libvulkan.so }}} diff --git a/bundle.json b/bundle.json new file mode 100644 index 00000000..501f0621 --- /dev/null +++ b/bundle.json @@ -0,0 +1,43 @@ +{ + "name": "@ohos/vulkan-loader", + "description": "vulkan loader", + "version": "4.0", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "segment": { + "destPath": "third_party/vulkan-loader" + }, + "dirs": {}, + "scripts": {}, + "component": { + "name": "vulkan-loader", + "subsystem": "thirdparty", + "adapted_system_type": [ "standard" ], + "rom": "10000KB", + "ram": "10000KB", + "deps": { + "components": [ + "hilog" + ], + "third_party": [ + "vulkan-headers" + ] + }, + "build": { + "sub_component": [ + "//third_party/vulkan-loader:vulkan_loader" + ], + "inner_kits": [ + { + "type": "so", + "name": "//third_party/vulkan-loader:vulkan_loader", + "header": { + "header_files": [ + ], + "header_base": "//third_party/vulkan-loader" + } + } + ] + } + } + } diff --git a/openharmony/BUILD.gn b/openharmony/BUILD.gn deleted file mode 100644 index 4ed457c7..00000000 --- a/openharmony/BUILD.gn +++ /dev/null @@ -1,113 +0,0 @@ -# Copyright (c) 2023 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 -# -# https://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") - -vulkan_headers_dir = "//third_party/vulkan-headers" - -# Vulkan loader build options - -## Build libvulkan.so {{{ - -config("vulkan_internal_config") { - defines = [ - "VULKAN_NON_CMAKE_BUILD", - "VK_ENABLE_BETA_EXTENSIONS", - ] - cflags = [ - "-Wno-conversion", - "-Wno-extra-semi", - "-Wno-implicit-fallthrough", - "-Wno-sign-compare", - "-Wno-unreachable-code", - "-Wno-unused-function", - "-Wno-unused-variable", - "-fPIC", - ] - ldflags = [ "-Wl,-Bsymbolic" ] - - defines += [ - "SYSCONFDIR=\"/system/etc\"", - "FALLBACK_CONFIG_DIRS=\"/vendor/etc\"", - "FALLBACK_DATA_DIRS=\"/data\"", - "VK_USE_PLATFORM_OHOS", - ] -} - -config("vulkan_loader_config") { - include_dirs = [ - "../loader/generated", - "../loader", - "../openharmony", - "//drivers/peripheral/base", - ] - defines = [ - "API_NAME=\"Vulkan\"", - "USE_UNSAFE_FILE_SEARCH=1", - ] -} - -ohos_shared_library("vulkan_loader") { - sources = [ - "../loader/adapters.h", - "../loader/allocation.c", - "../loader/allocation.h", - "../loader/asm_offset.c", - "../loader/cJSON.c", - "../loader/cJSON.h", - "../loader/debug_utils.c", - "../loader/debug_utils.h", - "../loader/dev_ext_trampoline.c", - "../loader/extension_manual.c", - "../loader/extension_manual.h", - "../loader/generated/vk_layer_dispatch_table.h", - "../loader/generated/vk_loader_extensions.h", - "../loader/generated/vk_object_types.h", - "../loader/get_environment.c", - "../loader/get_environment.h", - "../loader/gpa_helper.c", - "../loader/gpa_helper.h", - "../loader/loader.c", - "../loader/loader.h", - "../loader/loader_common.h", - "../loader/log.c", - "../loader/log.h", - "../loader/phys_dev_ext.c", - "../loader/stack_allocation.h", - "../loader/terminator.c", - "../loader/trampoline.c", - "../loader/unknown_function_handling.c", - "../loader/unknown_function_handling.h", - "../loader/vk_loader_layer.h", - - # TODO(jmadill): Use assembler where available. - "../loader/unknown_ext_chain.c", - "../loader/vk_loader_platform.h", - "../loader/wsi.c", - "../loader/wsi.h", - ] - - public_deps = [ "$vulkan_headers_dir:vulkan_headers" ] - configs = [ ":vulkan_internal_config" ] - public_configs = [ ":vulkan_loader_config" ] - external_deps = [ "hilog:libhilog" ] - - output_name = "vulkan" - output_extension = "so" - - part_name = "graphic_2d" - subsystem_name = "graphic" - - license_file = "//third_party/vulkan-headers/LICENSE.txt" -} -## Build libvulkan.so }}} -- Gitee