Skip to content
/ build Public

A standalone GN configuration which supports GCC, Clang, Xcode, and Visual Studio toolchains.

License

Notifications You must be signed in to change notification settings

mmotorny/build

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

How to create a GN-based project

by Maksym Motornyy (mmotorny@gmail.com)

Instructions for Linux

Instructions for macOS

Instructions for Windows

Instructions for Linux

Prerequisites

Ensure that git, python, and apt (optional) are present in $PATH.

Install GN.

cd $(mktemp -d)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone https://chromium.googlesource.com/chromium/buildtools
PATH=$PATH:depot_tools python depot_tools/download_from_google_storage.py \
    --no_resume --platform=linux* --no_auth --bucket chromium-gn \
    -s buildtools/linux64/gn.sha1
sudo cp buildtools/linux64/gn /usr/local/bin
sudo chmod a+x /usr/local/bin/gn

Option 1. Install Ninja.

sudo apt install ninja-build

Option 2. Download Ninja to a directory that is present in $PATH.

Create a project

Create a project directory.

mkdir your_project
cd your_project

Option 1. Clone the GN configuration.

git clone https://github.com/mmotorny/build.git

Option 2. If your project is tracked by Git, add the GN configuration as a submodule.

git submodule add https://github.com/mmotorny/build build

Initialize the source root with templates of .gn and BUILDCONFIG.gn files.

cp build/templates/*.gn .

Optional. Customize BUILDCONFIG.gn.

Now you are ready to write a BUILD.gn file.

Instructions for macOS

Prerequisites

Ensure that git, python, and brew (optional) are present in $PATH.

Install GN.

cd $(mktemp -d)
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone https://chromium.googlesource.com/chromium/buildtools
PATH=$PATH:depot_tools python depot_tools/download_from_google_storage.py \
    --no_resume --platform=darwin --no_auth --bucket chromium-gn \
    -s buildtools/mac/gn.sha1
cp buildtools/mac/gn /usr/local/bin

Option 1. Install Ninja.

brew install ninja

Option 2. Download Ninja to a directory that is present in $PATH.

Create a project

Create a project directory.

mkdir your_project
cd your_project

Option 1. Clone the GN configuration.

git clone https://github.com/mmotorny/build.git

Option 2. If your project is tracked by Git, add the GN configuration as a submodule.

git submodule add https://github.com/mmotorny/build build

Initialize the source root with templates of .gn and BUILDCONFIG.gn files.

cp build/templates/*.gn .

Optional. Customize BUILDCONFIG.gn.

Now you are ready to write a BUILD.gn file.

Instructions for Windows

Prerequisites

Ensure that git, python, and choco (optional) are present in %PATH%.

Download GN.

cd %TEMP%
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
git clone https://chromium.googlesource.com/chromium/buildtools
SET PATH=%PATH%;depot_tools
python depot_tools/download_from_google_storage.py ^
    --no_resume --platform=win32 --no_auth --bucket chromium-gn ^
    -s buildtools\win\gn.exe.sha1

Copy %TEMP%\buildtools\win\gn.exe to a directory that is present in %PATH%.

Option 1. Install Ninja (note that Chocolatey must be run as an administrator).

choco install ninja

Option 2. Download Ninja to a directory that is present in %PATH%.

Create a project

Create a project directory.

mkdir your_project
cd your_project

Option 1. Clone the GN configuration.

git clone https://github.com/mmotorny/build.git

Option 2. If your project is tracked by Git, add the GN configuration as a submodule.

git submodule add https://github.com/mmotorny/build build

Initialize the source root with templates of .gn and BUILDCONFIG.gn files.

copy build\templates\*.gn .

Optional. Customize BUILDCONFIG.gn.

Now you are ready to write a BUILD.gn file.

About

A standalone GN configuration which supports GCC, Clang, Xcode, and Visual Studio toolchains.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published