cc_project_template_gn

A gn, ninja, and googletest-based C++ project template
git clone https://git.bracken.jp/cc_project_template_gn.git
Log | Files | Refs | Submodules | README | LICENSE

README.md (1222B)


      1 ProjectTemplate
      2 ===============
      3 
      4 A [gn](https://gn.googlesource.com/gn),
      5 [ninja](https://github.com/ninja-build/ninja), and
      6 [googletest](https://github.com/google/googletest)-based C++ project template.
      7 
      8 
      9 Prerequisites
     10 -------------
     11 
     12 To build, you'll need [gn](https://gn.googlesource.com/gn),
     13 [ninja](https://github.com/ninja-build/ninja), and a clang build toolchain
     14 installed on your system.
     15 
     16 
     17 Obtaining the source
     18 --------------------
     19 
     20 First, clone the repo. Then, initialise and fetch git submodules:
     21 
     22     # Initialise local configuration file.
     23     git submodule init
     24 
     25     # Fetch data from the buildroot submodule.
     26     git submodule update
     27 
     28 
     29 Updating the gn buildroot
     30 -------------------------
     31 
     32 To update the git submodules to a newer commit, simply run:
     33 
     34     git submodule update --remote
     35 
     36 
     37 Building and running
     38 --------------------
     39 
     40 First, generate the ninja build files under the `out` directory:
     41 
     42     gn gen --args=is_debug=true out/debug
     43     gn gen --args=is_debug=false out/release
     44 
     45 
     46 ### Unit tests
     47 
     48 To build and run the unit tests, run:
     49 
     50     ninja -C out/debug src:foo_tests
     51     ./out/debug/foo_tests
     52 
     53 
     54 ### Executable binary
     55 
     56 To build and run the binary:
     57 
     58     ninja -C out/debug src:main
     59     ./out/debug/main