2020-07-29 20:19:11 +00:00
|
|
|
# How to build Skia
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Make sure you have first followed the
|
|
|
|
[instructions to download Skia](./download).
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2016-11-04 16:32:07 +00:00
|
|
|
Skia uses [GN](https://chromium.googlesource.com/chromium/src/tools/gn/) to
|
|
|
|
configure its builds.
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
- [`is_official_build` and Third-party Dependencies](#third-party)
|
|
|
|
- [Supported and Preferred Compilers](#compilers)
|
|
|
|
- [Quickstart](#quick)
|
|
|
|
- [Android](#android)
|
|
|
|
- [ChromeOS](#cros)
|
|
|
|
- [Mac](#macos)
|
|
|
|
- [iOS](#ios)
|
|
|
|
- [Windows](#windows)
|
|
|
|
- [Windows ARM64](#win-arm64)
|
|
|
|
- [CMake](#cmake)
|
2019-07-10 15:24:52 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="third-party">`is_official_build` and Third-party Dependencies</span>
|
2017-03-03 14:21:30 +00:00
|
|
|
|
|
|
|
Most users of Skia should set `is_official_build=true`, and most developers
|
|
|
|
should leave it to its `false` default.
|
|
|
|
|
|
|
|
This mode configures Skia in a way that's suitable to ship: an optimized build
|
|
|
|
with no debug symbols, dynamically linked against its third-party dependencies
|
|
|
|
using the ordinary library search path.
|
|
|
|
|
|
|
|
In contrast, the developer-oriented default is an unoptimized build with full
|
|
|
|
debug symbols and all third-party dependencies built from source and embedded
|
2020-07-29 20:19:11 +00:00
|
|
|
into libskia. This is how we do all our manual and automated testing.
|
2017-03-03 14:21:30 +00:00
|
|
|
|
|
|
|
Skia offers several features that make use of third-party libraries, like
|
|
|
|
libpng, libwebp, or libjpeg-turbo to decode images, or ICU and sftnly to subset
|
2020-07-29 20:19:11 +00:00
|
|
|
fonts. All these third-party dependencies are optional and can be controlled by
|
|
|
|
a GN argument that looks something like `skia_use_foo` for appropriate `foo`.
|
2017-03-03 14:21:30 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
If `skia_use_foo` is enabled, enabling `skia_use_system_foo` will build and link
|
|
|
|
Skia against the headers and libaries found on the system paths.
|
|
|
|
`is_official_build=true` enables all `skia_use_system_foo` by default. You can
|
2017-03-03 14:21:30 +00:00
|
|
|
use `extra_cflags` and `extra_ldflags` to add include or library paths if
|
|
|
|
needed.
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="compilers">Supported and Preferred Compilers</span>
|
2020-02-12 00:25:55 +00:00
|
|
|
|
|
|
|
While Skia should compile with GCC, MSVC, and other compilers, a number of
|
|
|
|
routines in Skia's software backend have been written to run fastest when
|
2020-07-29 20:19:11 +00:00
|
|
|
compiled with Clang. If you depend on software rasterization, image decoding, or
|
|
|
|
color space conversion and compile Skia with a compiler other than Clang, you
|
|
|
|
will see dramatically worse performance. This choice was only a matter of
|
2020-02-12 00:25:55 +00:00
|
|
|
prioritization; there is nothing fundamentally wrong with non-Clang compilers.
|
|
|
|
So if this is a serious issue for you, please let us know on the mailing list.
|
|
|
|
|
|
|
|
Skia makes use of C++17 language features (compiles with `-std=c++17` flag) and
|
2020-07-29 20:19:11 +00:00
|
|
|
thus requires a C++17 compatible compiler. Clang 5 and later implement all of
|
|
|
|
the features of the c++17 standard. Older compilers that lack C++17 support may
|
|
|
|
produce non-obvious compilation errors. You can configure your build to use
|
2020-02-12 00:25:55 +00:00
|
|
|
specific executables for `cc` and `cxx` invocations using e.g.
|
|
|
|
`--args='cc="clang-6.0" cxx="clang++6.0"'` GN build arguments, as illustrated in
|
2020-07-29 20:19:11 +00:00
|
|
|
[Quickstart](#quick). This can be useful for building Skia without needing to
|
2020-02-12 00:25:55 +00:00
|
|
|
modify your machine's default compiler toolchain.
|
Reland "Reland "make SkJumper stages normal Skia code""
This is a reland of 78cb579f33943421afc8423a39867fcfd69fed44
This time, lowp stages are controlled by !defined(JUMPER_IS_SCALAR), not
by defined(__clang__). The two are usually the same, except when we opt
Clang builds into JUMPER_IS_SCALAR artificially.
Some Google3 builds use compilers old enough that they barf when
compiling our NEON code. It's conceivably also possible to define
JUMPER_IS_SCALAR yourself, but I don't think anyone does that.
Original change's description:
> Reland "make SkJumper stages normal Skia code"
>
> This is a reland of 22e536e3a1a09405d1c0e6f071717a726d86e8d4
>
> Now with fixed #include paths in SkRasterPipeline_opts.h,
> and -ffp-contract=fast for the :hsw target to minimize
> diffs on non-Windows Clang AVX2/AVX-512 bots.
>
> Original change's description:
> > make SkJumper stages normal Skia code
> >
> > Enough clients are using Clang now that we can say, use Clang to build
> > if you want these software pipeline stages to go fast.
> >
> > This lets us drop the offline build aspect of SkJumper stages, instead
> > building as part of Skia using the SkOpts framework.
> >
> > I think everything should work, except I've (temporarily) removed
> > AVX-512 support. I will put this back in a follow up.
> >
> > I have had to drop Windows down to __vectorcall and our narrower
> > stage calling convention that keeps the d-registers on the stack.
> > I tried forcing sysv_abi, but that crashed Clang. :/
> >
> > Added a TODO to up the same narrower stage calling convention
> > for lowp stages... we just *don't* today, for no good reason.
> >
> > Change-Id: Iaaa792ffe4deab3508d2dc5d0008c163c24b3383
> > Reviewed-on: https://skia-review.googlesource.com/110641
> > Commit-Queue: Mike Klein <mtklein@chromium.org>
> > Reviewed-by: Herb Derby <herb@google.com>
> > Reviewed-by: Florin Malita <fmalita@chromium.org>
>
> Change-Id: I44f2c03d33958e3807747e40904b6351957dd448
> Reviewed-on: https://skia-review.googlesource.com/112742
> Reviewed-by: Mike Klein <mtklein@chromium.org>
Change-Id: I3d71197d4bbb19ca4a94961a97fa2e54d5cbfb0d
Reviewed-on: https://skia-review.googlesource.com/112744
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
2018-02-27 15:37:40 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="quick">Quickstart</span>
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Run `gn gen` to generate your build files. As arguments to `gn gen`, pass a name
|
|
|
|
for your build directory, and optionally `--args=` to configure the build type.
|
2016-12-16 13:10:47 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To build Skia as a static library in a build directory named `out/Static`:
|
2016-12-16 13:10:47 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/Static --args='is_official_build=true'
|
|
|
|
```
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To build Skia as a shared library (DLL) in a build directory named `out/Shared`:
|
2016-09-16 14:17:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/Shared --args='is_official_build=true is_component_build=true'
|
|
|
|
```
|
2016-11-04 16:32:07 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
If you find that you don't have `bin/gn`, make sure you've run:
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
python2 tools/git-sync-deps
|
|
|
|
```
|
2016-11-04 16:32:07 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
For a list of available build arguments, take a look at `gn/skia.gni`, or run:
|
2016-09-16 14:17:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn args out/Debug --list
|
|
|
|
```
|
2016-11-04 16:32:07 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
GN allows multiple build folders to coexist; each build can be configured
|
|
|
|
separately as desired. For example:
|
2016-07-29 15:35:54 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/Debug
|
|
|
|
bin/gn gen out/Release --args='is_debug=false'
|
|
|
|
bin/gn gen out/Clang --args='cc="clang" cxx="clang++"'
|
|
|
|
bin/gn gen out/Cached --args='cc_wrapper="ccache"'
|
|
|
|
bin/gn gen out/RTTI --args='extra_cflags_cc=["-frtti"]'
|
|
|
|
```
|
2018-02-09 02:52:18 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Once you have generated your build files, run Ninja to compile and link Skia:
|
|
|
|
|
|
|
|
```
|
|
|
|
ninja -C out/Static
|
|
|
|
```
|
|
|
|
|
|
|
|
If some header files are missing, install the corresponding dependencies:
|
|
|
|
|
|
|
|
```
|
|
|
|
tools/install_dependencies.sh
|
|
|
|
```
|
2018-02-09 02:52:18 +00:00
|
|
|
|
2020-02-12 00:25:55 +00:00
|
|
|
To pull new changes and rebuild:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
git pull
|
|
|
|
python tools/git-sync-deps
|
|
|
|
ninja -C out/Static
|
|
|
|
```
|
2020-02-12 00:25:55 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="android">Android</span>
|
2016-08-29 17:27:16 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To build Skia for Android you need an
|
|
|
|
[Android NDK](https://developer.android.com/ndk/index.html).
|
2016-08-29 17:27:16 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
If you do not have an NDK and have access to CIPD, you can use one of these
|
|
|
|
commands to fetch the NDK our bots use:
|
2016-08-29 17:27:16 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
python2 infra/bots/assets/android_ndk_linux/download.py -t /tmp/ndk
|
|
|
|
python2 infra/bots/assets/android_ndk_darwin/download.py -t /tmp/ndk
|
|
|
|
python2 infra/bots/assets/android_ndk_windows/download.py -t C:/ndk
|
|
|
|
```
|
2016-08-29 17:27:16 +00:00
|
|
|
|
|
|
|
When generating your GN build files, pass the path to your `ndk` and your
|
|
|
|
desired `target_cpu`:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/arm --args='ndk="/tmp/ndk" target_cpu="arm"'
|
|
|
|
bin/gn gen out/arm64 --args='ndk="/tmp/ndk" target_cpu="arm64"'
|
|
|
|
bin/gn gen out/x64 --args='ndk="/tmp/ndk" target_cpu="x64"'
|
|
|
|
bin/gn gen out/x86 --args='ndk="/tmp/ndk" target_cpu="x86"'
|
|
|
|
```
|
2016-08-29 17:27:16 +00:00
|
|
|
|
|
|
|
Other arguments like `is_debug` and `is_component_build` continue to work.
|
2016-09-16 14:17:45 +00:00
|
|
|
Tweaking `ndk_api` gives you access to newer Android features like Vulkan.
|
2016-09-08 17:03:21 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To test on an Android device, push the binary and `resources` over, and run it
|
|
|
|
as normal. You may find `bin/droid` convenient.
|
2016-10-15 15:44:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
ninja -C out/arm64
|
|
|
|
adb push out/arm64/dm /data/local/tmp
|
|
|
|
adb push resources /data/local/tmp
|
|
|
|
adb shell "cd /data/local/tmp; ./dm --src gm --config gl"
|
|
|
|
```
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="cros">ChromeOS</span>
|
2019-07-10 15:24:52 +00:00
|
|
|
|
2017-11-02 16:28:34 +00:00
|
|
|
To cross-compile Skia for arm ChromeOS devices the following is needed:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
- Clang 4 or newer
|
|
|
|
- An armhf sysroot
|
|
|
|
- The (E)GL lib files on the arm chromebook to link against.
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To compile Skia for an x86 ChromeOS device, one only needs Clang and the lib
|
|
|
|
files.
|
2017-11-02 16:28:34 +00:00
|
|
|
|
|
|
|
If you have access to CIPD, you can fetch all of these as follows:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
python2 infra/bots/assets/clang_linux/download.py -t /opt/clang
|
|
|
|
python2 infra/bots/assets/armhf_sysroot/download.py -t /opt/armhf_sysroot
|
|
|
|
python2 infra/bots/assets/chromebook_arm_gles/download.py -t /opt/chromebook_arm_gles
|
|
|
|
python2 infra/bots/assets/chromebook_x86_64_gles/download.py -t /opt/chromebook_x86_64_gles
|
|
|
|
```
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
If you don't have authorization to use those assets, then see the README.md
|
|
|
|
files for
|
2017-11-02 16:28:34 +00:00
|
|
|
[armhf_sysroot](https://skia.googlesource.com/skia/+/master/infra/bots/assets/armhf_sysroot/README.md),
|
2020-07-29 20:19:11 +00:00
|
|
|
[chromebook_arm_gles](https://skia.googlesource.com/skia/+/master/infra/bots/assets/chromebook_arm_gles/README.md),
|
|
|
|
and
|
2017-11-02 16:28:34 +00:00
|
|
|
[chromebook_x86_64_gles](https://skia.googlesource.com/skia/+/master/infra/bots/assets/chromebook_x86_64_gles/README.md)
|
|
|
|
for instructions on creating those assets.
|
|
|
|
|
|
|
|
Once those files are in place, generate the GN args that resemble the following:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
#ARM
|
|
|
|
cc= "/opt/clang/bin/clang"
|
|
|
|
cxx = "/opt/clang/bin/clang++"
|
|
|
|
|
|
|
|
extra_asmflags = [
|
|
|
|
"--target=armv7a-linux-gnueabihf",
|
|
|
|
"--sysroot=/opt/armhf_sysroot/",
|
|
|
|
"-march=armv7-a",
|
|
|
|
"-mfpu=neon",
|
|
|
|
"-mthumb",
|
|
|
|
]
|
|
|
|
extra_cflags=[
|
|
|
|
"--target=armv7a-linux-gnueabihf",
|
|
|
|
"--sysroot=/opt/armhf_sysroot",
|
|
|
|
"-I/opt/chromebook_arm_gles/include",
|
|
|
|
"-I/opt/armhf_sysroot/include/",
|
|
|
|
"-I/opt/armhf_sysroot/include/c++/4.8.4/",
|
|
|
|
"-I/opt/armhf_sysroot/include/c++/4.8.4/arm-linux-gnueabihf/",
|
|
|
|
"-DMESA_EGL_NO_X11_HEADERS",
|
|
|
|
"-funwind-tables",
|
|
|
|
]
|
|
|
|
extra_ldflags=[
|
|
|
|
"--sysroot=/opt/armhf_sysroot",
|
|
|
|
"-B/opt/armhf_sysroot/bin",
|
|
|
|
"-B/opt/armhf_sysroot/gcc-cross",
|
|
|
|
"-L/opt/armhf_sysroot/gcc-cross",
|
|
|
|
"-L/opt/armhf_sysroot/lib",
|
|
|
|
"-L/opt/chromebook_arm_gles/lib",
|
|
|
|
"--target=armv7a-linux-gnueabihf",
|
|
|
|
]
|
|
|
|
target_cpu="arm"
|
|
|
|
skia_use_fontconfig = false
|
|
|
|
skia_use_system_freetype2 = false
|
|
|
|
skia_use_egl = true
|
|
|
|
|
|
|
|
|
|
|
|
# x86_64
|
|
|
|
cc= "/opt/clang/bin/clang"
|
|
|
|
cxx = "/opt/clang/bin/clang++"
|
|
|
|
extra_cflags=[
|
|
|
|
"-I/opt/clang/include/c++/v1/",
|
|
|
|
"-I/opt/chromebook_x86_64_gles/include",
|
|
|
|
"-DMESA_EGL_NO_X11_HEADERS",
|
|
|
|
"-DEGL_NO_IMAGE_EXTERNAL",
|
|
|
|
]
|
|
|
|
extra_ldflags=[
|
|
|
|
"-stdlib=libc++",
|
|
|
|
"-fuse-ld=lld",
|
|
|
|
"-L/opt/chromebook_x86_64_gles/lib",
|
|
|
|
]
|
|
|
|
target_cpu="x64"
|
|
|
|
skia_use_fontconfig = false
|
|
|
|
skia_use_system_freetype2 = false
|
|
|
|
skia_use_egl = true
|
|
|
|
```
|
2017-11-02 16:28:34 +00:00
|
|
|
|
|
|
|
Compile dm (or another executable of your choice) with ninja, as per usual.
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Push the binary to a chromebook via ssh and
|
|
|
|
[run dm as normal](https://skia.org/dev/testing/tests) using the gles GPU
|
|
|
|
config.
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Most chromebooks by default have their home directory partition marked as
|
|
|
|
noexec. To avoid "permission denied" errors, remember to run something like:
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
sudo mount -i -o remount,exec /home/chronos
|
|
|
|
```
|
2017-11-02 16:28:34 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="macos">Mac</span>
|
2016-10-25 15:39:12 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Mac users may want to pass `--ide=xcode` to `bin/gn gen` to generate an Xcode
|
|
|
|
project.
|
2016-10-25 15:39:12 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="ios">iOS</span>
|
2017-02-03 18:13:29 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Run GN to generate your build files. Set `target_os="ios"` to build for iOS.
|
|
|
|
This defaults to `target_cpu="arm64"`. Choosing `x64` targets the iOS simulator.
|
2017-03-03 13:29:18 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/ios64 --args='target_os="ios"'
|
|
|
|
bin/gn gen out/ios32 --args='target_os="ios" target_cpu="arm"'
|
|
|
|
bin/gn gen out/iossim --args='target_os="ios" target_cpu="x64"'
|
|
|
|
```
|
2017-03-03 13:29:18 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
This will also package (and for devices, sign) iOS test binaries. This defaults
|
|
|
|
to a Google signing identity and provisioning profile. To use a different one
|
|
|
|
set the GN args `skia_ios_identity` to match your code signing identity and
|
|
|
|
`skia_ios_profile` to the name of your provisioning profile, e.g.
|
2020-02-05 14:40:12 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
skia_ios_identity=".*Jane Doe.*"
|
|
|
|
skia_ios_profile="iPad Profile"`
|
|
|
|
```
|
2020-02-05 14:40:12 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
A list of identities can be found by typing `security find-identity` on the
|
|
|
|
command line. The name of the provisioning profile should be available on the
|
|
|
|
Apple Developer site. Alternatively, `skia_ios_profile` can be the absolute path
|
|
|
|
to the mobileprovision file.
|
2017-02-03 18:13:29 +00:00
|
|
|
|
2020-11-18 21:07:37 +00:00
|
|
|
If you find yourself missing a Google signing identity or provisioning profile,
|
|
|
|
you'll want to have a read through go/appledev.
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
For signed packages `ios-deploy` makes installing and running them on a device
|
|
|
|
easy:
|
2017-02-03 18:13:29 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
ios-deploy -b out/Debug/dm.app -d --args "--match foo"
|
|
|
|
```
|
2017-02-03 18:13:29 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Alternatively you can generate an Xcode project by passing `--ide=xcode` to
|
2020-11-18 21:07:37 +00:00
|
|
|
`bin/gn gen`. If you are using Xcode version 10 or later, you may need to go to
|
|
|
|
`Project Settings...` and verify that `Build System:` is set to `Legacy Build System`.
|
2017-02-03 18:13:29 +00:00
|
|
|
|
2020-11-18 21:07:37 +00:00
|
|
|
Deploying to a device with an OS older than the current SDK can be done by setting the
|
|
|
|
`ios_min_target` arg:
|
2020-02-04 18:51:49 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
2020-11-18 21:07:37 +00:00
|
|
|
ios_min_target = "<major>.<minor>"
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
2020-02-04 18:51:49 +00:00
|
|
|
|
2020-02-05 14:40:12 +00:00
|
|
|
where `<major>.<minor>` is the iOS version on the device, e.g., 12.0 or 11.4.
|
2017-12-07 20:16:10 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="windows">Windows</span>
|
2016-10-15 15:44:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Skia can build on Windows with Visual Studio 2017 or 2019. If GN is unable to
|
|
|
|
locate either of those, it will print an error message. In that case, you can
|
|
|
|
pass your `VC` path to GN via `win_vc`.
|
Updated MSVC toolchain to 2017, and further refactored GN
'windk' is no longer a thing. There are two separate variables to point
at your compiler (win_vc), and SDK (win_sdk).
'msvc' is no longer a thing, either. By default, we look for 2017 and
then 2015 (in the default locations). If neither is located, use an
assert to let users know they should set win_vc. Then, detect if win_vc
points at a 2017 or 2015 installation, and configure it automatically.
Because the toolchain is now 2017, update the GN files to handle building
x86 in that configuration. In fact, we only support x86 builds (with 2017
or 2015) using the toolchain assets. Keep a 2015 toolchain around as a
new asset, so we can add bot coverage.
Docs-Preview: https://skia.org/?cl=81841
Bug: skia:
Change-Id: I8c68a6f949e54c0e798a219450bbb9406f8dc6ac
Reviewed-on: https://skia-review.googlesource.com/81841
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-07 21:16:21 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Skia can be compiled with the free
|
|
|
|
[Build Tools for Visual Studio 2017 or 2019](https://www.visualstudio.com/downloads/#build-tools-for-visual-studio-2019).
|
2018-02-14 16:25:31 +00:00
|
|
|
|
2019-12-26 19:33:39 +00:00
|
|
|
The bots use a packaged 2019 toolchain, which Googlers can download like this:
|
2016-10-15 15:44:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
python2 infra/bots/assets/win_toolchain/download.py -t C:/toolchain
|
|
|
|
```
|
2016-10-15 15:44:45 +00:00
|
|
|
|
Updated MSVC toolchain to 2017, and further refactored GN
'windk' is no longer a thing. There are two separate variables to point
at your compiler (win_vc), and SDK (win_sdk).
'msvc' is no longer a thing, either. By default, we look for 2017 and
then 2015 (in the default locations). If neither is located, use an
assert to let users know they should set win_vc. Then, detect if win_vc
points at a 2017 or 2015 installation, and configure it automatically.
Because the toolchain is now 2017, update the GN files to handle building
x86 in that configuration. In fact, we only support x86 builds (with 2017
or 2015) using the toolchain assets. Keep a 2015 toolchain around as a
new asset, so we can add bot coverage.
Docs-Preview: https://skia.org/?cl=81841
Bug: skia:
Change-Id: I8c68a6f949e54c0e798a219450bbb9406f8dc6ac
Reviewed-on: https://skia-review.googlesource.com/81841
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-07 21:16:21 +00:00
|
|
|
You can then pass the VC and SDK paths to GN by setting your GN args:
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
win_vc = "C:\toolchain\VC"
|
|
|
|
win_sdk = "C:\toolchain\win_sdk"
|
|
|
|
```
|
Updated MSVC toolchain to 2017, and further refactored GN
'windk' is no longer a thing. There are two separate variables to point
at your compiler (win_vc), and SDK (win_sdk).
'msvc' is no longer a thing, either. By default, we look for 2017 and
then 2015 (in the default locations). If neither is located, use an
assert to let users know they should set win_vc. Then, detect if win_vc
points at a 2017 or 2015 installation, and configure it automatically.
Because the toolchain is now 2017, update the GN files to handle building
x86 in that configuration. In fact, we only support x86 builds (with 2017
or 2015) using the toolchain assets. Keep a 2015 toolchain around as a
new asset, so we can add bot coverage.
Docs-Preview: https://skia.org/?cl=81841
Bug: skia:
Change-Id: I8c68a6f949e54c0e798a219450bbb9406f8dc6ac
Reviewed-on: https://skia-review.googlesource.com/81841
Reviewed-by: Mike Klein <mtklein@chromium.org>
Commit-Queue: Brian Osman <brianosman@google.com>
2017-12-07 21:16:21 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
This toolchain is the only way we support 32-bit builds, by also setting
|
|
|
|
`target_cpu="x86"`.
|
2016-10-15 15:44:45 +00:00
|
|
|
|
2018-06-19 14:34:32 +00:00
|
|
|
The Skia build assumes that the PATHEXT environment variable contains ".EXE".
|
|
|
|
|
2018-11-20 16:20:25 +00:00
|
|
|
### **Highly Recommended**: Build with clang-cl
|
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Skia uses generated code that is only optimized when Skia is built with clang.
|
|
|
|
Other compilers get generic unoptimized code.
|
2018-11-20 16:20:25 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
Setting the `cc` and `cxx` gn args is _not_ sufficient to build with clang-cl.
|
|
|
|
These variables are ignored on Windows. Instead set the variable `clang_win` to
|
|
|
|
your LLVM installation directory. If you installed the prebuilt LLVM downloaded
|
|
|
|
from [here](https://releases.llvm.org/download.html "LLVM Download") in the
|
|
|
|
default location that would be:
|
2018-11-20 16:20:25 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
clang_win = "C:\Program Files\LLVM"
|
|
|
|
```
|
2018-11-20 16:20:25 +00:00
|
|
|
|
2019-07-10 15:24:52 +00:00
|
|
|
Follow the standard Windows path specification and not MinGW convention (e.g.
|
|
|
|
`C:\Program Files\LLVM` not ~~`/c/Program Files/LLVM`~~).
|
2018-11-20 16:20:25 +00:00
|
|
|
|
2016-12-14 16:06:04 +00:00
|
|
|
### Visual Studio Solutions
|
|
|
|
|
2017-01-13 14:05:46 +00:00
|
|
|
If you use Visual Studio, you may want to pass `--ide=vs` to `bin/gn gen` to
|
2020-07-29 20:19:11 +00:00
|
|
|
generate `all.sln`. That solution will exist within the GN directory for the
|
2016-12-14 16:06:04 +00:00
|
|
|
specific configuration, and will only build/run that configuration.
|
|
|
|
|
|
|
|
If you want a Visual Studio Solution that supports multiple GN configurations,
|
|
|
|
there is a helper script. It requires that all of your GN directories be inside
|
2020-07-29 20:19:11 +00:00
|
|
|
the `out` directory. First, create all of your GN configurations as usual. Pass
|
|
|
|
`--ide=vs` when running `bin/gn gen` for each one. Then:
|
2016-12-14 16:06:04 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
python2 gn/gn_meta_sln.py
|
|
|
|
```
|
2016-12-14 16:06:04 +00:00
|
|
|
|
|
|
|
This creates a new dedicated output directory and solution file
|
|
|
|
`out/sln/skia.sln`. It has one solution configuration for each GN configuration,
|
2020-07-29 20:19:11 +00:00
|
|
|
and supports building and running any of them. It also adjusts syntax
|
|
|
|
highlighting of inactive code blocks based on preprocessor definitions from the
|
|
|
|
selected solution configuration.
|
2016-12-14 16:06:04 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="win-arm64">Windows ARM64</span>
|
2018-12-10 16:44:23 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
There is early, experimental support for
|
|
|
|
[Windows 10 on ARM](https://docs.microsoft.com/en-us/windows/arm/). This
|
|
|
|
currently requires (a recent version of) MSVC, and the `Visual C++ compilers and
|
|
|
|
libraries for ARM64` individual component in the Visual Studio Installer. For
|
|
|
|
Googlers, the win_toolchain asset includes the ARM64 compiler.
|
2018-12-10 16:44:23 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
To use that toolchain, set the `target_cpu` GN argument to `"arm64"`. Note that
|
|
|
|
OpenGL is not supported by Windows 10 on ARM, so Skia's GL backends are stubbed
|
|
|
|
out, and will not work. ANGLE is supported:
|
2018-12-10 16:44:23 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/win-arm64 --args='target_cpu="arm64" skia_use_angle=true'
|
|
|
|
```
|
2018-12-10 16:44:23 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
This will produce a build of Skia that can use the software or ANGLE backends,
|
|
|
|
in DM. Viewer only works when launched with `--backend angle`, because the
|
|
|
|
software backend tries to use OpenGL to display the window contents.
|
2018-12-10 16:44:23 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
## <span id="cmake">CMake</span>
|
2016-10-15 15:44:45 +00:00
|
|
|
|
|
|
|
We have added a GN-to-CMake translator mainly for use with IDEs that like CMake
|
2020-07-29 20:19:11 +00:00
|
|
|
project descriptions. This is not meant for any purpose beyond development.
|
2016-10-15 15:44:45 +00:00
|
|
|
|
2020-07-29 20:19:11 +00:00
|
|
|
```
|
|
|
|
bin/gn gen out/config --ide=json --json-ide-script=../../gn/gn_to_cmake.py
|
|
|
|
```
|