| # Copyright 2020 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config.gni") |
| import("//build/cpp/extract_imported_symbols.gni") |
| import("//build/cpp/verify_imported_symbols.gni") |
| import("//build/testing/environments.gni") |
| import( |
| "//src/graphics/lib/magma/src/magma_util/platform/zircon/driver_entry.gni") |
| |
| declare_args() { |
| magma_build_root = "//src/graphics/lib/magma" |
| expat_build_root = "//third_party/expat" |
| msd_build_root = "//src/graphics/drivers" |
| msd_intel_gen_build_root = "$msd_build_root/msd-intel-gen" |
| glm_build_root = "//third_party/glm" |
| zircon_build_root = "//zircon" |
| |
| magma_python_path = rebase_path("//third_party/mako") |
| |
| # Enable this to include fuchsia tracing capability |
| magma_enable_tracing = true |
| |
| # Enable this to have the msd include a suite of tests and invoke them |
| # automatically when the driver starts. |
| magma_enable_developer_build = false |
| |
| prebuilt_libvulkan_arm_path = "" |
| |
| # The path to a prebuilt libvulkan.so for an IMG GPU. |
| prebuilt_libvulkan_img_path = "" |
| |
| # The path to OpenVX headers |
| magma_openvx_include = "" |
| |
| # The path to an OpenVX implementation |
| magma_openvx_package = "" |
| } |
| |
| declare_args() { |
| # Targets that will be built as mali vulkan ICDS. |
| build_libvulkan_arm_mali = [] |
| |
| # Targets that will be built as verisilicon vulkan ICDS. |
| build_libvulkan_vsi_vip = [] |
| |
| # Targets that will be built as qualcomm vulkan ICDS. |
| build_libvulkan_qcom_adreno = [] |
| |
| # Targets that will be built as IMG vulkan ICDS. |
| build_libvulkan_img_rgx = [] |
| |
| # Board files can set this to true if they have a package with a mali libvulkan VCD. |
| board_has_libvulkan_arm_mali = false |
| } |
| |
| have_prebuilt_libvulkan_arm = prebuilt_libvulkan_arm_path != "" |
| have_prebuilt_libvulkan_img = prebuilt_libvulkan_img_path != "" |
| build_libvulkan = build_libvulkan_arm_mali + build_libvulkan_vsi_vip + |
| build_libvulkan_qcom_adreno + build_libvulkan_img_rgx |
| have_libvulkan = build_libvulkan != [] || have_prebuilt_libvulkan_arm || |
| have_prebuilt_libvulkan_img |
| |
| # Target environments with an Intel GPU. |
| intel_gpu_envs = [ nuc_env ] |
| |
| # Target environments with an ARM Mali GPU. |
| arm_gpu_envs = [ |
| astro_env, |
| sherlock_env, |
| ] |
| |
| # General hardware environments for magma tests to target. |
| magma_hardware_envs = intel_gpu_envs + arm_gpu_envs |
| |
| magma_libvulkan_hardware_envs = intel_gpu_envs |
| |
| magma_libvulkan_arm_hardware_envs = [] |
| if (build_libvulkan_arm_mali != [] || have_prebuilt_libvulkan_arm || |
| board_has_libvulkan_arm_mali) { |
| magma_libvulkan_arm_hardware_envs += arm_gpu_envs |
| } |
| |
| magma_libvulkan_hardware_envs += magma_libvulkan_arm_hardware_envs |
| |
| template("magma_vulkan_icd") { |
| assert(defined(invoker.output_name), "output_name must be provided") |
| if (is_fuchsia) { |
| assert(defined(invoker.imported_symbols_allowlist), |
| "imported_symbols_allowlist must be provided") |
| } |
| |
| has_allowlist = defined(invoker.imported_symbols_allowlist) |
| |
| shared_library_target_name = "${target_name}__shlib" |
| shared_library(shared_library_target_name) { |
| forward_variables_from(invoker, |
| "*", |
| [ |
| "imported_symbols_allowlist", |
| "configs", |
| ]) |
| if (defined(invoker.configs)) { |
| configs += invoker.configs |
| } |
| if (!is_debug) { |
| version_script = |
| rebase_path("//src/graphics/lib/magma/scripts/libvulkan.version") |
| if (!defined(invoker.inputs)) { |
| inputs = [] |
| } |
| inputs += [ version_script ] |
| if (!defined(invoker.ldflags)) { |
| ldflags = [] |
| } |
| ldflags += [ "-Wl,--version-script=$version_script" ] |
| } |
| } |
| |
| if (has_allowlist) { |
| lib_name = "${invoker.output_name}.so" |
| extract_imported_symbols_target_name = |
| "${target_name}__extract_imported_symbols" |
| verify_imported_symbols_target_name = |
| "${target_name}__verify_imported_symbols" |
| |
| shared_out_dir = get_label_info(":bogus($shlib_toolchain)", "root_out_dir") |
| |
| imported_symbols_allowlist_file = |
| rebase_path(invoker.imported_symbols_allowlist) |
| generated_imported_symbols_file = |
| "$target_gen_dir/${invoker.output_name}.imported_symbols.list" |
| extract_imported_symbols(extract_imported_symbols_target_name) { |
| library = "$shared_out_dir/$lib_name" |
| symbols = generated_imported_symbols_file |
| |
| deps = [ ":$shared_library_target_name" ] |
| } |
| |
| verify_imported_symbols(verify_imported_symbols_target_name) { |
| current = generated_imported_symbols_file |
| allowlist = imported_symbols_allowlist_file |
| library_name = lib_name |
| deps = [ ":$extract_imported_symbols_target_name" ] |
| } |
| } |
| |
| group(target_name) { |
| public_deps = [ ":$shared_library_target_name" ] |
| |
| if (has_allowlist) { |
| public_deps += [ ":$verify_imported_symbols_target_name" ] |
| } |
| } |
| } |
| |
| template("icd_config_data") { |
| assert(defined(invoker.icds)) |
| manifest_files = [] |
| manifest_targets = [] |
| foreach(entry, invoker.icds) { |
| manifest_file = entry.manifest |
| manifest_target = "${target_name}_${entry.lib}_gen" |
| action(manifest_target) { |
| script = "//src/graphics/lib/magma/scripts/gen_icd_manifest.sh" |
| args = [ |
| "${entry.lib}", |
| rebase_path("${manifest_file}", root_build_dir), |
| ] |
| outputs = [ manifest_file ] |
| } |
| manifest_files += [ rebase_path(manifest_file) ] |
| manifest_targets += [ ":${manifest_target}" ] |
| } |
| config_data(target_name) { |
| forward_variables_from(invoker, "*") |
| sources = manifest_files |
| deps = manifest_targets |
| for_pkg = "vulkan-icd" |
| outputs = [ "icd.d/{{source_file_part}}" ] |
| } |
| } |