blob: bf3b23aae9bb394508b3a9459e1497418cb369ff [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.
load(
"@rules_fuchsia//fuchsia:defs.bzl",
"fuchsia_bind_cc_library",
"fuchsia_bind_library",
"fuchsia_component_manifest",
"fuchsia_driver_bytecode_bind_rules",
"fuchsia_driver_component",
"fuchsia_fidl_bind_library",
"fuchsia_fidl_library",
"fuchsia_fidl_llcpp_library",
"fuchsia_package",
)
#[START fuchsia_gizmo_library]
# This is a bind library that we manually define.
fuchsia_bind_library(
name = "fuchsia.gizmo.library",
srcs = [
"testlibrary.bind",
],
deps = [
"@fuchsia_sdk//bind/fuchsia.acpi", # An SDK bind library.
],
)
# We have to create the C++ library for it manually as well.
fuchsia_bind_cc_library(
name = "fuchsia.gizmo.library_cc",
library = ":fuchsia.gizmo.library",
# Has to have the C++ libraries of all the deps of the bind library.
deps = [
"@fuchsia_sdk//bind/fuchsia.acpi:fuchsia.acpi_cc", # An SDK bind library's C++ lib.
],
)
#[END fuchsia_gizmo_library]
#[START fuchsia_gizmo_protocol]
# This is a FIDL library that we manually define.
fuchsia_fidl_library(
name = "fuchsia.gizmo.protocol",
srcs = [
"testfidl.fidl",
],
library = "fuchsia.gizmo.protocol",
)
# The C++ bindings for the FIDL library.
fuchsia_fidl_llcpp_library(
name = "fuchsia.gizmo.protocol_cc",
library = ":fuchsia.gizmo.protocol",
deps = [
"@fuchsia_sdk//pkg/fidl_cpp_wire",
],
)
# We have to manually create the bind library from it.
fuchsia_fidl_bind_library(
name = "fuchsia.gizmo.protocol_bindlib",
library = ":fuchsia.gizmo.protocol",
)
# We have to manually create the C++ lib for the FIDL based bind library we created.
fuchsia_bind_cc_library(
name = "fuchsia.gizmo.protocol_bindlib_cc",
library = ":fuchsia.gizmo.protocol_bindlib",
)
#[END fuchsia_gizmo_protocol]
cc_binary(
name = "child_driver",
srcs = [
"child-driver.cc",
"child-driver.h",
],
linkshared = True,
deps = [
":fuchsia.gizmo.protocol_cc",
"@fuchsia_sdk//pkg/driver2-llcpp",
"@fuchsia_sdk//pkg/sys_component_llcpp",
],
)
#[START bind_rules]
fuchsia_driver_bytecode_bind_rules(
name = "child_bind_bytecode",
output = "child-driver.bindbc",
rules = "child-driver.bind",
deps = [
# This bind library is one we created manually.
":fuchsia.gizmo.library",
# This bind library is from a FIDL library that we created manually.
":fuchsia.gizmo.protocol_bindlib",
# This bind library is from an SDK FIDL library.
"@fuchsia_sdk//fidl/fuchsia.device.fs:fuchsia.device.fs_bindlib",
],
)
#[END bind_rules]
fuchsia_component_manifest(
name = "child_manifest",
src = "meta/child-driver.cml",
includes = [
"@fuchsia_sdk//pkg/syslog:client",
],
)
fuchsia_driver_component(
name = "child_component",
bind_bytecode = ":child_bind_bytecode",
driver_lib = ":child_driver",
manifest = ":child_manifest",
)
fuchsia_package(
name = "child_pkg",
package_name = "child_pkg",
visibility = ["//visibility:public"],
deps = [
":child_component",
],
)
#[START parent_driver]
cc_binary(
name = "parent_driver",
srcs = [
"parent-driver.cc",
"parent-driver.h",
],
linkshared = True,
deps = [
# This is a C++ lib from our manually created bind library.
":fuchsia.gizmo.library_cc",
# This is a C++ lib from our manually created FIDL based bind library.
":fuchsia.gizmo.protocol_bindlib_cc",
":fuchsia.gizmo.protocol_cc",
# This is a C++ lib from an SDK FIDL based bind library.
"@fuchsia_sdk//fidl/fuchsia.device.fs:fuchsia.device.fs_bindlib_cc",
"@fuchsia_sdk//pkg/driver2-llcpp",
"@fuchsia_sdk//pkg/sys_component_llcpp",
],
)
#[END parent_driver]
fuchsia_driver_bytecode_bind_rules(
name = "parent_bind_bytecode",
output = "parent-driver.bindbc",
rules = "parent-driver.bind",
deps = [
"@fuchsia_sdk//bind/fuchsia.acpi",
],
)
fuchsia_component_manifest(
name = "parent_manifest",
src = "meta/parent-driver.cml",
includes = [
"@fuchsia_sdk//pkg/syslog:client",
],
)
fuchsia_driver_component(
name = "parent_component",
bind_bytecode = ":parent_bind_bytecode",
driver_lib = ":parent_driver",
manifest = ":parent_manifest",
)
fuchsia_package(
name = "parent_pkg",
package_name = "parent_pkg",
visibility = ["//visibility:public"],
deps = [
":parent_component",
],
)