blob: 72a600313f83a5a5f1cd63fb9519fa40eb408ff5 [file] [log] [blame] [view]
dan sinclair5ee22f32022-04-28 16:25:43 +00001# Building Dawn
2
3## System requirements
4
5 * Git
6 * CMake (3.10.2 or later) (if desired)
7 * GN (if desired)
8 * Ninja (or other build tool)
9 * Python, for fetching dependencies
10 * [depot_tools] in your path
11
12- Linux
13 - The `pkg-config` command:
14 ```sh
15 # Install pkg-config on Ubuntu
16 sudo apt-get install pkg-config
17 ```
18
19- Mac
20 - [Xcode](https://developer.apple.com/xcode/) 12.2+.
21 - The macOS 11.0 SDK. Run `xcode-select` to check whether you have it.
22 ```sh
23 ls `xcode-select -p`/Platforms/MacOSX.platform/Developer/SDKs
24 ```
25
Elie Michel69fb43d2023-08-10 07:10:02 +000026## Get the code and its dependencies
27
28### Using `depot_tools`
dan sinclair5ee22f32022-04-28 16:25:43 +000029
30Dawn uses the Chromium build system and dependency management so you need to [install depot_tools] and add it to the PATH.
31
32[install depot_tools]: http://commondatastorage.googleapis.com/chrome-infra-docs/flat/depot_tools/docs/html/depot_tools_tutorial.html#_setting_up
33
dan sinclair5ee22f32022-04-28 16:25:43 +000034```sh
35# Clone the repo as "dawn"
36git clone https://dawn.googlesource.com/dawn dawn && cd dawn
37
38# Bootstrap the gclient configuration
39cp scripts/standalone.gclient .gclient
40
41# Fetch external dependencies and toolchains with gclient
42gclient sync
43```
44
Elie Michel69fb43d2023-08-10 07:10:02 +000045### Without `depot_tools`
46
47If you cannot or do not want to depend on `depot_tools`, you may use the `tools/fetch_dawn_dependencies.py` to clone the dependencies' repositories:
48
49```sh
50# Clone the repo as "dawn"
51git clone https://dawn.googlesource.com/dawn dawn && cd dawn
52
53# Fetch dependencies (lose equivalent of gclient sync)
54python tools/fetch_dawn_dependencies.py --use-test-deps
55```
56
57Use `python tools/fetch_dawn_dependencies.py -h` to know more about the available options. The `--use-test-deps` option used above specifies to also fetch dependencies needed by tests. Contrary to `depot_tools`, this scripts does not figure out option-dependent requirements automatically.
58
dan sinclair81a2ed32024-03-27 14:43:12 +000059### Linux dependencies
60
61The following packages are needed to build Dawn. (Package names are the Ubuntu names).
62
63* `libxrandr-dev`
64* `libxinerama-dev`
65* `libxcursor-dev`
66* `mesa-common-dev`
67* `libx11-xcb-dev`
68* `pkg-config`
69* `nodejs`
70* `npm`
71
72```sh
73sudo apt-get install libxrandr-dev libxinerama-dev libxcursor-dev mesa-common-dev libx11-xcb-dev pkg-config nodejs npm
74```
75
76Note, `nodejs` and `npm` are only needed if building `dawn.node`.
77
78
dan sinclair5ee22f32022-04-28 16:25:43 +000079## Build Dawn
80
81### Compiling using CMake + Ninja
82```sh
83mkdir -p out/Debug
84cd out/Debug
85cmake -GNinja ../..
86ninja # or autoninja
87```
88
89### Compiling using CMake + make
90```sh
91mkdir -p out/Debug
92cd out/Debug
93cmake ../..
94make # -j N for N-way parallel build
95```
96
97### Compiling using gn + ninja
98```sh
99mkdir -p out/Debug
100gn gen out/Debug
101autoninja -C out/Debug
102```
103
104The most common GN build option is `is_debug=true/false`; otherwise
105`gn args out/Debug --list` shows all the possible options.
106
107On macOS you'll want to add the `use_system_xcode=true` in most cases.
108(and if you're a googler please get XCode from go/xcode).
109
Brandon Jonesd22886c2023-05-08 16:45:38 +0000110To generate a Microsoft Visual Studio solution, add `ide=vs2022` and
111`ninja-executable=<dawn parent directory>\dawn\third_party\ninja\ninja.exe`.
112The .sln file will be created in the output directory specified.
dan sinclair5ee22f32022-04-28 16:25:43 +0000113
114### Fuzzers on MacOS
115If you are attempting fuzz, using `TINT_BUILD_FUZZERS=ON`, the version of llvm
116in the XCode SDK does not have the needed libfuzzer functionality included.
117
118The build error that you will see from using the XCode SDK will look something
119like this:
120```
121ld: file not found:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib/darwin/libclang_rt.fuzzer_osx.a
122```
123
124The solution to this problem is to use a full version llvm, like what you would
125get via homebrew, `brew install llvm`, and use something like `CC=<path to full
126clang> cmake ..` to setup a build using that toolchain.
127