| # 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. |
| |
| # Generates two `source_set` definitions, for use with and without the driver framework. |
| # |
| # This template allows us to have a different source_set definition for targets that will become a |
| # driver and targets that will not. Notably, network-device libraries' tests and the network-tun |
| # component use the source_set without the driver symbols. |
| # |
| # The driver target will have driver libraries added to its public deps and `NETDEV_DRIVER` to its |
| # defines. The non-driver target will have the syslog library added to its public deps. Both targets |
| # have the `_ALL_SOURCE` define added. |
| # |
| # Parameters |
| # - sources and public_deps work as expected. |
| template("driver_source_split") { |
| source_set(target_name + "_driver") { |
| defines = [ "_ALL_SOURCE" ] |
| forward_variables_from(invoker, |
| [ |
| "sources", |
| "public_deps", |
| "public_configs", |
| "testonly", |
| ]) |
| if (defined(invoker.configs)) { |
| configs += invoker.configs |
| } |
| defines += [ "NETDEV_DRIVER" ] |
| public_deps += [ "//sdk/lib/driver/logging/cpp" ] |
| if (defined(invoker.driver_deps)) { |
| public_deps += invoker.driver_deps |
| } |
| } |
| |
| source_set(target_name) { |
| defines = [ "_ALL_SOURCE" ] |
| forward_variables_from(invoker, |
| [ |
| "sources", |
| "public_deps", |
| "public_configs", |
| "testonly", |
| ]) |
| if (defined(invoker.configs)) { |
| configs += invoker.configs |
| } |
| public_deps += [ |
| "//sdk/lib/driver/logging/cpp", |
| "//sdk/lib/syslog/cpp", |
| ] |
| if (defined(invoker.non_driver_deps)) { |
| public_deps += invoker.non_driver_deps |
| } |
| } |
| } |