blob: 9dffdb35045ee173928cb91fa9c41cb49ebf82b3 [file] [log] [blame]
# Copyright 2022 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/components.gni")
import("//build/rust/rustc_library.gni")
import("//src/graphics/lib/compute/gn/build_rules.gni")
#
# Wrapper headers
#
config("config") {
include_dirs = [ "." ]
}
source_set("spinel_vk_rs_headers") {
public_configs = [ ":config" ]
public = [ "spinel_vk_rs.h" ]
sources = [ "spinel_vk_rs.h" ]
public_deps = [ "//src/graphics/lib/compute/spinel:headers" ]
}
#
# Wrapper sources
#
source_set("spinel_vk_rs") {
sources = [ "spinel_vk_rs.c" ]
public_deps = [
":spinel_vk_rs_headers",
graphics_compute_vulkan_loader_target,
]
deps = [
"//src/graphics/lib/compute/common",
"//src/graphics/lib/compute/common/vk",
"//src/graphics/lib/compute/spinel/platforms/vk:headers",
"//src/graphics/lib/compute/spinel/platforms/vk/ext/find_target",
]
}
#
# Rust bindings for Spinel
#
rustc_library("spinel-vk-rs") {
name = "spinel-vk-rs-sys"
with_unit_tests = true
version = "0.1.0"
edition = "2021"
sources = [ "src/lib.rs" ]
}
#
# If the Spinel header files have changed then two actions must be
# manually performed:
#
# 1) If so, the spinel.c-api files needs to be updated:
#
# $ ../scripts/hash_dir.py \
# --header_paths ../spinel/include/spinel/* \
# --header_dir $FUCHSIA_DIR/src/graphics/lib/compute \
# > spinel.c-api
#
#
# 2) Regenerate the Rust bindings:
#
# $ bash bindgen.sh
#
# Note that the bindgen script requires the following prebuilts to be
# in your path:
#
# * bindgen
# * rustfmt
#
action("spinel_c_api_header_hashes") {
script = "${graphics_compute_dir}/scripts/hash_dir.py"
spinel_headers = "${graphics_compute_dir}/spinel/include"
sources = [ "spinel.c-api" ]
inputs = [
"spinel_vk_rs.h",
"${spinel_headers}/spinel/spinel.h",
"${spinel_headers}/spinel/spinel_assert.h",
"${spinel_headers}/spinel/spinel_opcodes.h",
"${spinel_headers}/spinel/spinel_result.h",
"${spinel_headers}/spinel/spinel_types.h",
]
stamp = "$target_gen_dir/$target_name.stamp"
outputs = [ stamp ]
args = [ "--header_paths" ] + rebase_path(inputs, root_build_dir) + [
"--header_dir",
rebase_path(graphics_compute_dir, root_build_dir),
"--compare",
rebase_path("spinel.c-api", root_build_dir),
"--stamp",
rebase_path(stamp, root_build_dir),
]
}
#
# Force the hash check
#
group("tests") {
testonly = true
public_deps = [
":spinel_c_api_header_hashes",
"tests",
]
}