| # 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/components.gni") | |
| import("//build/dist/resource.gni") | |
| import("//build/drivers.gni") | |
| import("//third_party/openthread/openthread_upstream_version.gni") | |
| template("ot_radio_driver") { | |
| forward_variables_from(invoker, | |
| [ | |
| "board", | |
| "firmware_type", | |
| "firmware_config", | |
| ]) | |
| if (openthread_upstream_version == | |
| "130957d48981c1294c8fc90d51556134cf935d6f" && firmware_config == "rcp" && | |
| board == "sherlock") { | |
| firmware_name = "ot-" + firmware_config + "-app-" + firmware_type + "-" + | |
| board + "-130957d48.bin" | |
| } else { | |
| firmware_name = | |
| "ot-" + firmware_config + "-app-" + firmware_type + "-" + board + ".bin" | |
| } | |
| if (!internal_access) { | |
| # Unused variable | |
| not_needed([ "firmware_name" ]) | |
| } | |
| driver_suffix = target_name | |
| fuchsia_driver("ot-radio-${driver_suffix}_driver") { | |
| 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:fuchsia.hardware.spi_banjo_cpp", | |
| "//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/system/ulib/async:async-cpp", | |
| "//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/fbl", | |
| "//zircon/system/ulib/fidl-async:fidl-async-cpp", | |
| "//zircon/system/ulib/inspect", | |
| "//zircon/system/ulib/sync", | |
| "//zircon/system/ulib/zircon-internal", | |
| "//zircon/system/ulib/zx", | |
| "//zircon/system/ulib/zxtest", | |
| ] | |
| 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}" ] | |
| } | |
| # TODO(https://fxbug.dev/58162): delete the below and fix compiler warnings | |
| configs += [ "//build/config:Wno-conversion" ] | |
| } | |
| fuchsia_driver_component("ot-radio-${driver_suffix}") { | |
| deps = [ ":ot-radio-${driver_suffix}_driver" ] | |
| info = "ot-radio-${driver_suffix}-info.json" | |
| colocate = true | |
| } | |
| 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_driver_package("openthread-${driver_suffix}") { | |
| driver_components = [ ":ot-radio-${driver_suffix}" ] | |
| deps = [] | |
| if (internal_access) { | |
| deps += [ ":ot-radio-firmware-${driver_suffix}" ] | |
| } | |
| } | |
| } |