blob: 484d7643270bce6206ed74de9564e2b50649eacc [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/components.gni")
import("//build/drivers.gni")
# Defines a controller driver
#
# This template creates a fuchsia_driver and driver_package customized for a
# specific target. Each instantiation must provide a dependency on a
# source_set that provides an implementation of camera::ProductConfig::Create.
# See //src/camera/drivers/controller/configs/product_config.h for more
# details.
#
# Example:
# ```
# camera_controller_driver(my_product_controller) {
# deps = [
# "//src/camera/drivers/controller/configs/my_product",
# ]
# }
# ```
#
# Parameters
# deps (required)
# List of additional dependencies to link. This must provide an implementation
# of camera::ProductConfig::Create.
# Type: list(path)
#
# package_name (optional)
# The name of the driver package.
# Type: string
# Default: $target_name
#
# gdc_config_files (optional)
# List of paths, relative to //prebuilt/camera/arm/gdc/configs, to include
# in the driver package.
# Type: list(path)
#
# watermark_files (optional)
# List of paths, relative to //prebuilt/camera/watermark, to include in the
# driver package.
# Type: list(path)
#
template("camera_controller_driver") {
package_name = target_name
if (defined(invoker.package_name)) {
package_name = invoker.package_name
}
driver_target = "${package_name}_driver"
fuchsia_driver(driver_target) {
output_name = package_name
deps = [
"//sdk/lib/syslog/cpp:backend",
"//src/camera/drivers/controller:source",
]
if (defined(invoker.deps)) {
deps += invoker.deps
}
configs += [ "//build/config/fuchsia:enable_zircon_asserts" ]
}
driver_component_target = "${package_name}_driver_component"
fuchsia_driver_component(driver_component_target) {
colocate = true
deps = [ ":${driver_target}" ]
info = "${driver_target}-info.json"
}
if (defined(invoker.gdc_config_files)) {
resource("firmware-configs-$target_name") {
sources = []
foreach(config_file, invoker.gdc_config_files) {
assert(
get_path_info(config_file, "dir") == ".",
"gdc_config_files entry cannot have sub-directory: " + config_file)
sources += [ "//prebuilt/camera/arm/gdc/configs/" + config_file ]
}
outputs = [ "lib/firmware/{{source_file_part}}" ]
}
}
if (defined(invoker.watermark_files)) {
resource("firmware-watermarks-$target_name") {
sources = []
foreach(watermark_file, invoker.watermark_files) {
assert(get_path_info(watermark_file, "dir") == ".",
"waternark_files entry cannot have sub-directory: " +
watermark_file)
sources += [ "//prebuilt/camera/watermark/" + watermark_file ]
}
outputs = [ "lib/firmware/{{source_file_part}}" ]
}
}
fuchsia_driver_package(package_name) {
driver_components = [ ":${driver_component_target}" ]
deps = []
if (defined(invoker.gdc_config_files)) {
deps += [ ":firmware-configs-$package_name" ]
}
if (defined(invoker.watermark_files)) {
deps += [ ":firmware-watermarks-$package_name" ]
}
}
}