1# Introduction 2 3This page is about how to design a project that can build independently 4with GN but also be brought into the Chrome build. 5 6GN is in principle no different than GYP in that there is some core 7configuration that must be the same between both the standalone build 8and the Chrome build. However, GN is much more explicit in its naming 9and configuration, so the similarities between the two builds are also 10much more explicit and there is less flexibility in how things are 11configured. 12 13# What you need for a minimal GN build 14 15Requirements: 16 17 * A master build config file. Chrome's is `//build/config/BUILDCONFIG.gn` 18 * A separate build file for the toolchain definition. It's not a good idea 19 to put these in a BUILD.gn file shared with any target definitions for 20 complex reasons. Chrome's are in `//build/toolchain/<platform>/BUILD.gn`. 21 * A `BUILD.gn` file in the root directory. This will be loaded after the 22 build config file to start the build. 23 24You may want a `.gn` file in the root directory. When you run GN it 25recursively looks up the directory tree until it finds this file, and it 26treats the containing directory as the "source root". This file also 27defines the location of the master build config file: 28 29 * See Chrome's `src/.gn` file. 30 * Unlike Chrome, you probably don't need to define a secondary root. 31 * see `gn help dotfile` for more. 32 33Adding a `.gn` file in a repository that is pulled into Chrome means 34that then running GN in your subdirectory will configure a build for 35your subproject rather than for all of Chrome. This could be an 36advantage or a disadvantage. 37 38If you are in a directory with such a file and you want to not use it 39(e.g., to do the full Chrome build instead), you can use the command-line 40flags `--root` and `--dotfile` to set the values you want. 41 42If you want a completely standalone build that has nothing to do with Chrome 43and doesn't use Chrome's `//build` files, you can look at an example in 44[//tools/gn/example](../tools/gn/example). 45