summaryrefslogtreecommitdiff
path: root/chromium/build/rust/rust_executable.gni
blob: ab22c5190cd38acd4ed166c1d63376891a57d4e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# Copyright 2021 The Chromium 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/rust/rust_target.gni")

# Defines a Rust executable.
#
# This is identical to the built-in gn intrinsic 'executable' but
# supports some additional parameters, as below:
#
#   edition (optional)
#     Edition of the Rust language to be used.
#     Options are "2015", "2018" and "2021". Defaults to "2021".
#
#   test_deps (optional)
#     List of GN targets on which this crate's tests depend, in addition
#     to deps.
#
#   build_native_rust_unit_tests (optional)
#     Builds native unit tests (under #[cfg(test)]) written inside the Rust
#     crate. This will create a `<name>_unittests` executable in the output
#     directory when set to true.
#     Chromium code should not set this, and instead prefer to split the code
#     into a library and write gtests against it. See how to do that in
#     //testing/rust_gtest_interop/README.md.
#
#   unit_test_target (optional)
#     Overrides the default name for the unit tests target
#
#   features (optional)
#     A list of conditional compilation flags to enable. This can be used
#     to set features for crates built in-tree which are also published to
#     crates.io. Each feature in the list will be passed to rustc as
#     '--cfg feature=XXX'
#
# Example of usage:
#
#   rust_executable("foo_bar") {
#     deps = [
#       "//boo/public/rust/bar",
#     ]
#     sources = [ "src/main.rs" ]
#   }
#
# This template is intended to serve the same purpose as 'rustc_library'
# in Fuchsia.
template("rust_executable") {
  exclude_forwards = TESTONLY_AND_VISIBILITY + [ "configs" ]
  rust_target(target_name) {
    forward_variables_from(invoker, "*", exclude_forwards)
    forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
    if (defined(invoker.configs)) {
      library_configs = []
      library_configs = invoker.configs
    }
    target_type = "executable"
    assert(!defined(cxx_bindings))
  }
}

set_defaults("rust_executable") {
  configs = default_executable_configs
}