1GN(1)                            User Commands                           GN(1)
2
3
4

NAME

6       gn - Documentation for GN
7

DESCRIPTION

9   Commands (type  gn help <command>" for more help):"
10       analyze:
11               Analyze which targets are affected by a list of files.
12
13       args:
14               Display or configure arguments declared by the build.
15
16       check:
17               Check header dependencies.
18
19       clean:
20               Cleans the output directory.
21
22       clean_stale:
23               Cleans the stale output files from the output directory.
24
25       desc:
26               Show lots of insightful information about a target or config.
27
28       format:
29               Format .gn files.
30
31       gen:
32               Generate ninja files.
33
34       help:
35               Does what you think.
36
37       ls:
38               List matching targets.
39
40       meta:
41               List target metadata collection results.
42
43       outputs:
44               Which files a source/target make.
45
46       path:
47               Find paths between two targets.
48
49       refs:
50               Find stuff referencing a target or file.
51
52   Target declarations (type  gn help <function>" for more help):"
53       action:
54               Declare a target that runs a script a single time.
55
56       action_foreach:
57               Declare a target that runs a script over a set of files.
58
59       bundle_data:
60               [iOS/macOS] Declare a target without output.
61
62       copy:
63               Declare a target that copies files.
64
65       create_bundle:
66               [iOS/macOS] Build an iOS or macOS bundle.
67
68       executable:
69               Declare an executable target.
70
71       generated_file:
72               Declare a generated_file target.
73
74       group:
75               Declare a named group of targets.
76
77       loadable_module:
78               Declare a loadable module target.
79
80       rust_library:
81               Declare a Rust library target.
82
83       rust_proc_macro:
84               Declare a Rust procedural macro target.
85
86       shared_library:
87               Declare a shared library target.
88
89       source_set:
90               Declare a source set target.
91
92       static_library:
93               Declare a static library target.
94
95       target:
96               Declare a target with the given programmatic type.
97
98   Buildfile functions (type  gn help <function>" for more help):"
99       assert:
100               Assert an expression is true at generation time.
101
102       config:
103               Defines a configuration object.
104
105       declare_args:
106               Declare build arguments.
107
108       defined:
109               Returns whether an identifier is defined.
110
111       exec_script:
112               Synchronously run a script and return the output.
113
114       filter_exclude:
115               Remove values that match a set of patterns.
116
117       filter_include:
118               Remove values that do not match a set of patterns.
119
120       foreach:
121               Iterate over a list.
122
123       forward_variables_from:
124               Copies variables from a different scope.
125
126       get_label_info:
127               Get an attribute from a target's label.
128
129       get_path_info:
130               Extract parts of a file or directory name.
131
132       get_target_outputs:
133               [file list] Get the list of outputs from a target.
134
135       getenv:
136               Get an environment variable.
137
138       import:
139               Import a file into the current scope.
140
141       not_needed:
142               Mark variables from scope as not needed.
143
144       pool:
145               Defines a pool object.
146
147       print:
148               Prints to the console.
149
150       print_stack_trace:
151               Prints a stack trace.
152
153       process_file_template:
154               Do template expansion over a list of files.
155
156       read_file:
157               Read a file into a variable.
158
159       rebase_path:
160               Rebase a file or directory to another location.
161
162       set_default_toolchain:
163               Sets the default toolchain name.
164
165       set_defaults:
166               Set default values for a target type.
167
168       split_list:
169               Splits a list into N different sub-lists.
170
171       string_join:
172               Concatenates a list of strings with a separator.
173
174       string_replace:
175               Replaces substring in the given string.
176
177       string_split:
178               Split string into a list of strings.
179
180       template:
181               Define a template rule.
182
183       tool:
184               Specify arguments to a toolchain tool.
185
186       toolchain:
187               Defines a toolchain.
188
189       write_file:
190               Write a file to disk.
191
192   Built-in predefined variables (type  gn help <variable>" for more help):"
193       current_cpu:
194               [string] The processor architecture of the current toolchain.
195
196       current_os:
197               [string] The operating system of the current toolchain.
198
199       current_toolchain:
200               [string] Label of the current toolchain.
201
202       default_toolchain:
203               [string] Label of the default toolchain.
204
205       gn_version:
206               [number] The version of gn.
207
208       host_cpu:
209               [string] The processor architecture that GN is running on.
210
211       host_os:
212               [string] The operating system that GN is running on.
213
214       invoker:
215               [string] The invoking scope inside a template.
216
217       python_path:
218               [string] Absolute path of Python.
219
220       root_build_dir:
221               [string] Directory where build commands are run.
222
223       root_gen_dir:
224               [string] Directory for the toolchain's generated files.
225
226       root_out_dir:
227               [string] Root directory for toolchain output files.
228
229       target_cpu:
230               [string] The desired cpu architecture for the build.
231
232       target_gen_dir:
233               [string] Directory for a target's generated files.
234
235       target_name:
236               [string] The name of the current target.
237
238       target_os:
239               [string] The desired operating system for the build.
240
241       target_out_dir:
242               [string] Directory for target output files.
243
244   Variables you set in targets (type  gn help <variable>" for more help):"
245       aliased_deps:
246               [scope] Set of crate-dependency pairs.
247
248       all_dependent_configs:
249               [label list] Configs to be forced on dependents.
250
251       allow_circular_includes_from:
252               [label list] Permit includes from deps.
253
254       arflags:
255               [string list] Arguments passed to static_library archiver.
256
257       args:
258               [string list] Arguments passed to an action.
259
260       asmflags:
261               [string list] Flags passed to the assembler.
262
263       assert_no_deps:
264               [label pattern list] Ensure no deps on these targets.
265
266       bridge_header:
267               [string] Path to C/Objective-C compatibility header.
268
269       bundle_contents_dir:
270               Expansion of {{bundle_contents_dir}} in create_bundle.
271
272       bundle_deps_filter:
273               [label list] A list of labels that are filtered out.
274
275       bundle_executable_dir:
276               Expansion of {{bundle_executable_dir}} in create_bundle
277
278       bundle_resources_dir:
279               Expansion of {{bundle_resources_dir}} in create_bundle.
280
281       bundle_root_dir:
282               Expansion of {{bundle_root_dir}} in create_bundle.
283
284       cflags:
285               [string list] Flags passed to all C compiler variants.
286
287       cflags_c:
288               [string list] Flags passed to the C compiler.
289
290       cflags_cc:
291               [string list] Flags passed to the C++ compiler.
292
293       cflags_objc:
294               [string list] Flags passed to the Objective C compiler.
295
296       cflags_objcc:
297               [string list] Flags passed to the Objective C++ compiler.
298
299       check_includes:
300               [boolean] Controls whether a target's files are checked.
301
302       code_signing_args:
303               [string list] Arguments passed to code signing script.
304
305       code_signing_outputs:
306               [file list] Output files for code signing step.
307
308       code_signing_script:
309               [file name] Script for code signing.
310
311       code_signing_sources:
312               [file list] Sources for code signing step.
313
314       complete_static_lib:
315               [boolean] Links all deps into a static library.
316
317       configs:
318               [label list] Configs applying to this target or config.
319
320       contents:
321               Contents to write to file.
322
323       crate_name:
324               [string] The name for the compiled crate.
325
326       crate_root:
327               [string] The root source file for a binary or library.
328
329       crate_type:
330               [string] The type of linkage to use on a shared_library.
331
332       data:
333               [file list] Runtime data file dependencies.
334
335       data_deps:
336               [label list] Non-linked dependencies.
337
338       data_keys:
339               [string list] Keys from which to collect metadata.
340
341       defines:
342               [string list] C preprocessor defines.
343
344       depfile:
345               [string] File name for input dependencies for actions.
346
347       deps:
348               [label list] Private linked dependencies.
349
350       externs:
351               [scope] Set of Rust crate-dependency pairs.
352
353       framework_dirs:
354               [directory list] Additional framework search directories.
355
356       frameworks:
357               [name list] Name of frameworks that must be linked.
358
359       friend:
360               [label pattern list] Allow targets to include private headers.
361
362       gen_deps:
363               [label  list]  Declares  targets that should generate when this
364              one does.
365
366       include_dirs:
367               [directory list] Additional include directories.
368
369       inputs:
370               [file list] Additional compile-time dependencies.
371
372       ldflags:
373               [string list] Flags passed to the linker.
374
375       lib_dirs:
376               [directory list] Additional library directories.
377
378       libs:
379               [string list] Additional libraries to link.
380
381       metadata:
382               [scope] Metadata of this target.
383
384       mnemonic:
385               [string] Prefix displayed when ninja runs this action.
386
387       module_name:
388               [string] The name for the compiled module.
389
390       output_conversion:
391               Data format for generated_file targets.
392
393       output_dir:
394               [directory] Directory to put output file in.
395
396       output_extension:
397               [string] Value to use for the output's file extension.
398
399       output_name:
400               [string] Name for the output file other than the default.
401
402       output_prefix_override:
403               [boolean] Don't use prefix for output name.
404
405       outputs:
406               [file list] Output files for actions and copy targets.
407
408       partial_info_plist:
409               [filename] Path plist from asset catalog compiler.
410
411       pool:
412               [string] Label of the pool used by binary targets and actions.
413
414       precompiled_header:
415               [string] Header file to precompile.
416
417       precompiled_header_type:
418               [string] "gcc" or "msvc".
419
420       precompiled_source:
421               [file name] Source file to precompile.
422
423       product_type:
424               [string] Product type for the bundle.
425
426       public:
427               [file list] Declare public header files for a target.
428
429       public_configs:
430               [label list] Configs applied to dependents.
431
432       public_deps:
433               [label list] Declare public dependencies.
434
435       rebase:
436               [boolean] Rebase collected metadata as files.
437
438       response_file_contents:
439               [string list] Contents of .rsp file for actions.
440
441       script:
442               [file name] Script file for actions.
443
444       sources:
445               [file list] Source files for a target.
446
447       swiftflags:
448               [string list] Flags passed to the swift compiler.
449
450       testonly:
451               [boolean] Declares a target must only be used for testing.
452
453       transparent:
454               [bool] True if the bundle is transparent.
455
456       visibility:
457               [label list] A list of labels that can depend on a target.
458
459       walk_keys:
460               [string list] Key(s) for managing the metadata collection walk.
461
462       weak_frameworks:
463               [name list] Name of frameworks that must be weak linked.
464
465       write_runtime_deps:
466               Writes the target's runtime_deps to the given path.
467
468       xcasset_compiler_flags:
469               [string list] Flags passed to xcassets compiler
470
471       xcode_extra_attributes:
472               [scope] Extra attributes for Xcode projects.
473
474       xcode_test_application_name:
475               [string] Name for Xcode test target.
476
477   Other help topics:
478       all:
479               Print all the help at once
480
481       buildargs:
482               How build arguments work.
483
484       dotfile:
485               Info about the toplevel .gn file.
486
487       execution:
488               Build graph and execution overview.
489
490       grammar:
491               Language and grammar for GN build files.
492
493       input_conversion:
494               Processing input from exec_script and read_file.
495
496       file_pattern:
497               Matching more than one file.
498
499       label_pattern:
500               Matching more than one label.
501
502       labels:
503               About labels.
504
505       metadata_collection:
506               About metadata and its collection.
507
508       ninja_rules:
509               How Ninja build rules are named.
510
511       nogncheck:
512               Annotating includes for checking.
513
514       output_conversion:
515               Specifies how to transform a value to output.
516
517       runtime_deps:
518               How runtime dependency computation works.
519
520       source_expansion:
521               Map sources to outputs for scripts.
522
523       switches:
524               Show available command-line switches.
525
526
527
528gn 2125 (85bd0a62938b)           November 2023                           GN(1)
Impressum