| # Copyright 2018 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/fidl_bind_library.gni") |
| import("//build/dart/toolchain.gni") |
| import("//build/fidl/toolchain.gni") |
| import("//build/go/toolchain.gni") |
| |
| # Declares a FIDL library. |
| # |
| # Depending on the toolchain in which this targets is expanded, it will yield |
| # different results: |
| # - in the FIDL toolchain, it will compile its source files into an |
| # intermediate representation consumable by language bindings generators; |
| # - in the target or shared toolchain, this will produce a source_set |
| # containing C++ bindings. |
| # |
| # Parameters |
| # |
| # sources (required) |
| # List of paths to library source files. |
| # |
| # name (optional) |
| # Name of the library. |
| # Defaults to the target's name. |
| # |
| # sdk_category (optional) |
| # Publication level of the library in SDKs. |
| # See //build/sdk/sdk_atom.gni. |
| # |
| # api (optional) |
| # Path to the file representing the API of this library. |
| # This file is used to ensure modifications to the library's API are |
| # explicitly acknowledged. It is mandatory for publication categories of |
| # "partner" or "public". |
| # Defaults to "<target name>.api". |
| # |
| # excluded_checks (optional) |
| # A list of fidl-lint check IDs to ignore (by passing the command line flag |
| # "-e some-check-id" for each value). |
| # |
| # fuzzers (optional) |
| # Protocol/methods for which to generate LibFuzzer fuzz targets. Example: |
| # [ |
| # { |
| # # Required: |
| # protocol = "fully.qualified.FIDLProtocolName" |
| # # Optional. Default: All methods in protocol. |
| # methods = [ "MethodName1", "MethodName2", ... ] |
| # }, |
| # ... |
| # ] |
| # |
| # golden_fuzzer (optional) |
| # Boolean flag to generate a LibFuzzer fuzz target for all protocols, used |
| # to ensure fuzzers for golden libraries compile successfully. |
| # |
| # experimental_flags (optional) |
| # A list of experimental fidlc features to enable. |
| # |
| # goldens_dir (optional) |
| # The directory containing golden files for this FIDL API, per API level. |
| # Should not contain a trailing slash. This is only used if the API is |
| # publishable in an SDK. |
| # Defaults to //sdk/history. |
| # |
| # non_fidl_deps (optional) |
| # A list of non-FIDL dependency targets, i.e. targets that don't contribute |
| # FIDL artifacts, but should be built before this target regardless. |
| # |
| # should_lint (optional, boolean) |
| # If set to false, the linting step is skipped. |
| # |
| # lenient_api_summary (optional, boolean, default false) |
| # If false, the builder will check the generated FIDL API summary files against |
| # their checked in version. If true, the checks will emit warnings instead |
| # of errors. This switch is used to deploy API summary checks across petals |
| # without breaking global integration. |
| # |
| # dart_analysis (optional, boolean, default false) |
| # If set to true, dart analysis is run on generated Dart bindings. |
| # Dart analysis can take tens of seconds to finish, so running it for all |
| # generated Dart bindings is wasteful. This parameter allows us to only run |
| # analysis on goldens, and skip for other generated bindings. See fxb/82975 |
| # for details. |
| # |
| # contains_drivers (optional, boolean, default false) |
| # Indicates if any of the FIDL files contain the driver transport or |
| # references to the driver transport. |
| |
| template("fidl") { |
| if (defined(invoker.sdk_category)) { |
| not_needed(invoker, [ "sdk_category" ]) |
| } |
| if (defined(invoker.api)) { |
| not_needed(invoker, [ "api" ]) |
| } |
| if (defined(invoker.excluded_checks)) { |
| not_needed(invoker, [ "excluded_checks" ]) |
| } |
| if (defined(invoker.fuzzers)) { |
| not_needed(invoker, [ "fuzzers" ]) |
| } |
| if (defined(invoker.golden_fuzzer)) { |
| not_needed(invoker, [ "golden_fuzzer" ]) |
| } |
| if (defined(invoker.experimental_flags)) { |
| not_needed(invoker, [ "experimental_flags" ]) |
| } |
| if (defined(invoker.goldens_dir)) { |
| not_needed(invoker, [ "goldens_dir" ]) |
| } |
| if (defined(invoker.lenient_api_summary)) { |
| not_needed(invoker, [ "lenient_api_summary" ]) |
| } |
| if (defined(invoker.dart_analysis)) { |
| not_needed(invoker, [ "dart_analysis" ]) |
| } |
| if (defined(invoker.contains_drivers)) { |
| not_needed(invoker, [ "contains_drivers" ]) |
| } |
| if (defined(invoker.should_lint)) { |
| not_needed(invoker, [ "should_lint" ]) |
| } |
| |
| # Allow generated targets visibility to their dependant generated targets |
| if (defined(invoker.visibility)) { |
| invoker.visibility += [ ":*" ] |
| } |
| |
| assert(!defined(invoker.deps), |
| "All FIDL dependencies are inherently " + |
| "public, use 'public_deps' instead of 'deps'.") |
| |
| deps = [] |
| |
| if (defined(invoker.non_fidl_deps)) { |
| deps += invoker.non_fidl_deps |
| } |
| |
| if (current_toolchain == dart_toolchain) { |
| import("//build/dart/fidl_dart.gni") |
| |
| fidl_dart(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } else if (current_toolchain == go_toolchain) { |
| import("//build/go/fidl_go.gni") |
| |
| fidl_go(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } else { |
| if (current_toolchain == fidl_toolchain) { |
| import("//build/fidl/fidl_library.gni") |
| |
| fidl_library(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| } |
| |
| # Define the C++ family of generated bindings |
| import("//build/cpp/fidl_cpp.gni") |
| fidl_cpp_family(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| # Define FIDL coding tables target, used by C and C++ |
| import("//build/c/fidl_c.gni") |
| fidl_tables(target_name) { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| } |
| |
| import("//build/banjo/fidl_banjo.gni") |
| fidl_banjo(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| # TODO(cramertj): remove pending fxbug.dev/26853. |
| import("//build/rust/fidl_rust.gni") |
| fidl_rust(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| fidl_bind_library(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| # Define the C generated bindings |
| if (is_fuchsia) { |
| fidl_c_header(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| fidl_c_client(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| fidl_c_server(target_name) { |
| forward_variables_from(invoker, "*") |
| } |
| |
| group("${target_name}_c") { |
| forward_variables_from(invoker, |
| [ |
| "testonly", |
| "visibility", |
| ]) |
| |
| public_deps = [ |
| ":${target_name}_client", |
| ":${target_name}_header", |
| ":${target_name}_server", |
| ] |
| } |
| } |
| } |
| } |