blob: 64533f5d0d984d5abd9ab80abea76d18ca01eb67 [file] [log] [blame]
# 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/bind/bind.gni")
import("//build/cipd.gni")
import("//build/config/fuchsia/rules.gni")
import("//build/dist/resource.gni")
import("//src/sys/build/components.gni")
template("ot_radio_driver") {
forward_variables_from(invoker,
[
"board",
"firmware_type",
"firmware_config",
])
firmware_name =
"ot-" + firmware_config + "-app-" + firmware_type + "-" + board + ".bin"
if (!internal_access) {
# Unused variable
not_needed([ "firmware_name" ])
}
driver_suffix = target_name
driver_module("ot-radio-${driver_suffix}") {
output_name = "ot-radio-driver-${driver_suffix}"
sources = [
"ot_radio.cc",
"ot_radio_tests.cc",
]
deps = [
"//sdk/banjo/fuchsia.hardware.gpio:fuchsia.hardware.gpio_banjo_cpp",
"//sdk/banjo/fuchsia.hardware.spi",
"//sdk/fidl/fuchsia.lowpan.spinel:fuchsia.lowpan.spinel_llcpp",
"//src/connectivity/openthread/drivers/ot-radio:ot_radio_bind",
"//src/connectivity/openthread/third_party/openthread:spinel-framer",
"//src/devices/lib/driver",
"//src/lib/ddk",
"//src/lib/ddktl",
"//zircon/public/lib/async-cpp",
"//zircon/public/lib/fbl",
"//zircon/public/lib/sync",
"//zircon/public/lib/zircon-internal",
"//zircon/public/lib/zx",
"//zircon/public/lib/zxtest",
"//zircon/system/ulib/async-loop:async-loop-cpp",
"//zircon/system/ulib/async-loop:async-loop-default",
"//zircon/system/ulib/driver-unit-test",
"//zircon/system/ulib/fidl-async:fidl-async-cpp",
]
include_dirs =
[ "//src/connectivity/openthread/third_party/openthread/spinel-framer" ]
if (internal_access) {
sources += [ "ot_radio_bootloader.cc" ]
defines = [
"INTERNAL_ACCESS",
"OT_NCP_FIRMWARE_BIN=\"" + firmware_name + "\"",
]
deps += [ ":version-string-${driver_suffix}" ]
}
}
if (internal_access) {
source_set("version-string-${driver_suffix}") {
sources = [
"$target_gen_dir/ot_radio_firmware_version_string-${driver_suffix}.cc",
]
deps = [ ":gen-version-string-${driver_suffix}" ]
}
resource("ot-radio-firmware-${driver_suffix}") {
sources = [ "//prebuilt/connectivity/openthread/radio-firmware/" +
firmware_name ]
outputs = [ "lib/firmware/${firmware_name}" ]
}
action("gen-version-string-${driver_suffix}") {
visibility = [ ":version-string-${driver_suffix}" ]
outputs = [
"$target_gen_dir/ot_radio_firmware_version_string-${driver_suffix}.cc",
]
sources = [ "//prebuilt/connectivity/openthread/radio-firmware/" +
firmware_name ]
script = "gen-version-string.sh"
args = rebase_path(outputs, root_build_dir) +
rebase_path(sources, root_build_dir)
}
}
fuchsia_system_package("openthread-${driver_suffix}") {
# Fuchsia does not yet support loading drivers out of packages.
deps = [ ":ot-radio-${driver_suffix}" ]
if (internal_access) {
deps += [ ":ot-radio-firmware-${driver_suffix}" ]
}
allowed_in_extra_deps = true
}
}