---
name: "gn"
section: "1"
platform: "linux"
package: "generate-ninja"
version: "0.0~git20221212.5e19d2f-1"
release: "Debian 12 (Bookworm)"
platforms: ["linux"]
url: "https://new.carta.tech/gn"
---

# gn(1)

Meta-build system that generates build files for Ninja

## NAME

gn - Meta-build system that generates build files for Ninja

## DESCRIPTION

### Commands (type gn help \<command\>" for more help):"

-

  analyze: Analyze which targets are affected by a list of files. args: Display or configure arguments declared by the build. check: Check header dependencies. clean: Cleans the output directory. clean\_stale: Cleans the stale output files from the output directory. desc: Show lots of insightful information about a target or config. format: Format .gn files. gen: Generate ninja files. help: Does what you think. ls: List matching targets. meta: List target metadata collection results. outputs: Which files a source/target make. path: Find paths between two targets. refs: Find stuff referencing a target or file.

### Target declarations (type gn help \<function\>" for more help):"

-

  action: Declare a target that runs a script a single time. action\_foreach: Declare a target that runs a script over a set of files. bundle\_data: \[iOS/macOS\] Declare a target without output. copy: Declare a target that copies files. create\_bundle: \[iOS/macOS\] Build an iOS or macOS bundle. executable: Declare an executable target. generated\_file: Declare a generated\_file target. group: Declare a named group of targets. loadable\_module: Declare a loadable module target. rust\_library: Declare a Rust library target. rust\_proc\_macro: Declare a Rust procedural macro target. shared\_library: Declare a shared library target. source\_set: Declare a source set target. static\_library: Declare a static library target. target: Declare a target with the given programmatic type.

### Buildfile functions (type gn help \<function\>" for more help):"

-

  assert: Assert an expression is true at generation time. config: Defines a configuration object. declare\_args: Declare build arguments. defined: Returns whether an identifier is defined. exec\_script: Synchronously run a script and return the output. filter\_exclude: Remove values that match a set of patterns. filter\_include: Remove values that do not match a set of patterns. foreach: Iterate over a list. forward\_variables\_from: Copies variables from a different scope. get\_label\_info: Get an attribute from a target's label. get\_path\_info: Extract parts of a file or directory name. get\_target\_outputs: \[file list\] Get the list of outputs from a target. getenv: Get an environment variable. import: Import a file into the current scope. not\_needed: Mark variables from scope as not needed. pool: Defines a pool object. print: Prints to the console. print\_stack\_trace: Prints a stack trace. process\_file\_template: Do template expansion over a list of files. read\_file: Read a file into a variable. rebase\_path: Rebase a file or directory to another location. set\_default\_toolchain: Sets the default toolchain name. set\_defaults: Set default values for a target type. split\_list: Splits a list into N different sub-lists. string\_join: Concatenates a list of strings with a separator. string\_replace: Replaces substring in the given string. string\_split: Split string into a list of strings. template: Define a template rule. tool: Specify arguments to a toolchain tool. toolchain: Defines a toolchain. write\_file: Write a file to disk.

### Built-in predefined variables (type gn help \<variable\>" for more help):"

-

  current\_cpu: \[string\] The processor architecture of the current toolchain. current\_os: \[string\] The operating system of the current toolchain. current\_toolchain: \[string\] Label of the current toolchain. default\_toolchain: \[string\] Label of the default toolchain. gn\_version: \[number\] The version of gn. host\_cpu: \[string\] The processor architecture that GN is running on. host\_os: \[string\] The operating system that GN is running on. invoker: \[string\] The invoking scope inside a template. python\_path: \[string\] Absolute path of Python. root\_build\_dir: \[string\] Directory where build commands are run. root\_gen\_dir: \[string\] Directory for the toolchain's generated files. root\_out\_dir: \[string\] Root directory for toolchain output files. target\_cpu: \[string\] The desired cpu architecture for the build. target\_gen\_dir: \[string\] Directory for a target's generated files. target\_name: \[string\] The name of the current target. target\_os: \[string\] The desired operating system for the build. target\_out\_dir: \[string\] Directory for target output files.

### Variables you set in targets (type gn help \<variable\>" for more help):"

-

  aliased\_deps: \[scope\] Set of crate-dependency pairs. all\_dependent\_configs: \[label list\] Configs to be forced on dependents. allow\_circular\_includes\_from: \[label list\] Permit includes from deps. arflags: \[string list\] Arguments passed to static\_library archiver. args: \[string list\] Arguments passed to an action. asmflags: \[string list\] Flags passed to the assembler. assert\_no\_deps:??\[label pattern list\] Ensure no deps on these targets. bridge\_header: \[string\] Path to C/Objective-C compatibility header. bundle\_contents\_dir: Expansion of {{bundle\_contents\_dir}} in create\_bundle. bundle\_deps\_filter: \[label list\] A list of labels that are filtered out. bundle\_executable\_dir: Expansion of {{bundle\_executable\_dir}} in create\_bundle bundle\_resources\_dir: Expansion of {{bundle\_resources\_dir}} in create\_bundle. bundle\_root\_dir: Expansion of {{bundle\_root\_dir}} in create\_bundle. cflags: \[string list\] Flags passed to all C compiler variants. cflags\_c: \[string list\] Flags passed to the C compiler. cflags\_cc: \[string list\] Flags passed to the C++ compiler. cflags\_objc: \[string list\] Flags passed to the Objective C compiler. cflags\_objcc: \[string list\] Flags passed to the Objective C++ compiler. check\_includes: \[boolean\] Controls whether a target's files are checked. code\_signing\_args: \[string list\] Arguments passed to code signing script. code\_signing\_outputs: \[file list\] Output files for code signing step. code\_signing\_script: \[file name\] Script for code signing. code\_signing\_sources: \[file list\] Sources for code signing step. complete\_static\_lib: \[boolean\] Links all deps into a static library. configs: \[label list\] Configs applying to this target or config. contents: Contents to write to file. crate\_name: \[string\] The name for the compiled crate. crate\_root: \[string\] The root source file for a binary or library. crate\_type: \[string\] The type of linkage to use on a shared\_library. data: \[file list\] Runtime data file dependencies. data\_deps: \[label list\] Non-linked dependencies. data\_keys: \[string list\] Keys from which to collect metadata. defines: \[string list\] C preprocessor defines. depfile: \[string\] File name for input dependencies for actions. deps: \[label list\] Private linked dependencies. externs: \[scope\] Set of Rust crate-dependency pairs. framework\_dirs: \[directory list\] Additional framework search directories. frameworks: \[name list\] Name of frameworks that must be linked. friend: \[label pattern list\] Allow targets to include private headers. gen\_deps: \[label list\] Declares targets that should generate when this one does. include\_dirs: \[directory list\] Additional include directories. inputs: \[file list\] Additional compile-time dependencies. ldflags: \[string list\] Flags passed to the linker. lib\_dirs: \[directory list\] Additional library directories. libs: \[string list\] Additional libraries to link. metadata: \[scope\] Metadata of this target. module\_name: \[string\] The name for the compiled module. output\_conversion: Data format for generated\_file targets. output\_dir: \[directory\] Directory to put output file in. output\_extension: \[string\] Value to use for the output's file extension. output\_name: \[string\] Name for the output file other than the default. output\_prefix\_override: \[boolean\] Don't use prefix for output name. outputs: \[file list\] Output files for actions and copy targets. partial\_info\_plist: \[filename\] Path plist from asset catalog compiler. pool: \[string\] Label of the pool used by binary targets and actions. precompiled\_header: \[string\] Header file to precompile. precompiled\_header\_type: \[string\] "gcc" or "msvc". precompiled\_source: \[file name\] Source file to precompile. product\_type: \[string\] Product type for Xcode projects. public: \[file list\] Declare public header files for a target. public\_configs: \[label list\] Configs applied to dependents. public\_deps: \[label list\] Declare public dependencies. rebase: \[boolean\] Rebase collected metadata as files. response\_file\_contents: \[string list\] Contents of .rsp file for actions. script: \[file name\] Script file for actions. sources: \[file list\] Source files for a target. swiftflags: \[string list\] Flags passed to the swift compiler. testonly: \[boolean\] Declares a target must only be used for testing. visibility: \[label list\] A list of labels that can depend on a target. walk\_keys: \[string list\] Key(s) for managing the metadata collection walk. weak\_frameworks: \[name list\] Name of frameworks that must be weak linked. write\_runtime\_deps: Writes the target's runtime\_deps to the given path. xcasset\_compiler\_flags: \[string list\] Flags passed to xcassets compiler xcode\_extra\_attributes: \[scope\] Extra attributes for Xcode projects. xcode\_test\_application\_name: \[string\] Name for Xcode test target.

### Other help topics:

-

  all: Print all the help at once buildargs: How build arguments work. dotfile: Info about the toplevel .gn file. execution: Build graph and execution overview. grammar: Language and grammar for GN build files. input\_conversion: Processing input from exec\_script and read\_file. file\_pattern: Matching more than one file. label\_pattern: Matching more than one label. labels: About labels. metadata\_collection: About metadata and its collection. ninja\_rules: How Ninja build rules are named. nogncheck: Annotating includes for checking. output\_conversion: Specifies how to transform a value to output. runtime\_deps: How runtime dependency computation works. source\_expansion: Map sources to outputs for scripts. switches: Show available command-line switches.
