GN(1)
π¦ GN(1) β User Commands, but make it a group chat π¦
okay so this is the gn manual page, filed under User Commands in section 1, and bestie it is long. like, "grab a snack" long. π
the good news? you never have to memorize any of this, because everything on this page has its own little help page. type:
gn help <command>
for commands, gn help <function> for target declarations and buildfile functions, and gn help <variable> for variables. iykyk π
β¨ NAME β¨
gn β Documentation for GN
π DESCRIPTION π
this whole section is literally just the index of everything gn can do, so let's go section by section, no skipping. πΈ
π Commands π
type gn help <command> for more help on any of these, bestie. here's the whole squad:
analyzeβ works out which targets are affected by a list of files. detective mode, no cap πargsβ shows you the arguments your build declares, or configures them for you. yes, you can actually set them from here.checkβ checks your header dependencies.cleanβ cleans the output directory. wipe it. self care β¨clean_staleβ same energy, but it only cleans the stale output files out of the output directory. it's selective, we respect it.descβ shows a whole lot of insightful information about a target or a config. it's giving gossip column but for your build πeditβ editsBUILD.gnfiles straight from the command line.formatβ formats.gnfiles. they were doing their best before, but now they're pretty.genβ generates ninja files. this is the main character moment πhelpβ "does what you think." that's the entire description. no notes, iconic.lsβ lists matching targets.metaβ lists target metadata collection results.outputsβ tells you which files a source or a target make.pathβ finds the paths between two targets. connect the dots π¦refsβ finds stuff that references a target or a file.suggestβ suggests fixes to the build graph based on includes. bestie advice fr fr π«Ά
π§ Target declarations π§
type gn help <function> for more help on any of these. these are the things you use to declare targets:
actionβ declares a target that runs a script a single time. one and done.action_foreachβ declares a target that runs a script over a set of files.bundle_dataβ [iOS/macOS] declares a target without output. yes, a target with no output. it exists, that's the vibe.copyβ declares a target that copies files. exactly what it says πcreate_bundleβ [iOS/macOS] builds an iOS or macOS bundle.executableβ declares an executable target.generated_fileβ declares agenerated_filetarget.groupβ declares a named group of targets.loadable_moduleβ declares a loadable module target.rust_libraryβ declares a Rust library target.rust_proc_macroβ declares a Rust procedural macro target.shared_libraryβ declares a shared library target.source_setβ declares a source set target.static_libraryβ declares a static library target.targetβ declares a target with the given programmatic type. the wildcard one, lowkey powerful.
π Buildfile functions π
type gn help <function> for more help. this is the function section in its full glory:
assertβ asserts that an expression is true at generation time. if it's not true, it's not happening.configβ defines a configuration object.declare_argsβ declares build arguments.definedβ returns whether an identifier is defined.exec_scriptβ synchronously runs a script and returns the output.expand_directoryβ expands a source directory and returns files.filter_excludeβ removes values that match a set of patterns. bye πfilter_includeβ removes values that do not match a set of patterns. keep only the ones that match.filter_labels_excludeβ removes labels that match a set of patterns.filter_labels_includeβ removes labels that do not match a set of patterns.foreachβ iterates over a list.forward_variables_fromβ copies variables from a different scope.get_label_infoβ gets an attribute from a target's label.get_path_infoβ extracts parts of a file or directory name.get_target_outputsβ[file list]gets the list of outputs from a target.getenvβ gets an environment variable.importβ imports a file into the current scope.label_matchesβ returns whether a label matches any of a list of patterns.lenβ returns the length of a string or a list.not_neededβ marks variables from scope as not needed. not me ignoring my problems πpath_existsβ returns whether the given path exists.poolβ defines a pool object.printβ prints to the console.print_stack_traceβ prints a stack trace.process_file_templateβ does template expansion over a list of files.read_fileβ reads a file into a variable.rebase_pathβ rebases a file or directory to another location.set_default_toolchainβ sets the default toolchain name.set_defaultsβ sets default values for a target type.split_listβ splits a list into N different sub-lists.string_hashβ calculates a stable hash of the given string.string_joinβ concatenates a list of strings with a separator.string_replaceβ replaces substring in the given string.string_splitβ splits string into a list of strings.templateβ defines a template rule.toolβ specifies arguments to a toolchain tool.toolchainβ defines a toolchain.write_fileβ writes a file to disk.
β Built-in predefined variables β
type gn help <variable> for more help. these ones come free with the build, no assembly required:
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.generate_modulemapβ[string]mode for generating modulemaps.gn_versionβ[number]the version ofgn. your girl has a number π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. these are the ones you get to write, so go off:
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_bundlebundle_resources_dirβ expansion of{{bundle_resources_dir}}in create_bundle.bundle_root_dirβ expansion of{{bundle_root_dir}}in create_bundle.c_additional_outputsβ[string list]additional outputs for the compiler.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.check_includes_strictβ[boolean]controls whether strict include checking is enforced. strict queen πcollect_validations_metadataβ[bool]collect metadata values from validations deps.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. friendship is a permission system π«Ά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.mnemonicβ[string]prefix displayed when ninja runs this action.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.post_processing_argsβ[string list]args for the post-processing script.
(and that's only part 1, bestie β part 2 is right there, don't move π)
post_processing_manifestβ [file] bestie, this is the name of the generated bundle manifest πpost_processing_outputsβ [file list] the outputs of the post-processing steppost_processing_scriptβ [file name] the script for the post-processing steppost_processing_sourcesβ [file list] the sources for the post-processing stepprecompiled_headerβ [string] header file to precompileprecompiled_header_typeβ [string] literally just"gcc"or"msvc", pick one πprecompiled_sourceβ [file name] source file to precompileproduct_typeβ [string] the product type for the bundlepublicβ [file list] declare public header files for a targetpublic_configsβ [label list] configs applied to dependentspublic_depsβ [label list] declare public dependenciespublic_inputsβ [file list] declare public inputsrebaseβ [boolean] rebase collected metadata as filesresponse_file_contentsβ [string list] contents of.rspfile for actionsrustflagsβ [string list] flags passed to the Rust compiler π¦scriptβ [file name] script file for actionssourcesβ [file list] source files for a targetswiftflagsβ [string list] flags passed to the swift compilertarget_xcode_platformβ [string] the desired platform for the buildtestonlyβ [boolean] declares a target must only be used for testingtransparentβ [bool] true if the bundle is transparentvalidationsβ [label list] validation dependenciesvisibilityβ [label list] a list of labels that can depend on a targetwalk_keysβ [string list] key(s) for managing the metadata collection walkweak_frameworksβ [name list] name of frameworks that must be weak linkedweak_librariesβ [file list] file of libraries that must be weak linkedwrite_runtime_depsβ writes the target'sruntime_depsto the given pathxcasset_compiler_flagsβ [string list] flags passed to xcassets compilerxcode_extra_attributesβ [scope] extra attributes for Xcode projectsxcode_test_application_nameβ [string] name for Xcode test target
π«Ά Other help topics π«Ά
these are the other pages in the GN lore, bestie. run gn help <topic> and go off π
allβ print all the help at once (the whole buffet, no cap)buildargsβ how build arguments workdotfileβ info about the toplevel.gnfileexecutionβ build graph and execution overviewgrammarβ language and grammar for GN build filesinput_conversionβ processing input fromexec_scriptandread_filefile_patternβ matching more than one filelabel_patternβ matching more than one labellabelsβ about labelsmetadata_collectionβ about metadata and its collectionninja_rulesβ how Ninja build rules are namednogncheckβ annotating includes for checkingoutput_conversionβ specifies how to transform a value to outputruntime_depsβ how runtime dependency computation workssource_expansionβ map sources to outputs for scriptsswitchesβ show available command-line switches
and that's a wrap on the whole page, bestie πβ¨ you just read gn 2598 (the build is f90c3d9df882, iconic, no notes π
), dated October 2026. go build something gorgeous ππ¦ fr fr π
π¦ where this page comes from
- epel 10: gn 2598^20261019.f90c3d9df882-1.el10_3 Β· BSD-3-Clause AND ICU AND Unicode-DFS-2016 AND (Apache-2.0 OR MIT)
- fedora 43: gn 2598^20261019.f90c3d9df882-1.fc43 Β· BSD-3-Clause AND ICU AND Unicode-DFS-2016 AND (Apache-2.0 OR MIT)
- fedora 44: gn 2598^20261019.f90c3d9df882-1.fc44 Β· BSD-3-Clause AND ICU AND Unicode-DFS-2016 AND (Apache-2.0 OR MIT)
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms