OLD | NEW |
1 # How GN handles cross-compiling | 1 # How GN handles cross-compiling |
2 | 2 |
3 ## As a GN user | 3 ## As a GN user |
4 | 4 |
5 GN has robust support for doing cross compiles and building things for | 5 GN has robust support for doing cross compiles and building things for |
6 multiple architectures in a single build (e.g., to build some things to | 6 multiple architectures in a single build (e.g., to build some things to |
7 run locally and some things to run on an embedded device). In fact, | 7 run locally and some things to run on an embedded device). In fact, |
8 there is no limit on the number of different architectures you can build | 8 there is no limit on the number of different architectures you can build |
9 at once; the Chromium build uses at least four in some configurations. | 9 at once; the Chromium build uses at least four in some configurations. |
10 | 10 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 To do an 32-bit ARM Android cross-compile, do: | 43 To do an 32-bit ARM Android cross-compile, do: |
44 | 44 |
45 ``` | 45 ``` |
46 gn gen out/Default --args='target_os="android"' | 46 gn gen out/Default --args='target_os="android"' |
47 ``` | 47 ``` |
48 | 48 |
49 (We don't have to specify target\_cpu because of the conditionals | 49 (We don't have to specify target\_cpu because of the conditionals |
50 mentioned above). | 50 mentioned above). |
51 | 51 |
52 And, to do a 64-bit MIPS ChromeOS cross-compile: | 52 And, to do a 64-bit MIPS Chrome OS cross-compile: |
53 | 53 |
54 ``` | 54 ``` |
55 gn gen out/Default --args='target_os="chromeos" target_cpu="mips64el"' | 55 gn gen out/Default --args='target_os="chromeos" target_cpu="mips64el"' |
56 ``` | 56 ``` |
57 | 57 |
58 ## As a BUILD.gn author | 58 ## As a BUILD.gn author |
59 | 59 |
60 If you are editing build files outside of the //build directory (i.e., | 60 If you are editing build files outside of the //build directory (i.e., |
61 not directly working on toolchains, compiler configs, etc.), generally | 61 not directly working on toolchains, compiler configs, etc.), generally |
62 you only need to worry about a few things: | 62 you only need to worry about a few things: |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 `target_os` and `target_cpu`. The `current_toolchain` reflects the | 118 `target_os` and `target_cpu`. The `current_toolchain` reflects the |
119 toolchain that is currently in effect for a rule. | 119 toolchain that is currently in effect for a rule. |
120 | 120 |
121 Be sure you understand the differences between `host_cpu`, `target_cpu`, | 121 Be sure you understand the differences between `host_cpu`, `target_cpu`, |
122 `current_cpu`, and `toolchain_cpu` (and the os equivalents). The first | 122 `current_cpu`, and `toolchain_cpu` (and the os equivalents). The first |
123 two are set as described above. You are responsible for making sure that | 123 two are set as described above. You are responsible for making sure that |
124 `current_cpu` is set appropriately in your toolchain definitions; if you | 124 `current_cpu` is set appropriately in your toolchain definitions; if you |
125 are using the stock templates like `gcc_toolchain` and `msvc_toolchain`, | 125 are using the stock templates like `gcc_toolchain` and `msvc_toolchain`, |
126 that means you are responsible for making sure that `toolchain_cpu` and | 126 that means you are responsible for making sure that `toolchain_cpu` and |
127 `toolchain_os` are set as appropriate in the template invocations. | 127 `toolchain_os` are set as appropriate in the template invocations. |
OLD | NEW |