{"id":18496077,"url":"https://github.com/jiauzhang/gn","last_synced_at":"2025-10-09T05:34:29.530Z","repository":{"id":135510265,"uuid":"563822950","full_name":"JiauZhang/gn","owner":"JiauZhang","description":"GN is a meta-build system that generates build files for Ninja.","archived":false,"fork":false,"pushed_at":"2025-04-28T12:21:32.000Z","size":27573,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-28T13:41:11.946Z","etag":null,"topics":["c-plus-plus","chrome","electron","ninja","v8"],"latest_commit_sha":null,"homepage":"https://gn.googlesource.com/gn","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JiauZhang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS","dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-11-09T12:14:45.000Z","updated_at":"2025-04-28T12:21:36.000Z","dependencies_parsed_at":"2023-10-15T21:10:35.106Z","dependency_job_id":"ee5a819f-f1e1-4edb-9c10-318b92230a49","html_url":"https://github.com/JiauZhang/gn","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/JiauZhang/gn","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiauZhang%2Fgn","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiauZhang%2Fgn/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiauZhang%2Fgn/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiauZhang%2Fgn/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JiauZhang","download_url":"https://codeload.github.com/JiauZhang/gn/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JiauZhang%2Fgn/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000741,"owners_count":26082932,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c-plus-plus","chrome","electron","ninja","v8"],"created_at":"2024-11-06T13:27:43.497Z","updated_at":"2025-10-09T05:34:29.503Z","avatar_url":"https://github.com/JiauZhang.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GN\n\nGN is a meta-build system that generates build files for\n[Ninja](https://ninja-build.org).\n\nRelated resources:\n\n  * Documentation in [docs/](https://gn.googlesource.com/gn/+/main/docs/). In\n    particular:\n    *  [GN quick start guide](https://gn.googlesource.com/gn/+/main/docs/quick_start.md).\n    *  [Frequently asked questions](https://gn.googlesource.com/gn/+/main/docs/faq.md)\n    *  [Reference](https://gn.googlesource.com/gn/+/main/docs/reference.md)\n       (all builtin help converted to a single file).\n  * An introductory [presentation](https://docs.google.com/presentation/d/15Zwb53JcncHfEwHpnG_PoIbbzQ3GQi_cpujYwbpcbZo/edit?usp=sharing).\n  * The [mailing list](https://groups.google.com/a/chromium.org/forum/#!forum/gn-dev).\n  * The [bug database](https://gn.issues.chromium.org/issues?q=status:open).\n\n## What GN is for\n\nGN is currently used as the build system for Chromium, Fuchsia, and related\nprojects. Some strengths of GN are:\n\n  * It is designed for large projects and large teams. It scales efficiently to\n    many thousands of build files and tens of thousands of source files.\n\n  * It has a readable, clean syntax. Once a build is set-up, it is generally\n    easy for people with no backround in GN to make basic edits to the build.\n\n  * It is designed for multi-platform projects. It can cleanly express many\n    complicated build variants across different platforms. A single build\n    invocation can target multiple platforms.\n\n  * It supports multiple parallel output directories, each with their own\n    configuration. This allows a developer to maintain builds targeting debug,\n    release, or different platforms in parallel without forced rebuilds when\n    switching.\n\n  * It has a focus on correctness. GN checks for the correct dependencies,\n    inputs, and outputs to the extent possible, and has a number of tools to\n    allow developers to ensure the build evolves as desired (for example, `gn\n    check`, `testonly`, `assert_no_deps`).\n\n  * It has comprehensive build-in help available from the command-line.\n\nAlthough small projects successfully use GN, the focus on large projects has\nsome disadvanages:\n\n  * GN has the goal of being minimally expressive. Although it can be quite\n    flexible, a design goal is to direct members of a large team (who may not\n    have much knowledge about the build) down an easy-to-understand, well-lit\n    path. This isn't necessarily the correct trade-off for smaller projects.\n\n  * The minimal build configuration is relatively heavyweight. There are several\n    files required and the exact way all compilers and linkers are run must be\n    specified in the configuration (see \"Examples\" below). There is no default\n    compiler configuration.\n\n  * It is not easily composable. GN is designed to compile a single large\n    project with relatively uniform settings and rules. Projects like Chromium\n    do bring together multiple repositories from multiple teams, but the\n    projects must agree on some conventions in the build files to allow this to\n    work.\n\n  * GN is designed with the expectation that the developers building a project\n    want to compile an identical configuration. So while builds can integrate\n    with the user's environment like the CXX and CFLAGS variables if they want,\n    this is not the default and most project's builds do not do this. The result\n    is that many GN projects do not integrate well with other systems like\n    ebuild.\n\n  * There is no simple release scheme (see \"Versioning and distribution\" below).\n    Projects are expected to manage the version of GN they require. Getting an\n    appropriate GN binary can be a hurdle for new contributors to a project.\n    Since GN is relatively uncommon, it can be more difficult to find\n    information and examples.\n\nGN can generate Ninja build files for C, C++, Rust, Objective C, and Swift\nsource on most popular platforms. Other languages can be compiled using the\ngeneral \"action\" rules which are executed by Python or another scripting\nlanguage (Google does this to compile Java and Go). But because this is not as\nclean, generally GN is only used when the bulk of the build is in one of the\nmain built-in languages.\n\n## Getting a binary\n\nYou can download the latest version of GN binary for\n[Linux](https://chrome-infra-packages.appspot.com/dl/gn/gn/linux-amd64/+/latest),\n[macOS](https://chrome-infra-packages.appspot.com/dl/gn/gn/mac-amd64/+/latest) and\n[Windows](https://chrome-infra-packages.appspot.com/dl/gn/gn/windows-amd64/+/latest)\nfrom Google's build infrastructure (see \"Versioning and distribution\" below for\nhow this is expected to work).\n\nAlternatively, you can build GN from source with a C++17 compiler:\n\n    git clone https://gn.googlesource.com/gn\n    cd gn\n    python build/gen.py # --allow-warning if you want to build with warnings.\n    ninja -C out\n    # To run tests:\n    out/gn_unittests\n\nOn Windows, it is expected that `cl.exe`, `link.exe`, and `lib.exe` can be found\nin `PATH`, so you'll want to run from a Visual Studio command prompt, or\nsimilar.\n\nOn Linux, Mac and z/OS, the default compiler is `clang++`, a recent version is\nexpected to be found in `PATH`. This can be overridden by setting the `CC`, `CXX`,\nand `AR` environment variables.\n\nOn MSYS and MinGW, the default compiler is `g++`, a recent version is\nexpected to be found in `PATH`. This can be overridden by setting the `CC`, `CXX`,\n`LD` and `AR` environment variables.\n\nOn z/OS, building GN requires [ZOSLIB](https://github.com/ibmruntimes/zoslib) to be\ninstalled, as described at that URL. When building with `build/gen.py`, use the option\n`--zoslib-dir` to specify the path to [ZOSLIB](https://github.com/ibmruntimes/zoslib):\n\n    cd gn\n    python build/gen.py --zoslib-dir /path/to/zoslib\n\nBy default, if you don't specify `--zoslib-dir`, `gn/build/gen.py` expects to find\n`zoslib` directory under `gn/third_party/`.\n\n## Examples\n\nThere is a simple example in [examples/simple_build](examples/simple_build)\ndirectory that is a good place to get started with the minimal configuration.\n\nTo build and run the simple example with the default gcc compiler:\n\n    cd examples/simple_build\n    ../../out/gn gen -C out\n    ninja -C out\n    ./out/hello\n\nFor a maximal configuration see the Chromium setup:\n  * [.gn](https://cs.chromium.org/chromium/src/.gn)\n  * [BUILDCONFIG.gn](https://cs.chromium.org/chromium/src/build/config/BUILDCONFIG.gn)\n  * [Toolchain setup](https://cs.chromium.org/chromium/src/build/toolchain/)\n  * [Compiler setup](https://cs.chromium.org/chromium/src/build/config/compiler/BUILD.gn)\n\nand the Fuchsia setup:\n  * [.gn](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/.gn)\n  * [BUILDCONFIG.gn](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/build/config/BUILDCONFIG.gn)\n  * [Toolchain setup](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/build/toolchain/)\n  * [Compiler setup](https://fuchsia.googlesource.com/fuchsia/+/refs/heads/main/build/config/BUILD.gn)\n\n## Reporting bugs\n\nIf you find a bug, you can see if it is known or report it in the [bug\ndatabase](https://bugs.chromium.org/p/gn/issues/list).\n\n## Sending patches\n\nGN uses [Gerrit](https://www.gerritcodereview.com/) for code review hosted at\n[gn-review.googlesource.com](https://gn-review.googlesource.com/). The short\nversion of how to patch is:\n\n    Register at https://gn-review.googlesource.com.\n\n    ... edit code ...\n    ninja -C out \u0026\u0026 out/gn_unittests\n\nThen, to upload a change for review:\n\n    git commit\n    git push origin HEAD:refs/for/main\n\nThe first time you do this you'll get an error from the server about a missing\nchange-ID. Follow the directions in the error message to install the change-ID\nhook and run `git commit --amend` to apply the hook to the current commit.\n\nWhen revising a change, use:\n\n    git commit --amend\n    git push origin HEAD:refs/for/main\n\nwhich will add the new changes to the existing code review, rather than creating\na new one.\n\nWe ask that all contributors\n[sign Google's Contributor License Agreement](https://cla.developers.google.com/)\n(either individual or corporate as appropriate, select 'any other Google\nproject').\n\n## Community\n\nYou may ask questions and follow along with GN's development on Chromium's\n[gn-dev@](https://groups.google.com/a/chromium.org/forum/#!forum/gn-dev)\nGoogle Group.\n\n## Versioning and distribution\n\nMost open-source projects are designed to use the developer's computer's current\ntoolchain such as compiler, linker, and build tool. But the large\ncentrally controlled projects that GN is designed for typically want a more\nhermetic environment. They will ensure that developers are using a specific\ncompatible toolchain that is versioned with the code.\n\nAs a result, GN expects that the project choose the appropriate version of GN\nthat will work with each version of the project. There is no \"current stable\nversion\" of GN that is expected to work for all projects.\n\nAs a result, the GN developers do not maintain any packages in any of the\nvarious packaging systems (Debian, RedHat, HomeBrew, etc.). Some of these\nsystems to have GN packages, but they are maintained by third parties and you\nshould use them at your own risk. Instead, we recommend you refer your checkout\ntooling to download binaries for a specific hash from [Google's build\ninfrastructure](https://chrome-infra-packages.appspot.com/p/gn/gn) or compile\nyour own.\n\nGN does not guarantee the backwards-compatibility of new versions and has no\nbranches or versioning scheme beyond the sequence of commits to the main git\nbranch (which is expected to be stable).\n\nIn practice, however, GN is very backwards-compatible. The core functionality\nhas been stable for many years and there is enough GN code at Google alone to\nmake non-backwards-compatible changes very difficult, even if they were\ndesirable.\n\nThere have been discussions about adding a versioning scheme with some\nguarantees about backwards-compatibility, but nothing has yet been implemented.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiauzhang%2Fgn","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjiauzhang%2Fgn","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjiauzhang%2Fgn/lists"}