1# Copyright (C) 2018-2019 The ANGLE Project Authors. 2# Copyright (C) 2019-2023 LunarG, Inc. 3# Copyright (c) 2023-2024 Huawei Device Co., Ltd. 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# https://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16import("//build/ohos.gni") 17 18group("vulkan_loader_test") { 19 testonly = true 20 21 public_deps = [ "openharmony/test:test" ] 22} 23 24# Vulkan loader build options 25 26## Build libvulkan.so {{{ 27 28config("vulkan_internal_config") { 29 defines = [ "VK_ENABLE_BETA_EXTENSIONS" ] 30 cflags = [ 31 "-Wno-conversion", 32 "-Wno-extra-semi", 33 "-Wno-sign-compare", 34 "-Wno-unreachable-code", 35 "-Wno-unused-function", 36 "-Wno-unused-variable", 37 "-fPIC", 38 ] 39 40 cflags_cc = [ "-std=c++17" ] 41 ldflags = [ "-Wl,-Bsymbolic" ] 42 43 defines += [ 44 "SYSCONFDIR=\"/system/etc:/vendor/etc\"", 45 "VK_USE_PLATFORM_OHOS", 46 ] 47} 48 49config("vulkan_loader_config") { 50 include_dirs = [ 51 "loader/generated", 52 "loader", 53 "openharmony", 54 ] 55 defines = [ "LOADER_USE_UNSAFE_FILE_SEARCH=1" ] 56} 57 58support_unknown_function_handling = false 59if (defined(ar_path) && ar_path != "" && !is_win && 60 (current_cpu == "arm64" || current_cpu == "x86_64")) { 61 support_unknown_function_handling = true 62 static_library("asm_offset") { 63 sources = [ "loader/asm_offset.c" ] 64 deps = [ "$vulkan_headers_dir:vulkan_headers" ] 65 66 # Output raw assembly instead of compiled object file. The assembly will be included as a member of the output ar file. 67 cflags = [ "-S" ] 68 configs += [ ":vulkan_internal_config" ] 69 configs += [ ":vulkan_loader_config" ] 70 } 71 72 action("gen_defines") { 73 script = "scripts/parse_asm_values.py" 74 deps = [ ":asm_offset" ] 75 76 inputs = [ 77 "$target_out_dir/libasm_offset.a", 78 ar_path, 79 ] 80 if (current_cpu == "arm64") { 81 cpu = "aarch64" 82 } else { 83 cpu = "x86_64" 84 } 85 args = [ 86 rebase_path("$target_gen_dir/gen_defines.asm", root_build_dir), 87 rebase_path("$target_out_dir/libasm_offset.a", root_build_dir), 88 "GAS", 89 "Clang", 90 cpu, 91 rebase_path(ar_path, root_build_dir), 92 "libasm_offset.asm_offset.c.o", 93 ] 94 outputs = [ "$target_gen_dir/gen_defines.asm" ] 95 } 96} 97 98ohos_shared_library("vulkan_loader") { 99 branch_protector_ret = "pac_ret" 100 sources = [ 101 "loader/adapters.h", 102 "loader/allocation.c", 103 "loader/allocation.h", 104 "loader/cJSON.c", 105 "loader/cJSON.h", 106 "loader/debug_utils.c", 107 "loader/debug_utils.h", 108 109 # Should only be linked when assembler is used 110 # "loader/dev_ext_trampoline.c", 111 "loader/extension_manual.c", 112 "loader/extension_manual.h", 113 "loader/generated/vk_layer_dispatch_table.h", 114 "loader/generated/vk_loader_extensions.h", 115 "loader/generated/vk_object_types.h", 116 "loader/gpa_helper.c", 117 "loader/gpa_helper.h", 118 "loader/loader.c", 119 "loader/loader.h", 120 "loader/loader_common.h", 121 "loader/loader_environment.c", 122 "loader/loader_environment.h", 123 "loader/loader_json.c", 124 "loader/loader_json.h", 125 "loader/log.c", 126 "loader/log.h", 127 128 # Should only be linked when assembler is used 129 # "loader/phys_dev_ext.c", 130 "loader/settings.c", 131 "loader/settings.h", 132 "loader/stack_allocation.h", 133 "loader/terminator.c", 134 "loader/trampoline.c", 135 "loader/unknown_function_handling.c", 136 "loader/unknown_function_handling.h", 137 "loader/vk_loader_layer.h", 138 "loader/vk_loader_platform.h", 139 "loader/wsi.c", 140 "loader/wsi.h", 141 "openharmony/bundle_mgr_helper/vk_bundle_mgr_helper.cpp", 142 "openharmony/bundle_mgr_helper/vk_bundle_mgr_helper.h", 143 "openharmony/loader_hilog.h", 144 ] 145 146 configs = [ ":vulkan_internal_config" ] 147 public_configs = [ ":vulkan_loader_config" ] 148 external_deps = [ 149 "bundle_framework:appexecfwk_base", 150 "bundle_framework:appexecfwk_core", 151 "c_utils:utils", 152 "hilog:libhilog", 153 "init:libbegetutil", 154 "ipc:ipc_core", 155 "samgr:samgr_proxy", 156 "vulkan-headers:vulkan_headers", 157 ] 158 159 if (support_unknown_function_handling) { 160 if (current_cpu == "arm64") { 161 sources += [ "loader/unknown_ext_chain_gas_aarch.S" ] 162 } else if (current_cpu == "x86_64") { 163 sources += [ "loader/unknown_ext_chain_gas_x86.S" ] 164 } else { 165 assert(false, "Unexpected CPU $current_cpu") 166 } 167 168 defines += [ "UNKNOWN_FUNCTIONS_SUPPORTED=1" ] 169 deps += [ ":gen_defines" ] 170 include_dirs = [ "$target_gen_dir" ] 171 } 172 173 output_name = "vulkan" 174 output_extension = "so" 175 176 part_name = "vulkan-loader" 177 subsystem_name = "thirdparty" 178 license_file = "//third_party/vulkan-loader/LICENSE.txt" 179} 180## Build libvulkan.so }}} 181