blob: a80005b02c6734122c69e7e89a31afe1bad077bf [file] [log] [blame] [view]
anlex N70844c82024-04-24 18:49:31 +08001# Building and using `gn` with MinGW on Windows
2
3At the time of writing: 2024-04-13
4Test environment: Windows 11, intel x86_64 CPU
5
6## Requirements
7
81. Install [MSYS2](https://www.msys2.org/)
91. Start a Terminal windows for MSYS2's MinGW development by opening one of `clang32.exe`, `clang64.exe`, `clangarm64.exe`,`mingw32.exe`, `mingw64.exe`, `ucrt64.exe`.
101. To download clang toolchain, Ninja and git programs, run command: `pacman -S mingw-w64-clang-x86_64-toolchain mingw-w64-clang-x86_64-ninja git`
11
12## Build `gn`
13
141. To clone `gn` source code, run command: `git clone https://gn.googlesource.com/gn`
151. Run command: `cd gn`
161. Run command: `build/gen.py --platform mingw`
17 This configuration generates a static executable that does not depend on MSYS2, and can be run in any development environment.
18 Use `--help` flag to check more configuration options.
19 Use `--allow-warning` flag to build with warnings.
201. Run command: `ninja -C out`
21
22## Testing
23
241. Run command: `out/gn --version`
251. Run command: `out/gn_unittests`
26
27> Notes:
28>
29> For "mingw-w64-clang-x86_64-toolchain" in the clang64 environment, g++ is a copy of clang++.
30>
31> The toolchain that builds `gn` does not use vendor lock-in compiler command flags,
32> so `gn` can be built with these clang++, g++.
33>
34> However the build rules in [examples/simple_build](../examples/simple_build/) require GCC-specific compiler macros, and thus only work in the `ucrt64` MSYS2 development environment.