• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2024 The Pigweed Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License"); you may not
4# use this file except in compliance with the License. You may obtain a copy of
5# the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12# License for the specific language governing permissions and limitations under
13# the License.
14
15import("//build_overrides/pigweed.gni")
16
17import("$dir_pw_build/gn_internal/build_target.gni")
18
19# Note: In general, prefer to import target_types.gni rather than this file.
20#
21# This template wraps a configurable target type specified by the current
22# toolchain to be used for all pw_rust_bindgen targets. It wraps a creation of
23# an action target `rust_bindgen_action.gni`.
24#
25# Args:
26#  cflags: C flags passed to bindgen.
27#
28#  cflags_c: Suppliment C flags. Useful for override toolchain C flags.
29#
30#  configs: Configs specify sets of compiler flags, includes, defines, etc
31#
32#  deps: Dependencies for this target.
33#
34#  header: C header file for generating bindings.
35#
36#  libclang_path: Optional. Path to directory of libclang.so for bindgen to use.
37#     By default bindgen dynamically links to system wide libclang.
38#
39#  public_deps: Public dependencies for this target. In addition to outputs from
40#    this target, outputs generated by public dependencies can be used as inputs
41#    from targets that depend on this one. This is not the case for private
42#    deps.
43#
44#  public_configs: Configs to be applied on dependents.
45#
46#  outputs: Output path of the generated rust bindings source file.
47#
48#  visibility: GN visibility to apply to the underlying target.
49#
50# For more information on the features provided by this template, see the full
51# docs at https://pigweed.dev/pw_build/?highlight=pw_rust_bindgen
52
53_action_gni_path = get_path_info("rust_bindgen_action.gni", "abspath")
54
55template("pw_rust_bindgen") {
56  pw_internal_build_target(target_name) {
57    forward_variables_from(invoker, "*")
58
59    target_type_file = _action_gni_path
60    underlying_target_type = "rust_bindgen_action"
61    add_global_link_deps = false
62  }
63}
64