File: rust_executable.gni

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (76 lines) | stat: -rw-r--r-- 2,589 bytes parent folder | download | duplicates (10)
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
65
66
67
68
69
70
71
72
73
74
75
76
# Copyright 2021 The Chromium Authors
# 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'
#
#   inputs (optional)
#     Additional input files needed for compilation (such as `include!`ed files)
#
#   test_inputs (optional)
#     Same as above but for the unit tests target
#
# 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") {
  rust_target(target_name) {
    forward_variables_from(invoker,
                           "*",
                           TESTONLY_AND_VISIBILITY + [ "configs" ])
    forward_variables_from(invoker, TESTONLY_AND_VISIBILITY)
    executable_configs = invoker.configs
    target_type = "executable"
    assert(!defined(cxx_bindings))

    # Executable targets should be unique names as they all get placed in the
    # root output dir. We want their exe file name to be the same as the GN
    # target, not a mangled name including the full GN path, and the exe file
    # name comes from the crate name.
    if (!defined(invoker.crate_name)) {
      crate_name = target_name
    }
  }
}

set_defaults("rust_executable") {
  configs = default_executable_configs
}