File: BUILD.gn

package info (click to toggle)
android-platform-tools 34.0.5-12
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 150,900 kB
  • sloc: cpp: 805,786; java: 293,500; ansic: 128,288; xml: 127,491; python: 41,481; sh: 14,245; javascript: 9,665; cs: 3,846; asm: 2,049; makefile: 1,917; yacc: 440; awk: 368; ruby: 183; sql: 140; perl: 88; lex: 67
file content (221 lines) | stat: -rw-r--r-- 5,894 bytes parent folder | download | duplicates (11)
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
# Copyright 2018 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.

template("gcc_toolchain") {
  toolchain(target_name) {
    assert(defined(invoker.ar), "Caller must define ar command.")
    assert(defined(invoker.cc), "Caller must define cc command.")
    assert(defined(invoker.cxx), "Caller must define cxx command.")
    assert(defined(invoker.ld), "Caller must define ld command.")
    forward_variables_from(invoker,
                           [
                             "ar",
                             "cc",
                             "cxx",
                             "ld",
                           ])

    toolchain_args = {
      forward_variables_from(invoker.toolchain_args, "*")

      # The host toolchain needs to be preserved by all secondary toolchains.
      # For futher explanation, see
      # https://gn.googlesource.com/gn/+/refs/heads/master/docs/reference.md#toolchain-overview
      host_toolchain = host_toolchain
    }

    lib_switch = "-l"
    lib_dir_switch = "-L"

    object_prefix = "{{source_out_dir}}/{{label_name}}."

    tool("cc") {
      depfile = "{{output}}.d"
      command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_c}} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "CC {{output}}"
      outputs = [
        "$object_prefix{{source_name_part}}.o",
      ]
    }

    tool("cxx") {
      depfile = "{{output}}.d"
      command = "$cxx -MMD -MF $depfile {{defines}} {{include_dirs}} {{cflags}} {{cflags_cc}} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "CXX {{output}}"
      outputs = [
        "$object_prefix{{source_name_part}}.o",
      ]
    }

    tool("asm") {
      depfile = "{{output}}.d"
      command = "$cc -MMD -MF $depfile {{defines}} {{include_dirs}} {{asmflags}} -c {{source}} -o {{output}}"
      depsformat = "gcc"
      description = "ASM {{output}}"
      outputs = [
        "$object_prefix{{source_name_part}}.o",
      ]
    }

    tool("alink") {
      rspfile = "{{output}}.rsp"
      command = "rm -f {{output}} && $ar rcs {{output}} @$rspfile"
      description = "AR {{target_output_name}}{{output_extension}}"
      rspfile_content = "{{inputs}}"
      outputs = [
        "{{output_dir}}/{{target_output_name}}{{output_extension}}",
      ]
      default_output_dir = "{{target_out_dir}}"
      default_output_extension = ".a"
      output_prefix = "lib"
    }

    tool("solink") {
      soname = "{{target_output_name}}{{output_extension}}"  # e.g. "libfoo.so".
      sofile = "{{output_dir}}/$soname"
      rspfile = soname + ".rsp"

      command =
          "$ld -shared {{ldflags}} -o $sofile -Wl,-soname=$soname @$rspfile"
      rspfile_content = "-Wl,--whole-archive {{inputs}} {{solibs}} -Wl,--no-whole-archive {{libs}}"

      description = "SOLINK {{output}}"

      # Use this for {{output_extension}} expansions unless a target manually
      # overrides it (in which case {{output_extension}} will be what the target
      # specifies).
      default_output_extension = ".so"

      # Use this for {{output_dir}} expansions unless a target manually overrides
      # it (in which case {{output_dir}} will be what the target specifies).
      default_output_dir = "{{root_out_dir}}"

      outputs = [
        sofile,
      ]
      link_output = sofile
      depend_output = sofile
      output_prefix = "lib"
    }

    tool("link") {
      outfile = "{{output_dir}}/{{target_output_name}}{{output_extension}}"
      rspfile = "$outfile.rsp"

      # These extra ldflags allow an executable to search for shared libraries in
      # the current working directory.
      additional_executable_ldflags = "-Wl,-rpath=\$ORIGIN/ -Wl,-rpath-link="
      command = "$ld {{ldflags}} $additional_executable_ldflags -o $outfile -Wl,--start-group @$rspfile {{solibs}} -Wl,--end-group {{libs}}"
      description = "LINK $outfile"
      default_output_dir = "{{root_out_dir}}"
      rspfile_content = "{{inputs}}"
      outputs = [
        outfile,
      ]
    }

    tool("stamp") {
      command = "touch {{output}}"
      description = "STAMP {{output}}"
    }

    tool("copy") {
      command = "ln -f {{source}} {{output}} 2>/dev/null || (rm -rf {{output}} && cp -af {{source}} {{output}})"
      description = "COPY {{source}} {{output}}"
    }
  }
}

template("clang_toolchain") {
  prefix = rebase_path("$clang_base_path/bin", root_build_dir)

  gcc_toolchain(target_name) {
    ar = "$prefix/llvm-ar"
    cc = "$prefix/clang"
    cxx = "$prefix/clang++"
    ld = cxx
    toolchain_args = {
      forward_variables_from(invoker.toolchain_args, "*")
      is_clang = true
    }
  }
}

clang_toolchain("clang_x64") {
  toolchain_args = {
    current_cpu = "x64"
    current_os = "linux"
  }
}

clang_toolchain("clang_x86") {
  toolchain_args = {
    current_cpu = "x86"
    current_os = "linux"
  }
}

clang_toolchain("clang_arm") {
  toolchain_args = {
    current_cpu = "arm"
    current_os = "linux"
  }
}

clang_toolchain("clang_arm64") {
  toolchain_args = {
    current_cpu = "arm64"
    current_os = "linux"
  }
}

gcc_toolchain("gcc_x64") {
  ar = "ar"
  cc = "gcc"
  cxx = "g++"
  ld = cxx
  toolchain_args = {
    current_cpu = "x64"
    current_os = "linux"
    is_gcc = true
  }
}

gcc_toolchain("gcc_x86") {
  ar = "ar"
  cc = "gcc"
  cxx = "g++"
  ld = cxx
  toolchain_args = {
    current_cpu = "x86"
    current_os = "linux"
    is_gcc = true
  }
}

gcc_toolchain("gcc_arm") {
  ar = "ar"
  cc = "gcc"
  cxx = "g++"
  ld = cxx
  toolchain_args = {
    current_cpu = "arm"
    current_os = "linux"
    is_gcc = true
  }
}

gcc_toolchain("gcc_arm64") {
  ar = "ar"
  cc = "gcc"
  cxx = "g++"
  ld = cxx
  toolchain_args = {
    current_cpu = "arm64"
    current_os = "linux"
    is_gcc = true
  }
}