xref: /aosp_15_r20/external/vulkan-validation-layers/BUILD.md (revision b7893ccf7851cd6a48cc5a1e965257d8a5cdcc70)
1# Build Instructions
2
3Instructions for building this repository on Linux, Windows, Android, and
4MacOS.
5
6## Index
7
81. [Contributing](#contributing-to-the-repository)
91. [Repository Content](#repository-content)
101. [Repository Set-Up](#repository-set-up)
111. [Windows Build](#building-on-windows)
121. [Linux Build](#building-on-linux)
131. [Android Build](#building-on-android)
141. [MacOS build](#building-on-macos)
15
16## Contributing to the Repository
17
18If you intend to contribute, the preferred work flow is for you to develop
19your contribution in a fork of this repository in your GitHub account and then
20submit a pull request. Please see the [CONTRIBUTING.md](CONTRIBUTING.md) file
21in this repository for more details.
22
23## Repository Content
24
25This repository contains the source code necessary to build the Vulkan
26validation layers and their tests.
27
28### Installed Files
29
30The `install` target installs the following files under the directory
31indicated by *install_dir*:
32
33- *install_dir*`/lib` : The Vulkan validation layer libraries
34- *install_dir*`/share/vulkan/explicit_layer.d` : The Vulkan validation layer
35  JSON files (Linux and MacOS)
36
37The `uninstall` target can be used to remove the above files from the install
38directory.
39
40## Repository Set-Up
41
42### Display Drivers
43
44This repository does not contain a Vulkan-capable driver. You will need to
45obtain and install a Vulkan driver from your graphics hardware vendor or from
46some other suitable source if you intend to run Vulkan applications.
47
48### Download the Repository
49
50To create your local git repository:
51
52    git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git
53
54### Repository Dependencies
55
56This repository attempts to resolve some of its dependencies by using
57components found from the following places, in this order:
58
591. CMake or Environment variable overrides (e.g., -DVULKAN_HEADERS_INSTALL_DIR)
601. LunarG Vulkan SDK, located by the `VULKAN_SDK` environment variable
611. System-installed packages, mostly applicable on Linux
62
63Dependencies that cannot be resolved by the SDK or installed packages must be
64resolved with the "install directory" override and are listed below. The
65"install directory" override can also be used to force the use of a specific
66version of that dependency.
67
68#### Vulkan-Headers
69
70This repository has a required dependency on the
71[Vulkan Headers repository](https://github.com/KhronosGroup/Vulkan-Headers).
72You must clone the headers repository and build its `install` target before
73building this repository. The Vulkan-Headers repository is required because it
74contains the Vulkan API definition files (registry) that are required to build
75the validation layers. You must also take note of the headers' install
76directory and pass it on the CMake command line for building this repository,
77as described below.
78
79#### glslang
80
81This repository has a required dependency on the
82[glslang repository](https://github.com/KhronosGroup/glslang).
83The glslang repository is required because it contains components that are
84required to build the validation layers. You must clone the glslang repository
85and build its `install` target. Follow the build instructions in the glslang
86[README.md](https://github.com/KhronosGroup/glslang/blob/master/README.md)
87file. Ensure that the `update_glslang_sources.py` script has been run as part
88of building glslang. You must also take note of the glslang install directory
89and pass it on the CMake command line for building this repository, as
90described below.
91
92#### Google Test
93
94The validation layer tests depend on the
95[Google Test](https://github.com/google/googletest)
96framework and do not build unless this framework is downloaded into the
97repository's `external` directory.
98
99To obtain the framework, change your current directory to the top of your
100Vulkan-ValidationLayers repository and run:
101
102    git clone https://github.com/google/googletest.git external/googletest
103    cd external/googletest
104    git checkout tags/release-1.8.1
105
106before configuring your build with CMake.
107
108If you do not need the tests, there is no need to download this
109framework.
110
111#### Vulkan-Loader
112
113The validation layer tests depend on the Vulkan loader when they execute and
114so a loader is needed only if the tests are built and run.
115
116A loader can be used from an installed LunarG SDK, an installed Linux package,
117or from a driver installation on Windows.
118
119If a loader is not available from any of these methods and/or it is important
120to use a loader built from a repository, then you must build the
121[Vulkan-Loader repository](https://github.com/KhronosGroup/Vulkan-Loader.git)
122with its install target. Take note of its install directory location and pass
123it on the CMake command line for building this repository, as described below.
124
125If you do not intend to run the tests, you do not need a Vulkan loader.
126
127### Build and Install Directories
128
129A common convention is to place the build directory in the top directory of
130the repository with a name of `build` and place the install directory as a
131child of the build directory with the name `install`. The remainder of these
132instructions follow this convention, although you can use any name for these
133directories and place them in any location.
134
135### Building Dependent Repositories with Known-Good Revisions
136
137There is a Python utility script, `scripts/update_deps.py`, that you can use to
138gather and build the dependent repositories mentioned above. This script uses
139information stored in the `scripts/known_good.json` file to check out dependent
140repository revisions that are known to be compatible with the revision of this
141repository that you currently have checked out. As such, this script is useful
142as a quick-start tool for common use cases and default configurations.
143
144For all platforms, start with:
145
146    git clone [email protected]:KhronosGroup/Vulkan-ValidationLayers.git
147    cd Vulkan-ValidationLayers
148    mkdir build
149    cd build
150
151For 64-bit Linux and MacOS, continue with:
152
153    ../scripts/update_deps.py
154    cmake -C helper.cmake ..
155    cmake --build .
156
157For 64-bit Windows, continue with:
158
159    ..\scripts\update_deps.py --arch x64
160    cmake -A x64 -C helper.cmake ..
161    cmake --build .
162
163For 32-bit Windows, continue with:
164
165    ..\scripts\update_deps.py --arch Win32
166    cmake -A Win32 -C helper.cmake ..
167    cmake --build .
168
169Please see the more detailed build information later in this file if you have
170specific requirements for configuring and building these components.
171
172#### Notes
173
174- You may need to adjust some of the CMake options based on your platform. See
175  the platform-specific sections later in this document.
176- The `update_deps.py` script fetches and builds the dependent repositories in
177  the current directory when it is invoked. In this case, they are built in
178  the `build` directory.
179- The `build` directory is also being used to build this
180  (Vulkan-ValidationLayers) repository. But there shouldn't be any conflicts
181  inside the `build` directory between the dependent repositories and the
182  build files for this repository.
183- The `--dir` option for `update_deps.py` can be used to relocate the
184  dependent repositories to another arbitrary directory using an absolute or
185  relative path.
186- The `update_deps.py` script generates a file named `helper.cmake` and places
187  it in the same directory as the dependent repositories (`build` in this
188  case). This file contains CMake commands to set the CMake `*_INSTALL_DIR`
189  variables that are used to point to the install artifacts of the dependent
190  repositories. You can use this file with the `cmake -C` option to set these
191  variables when you generate your build files with CMake. This lets you avoid
192  entering several `*_INSTALL_DIR` variable settings on the CMake command line.
193- If using "MINGW" (Git For Windows), you may wish to run
194  `winpty update_deps.py` in order to avoid buffering all of the script's
195  "print" output until the end and to retain the ability to interrupt script
196  execution.
197- Please use `update_deps.py --help` to list additional options and read the
198  internal documentation in `update_deps.py` for further information.
199
200### Generated source code
201
202This repository contains generated source code in the `layers/generated`
203directory which is not intended to be modified directly. Instead, changes should be
204made to the corresponding generator in the `scripts` directory. The source files can
205then be regenerated using `scripts/generate_source.py`:
206
207    python3 scripts/generate_source.py PATH_TO_VULKAN_HEADERS_REGISTRY_DIR
208
209A helper CMake target `VulkanVL_generated_source` is also provided to simplify
210the invocation of `scripts/generate_source.py` from the build directory:
211
212    cmake --build . --target VulkanVL_generated_source
213
214### Build Options
215
216When generating native platform build files through CMake, several options can
217be specified to customize the build. Some of the options are binary on/off
218options, while others take a string as input. The following is a table of all
219on/off options currently supported by this repository:
220
221| Option | Platform | Default | Description |
222| ------ | -------- | ------- | ----------- |
223| BUILD_LAYERS | All | `ON` | Controls whether or not the validation layers are built. |
224| BUILD_LAYER_SUPPORT_FILES | All | `OFF` | Controls whether or not layer support files are built if the layers are not built. |
225| BUILD_TESTS | All | `???` | Controls whether or not the validation layer tests are built. The default is `ON` when the Google Test repository is cloned into the `external` directory.  Otherwise, the default is `OFF`. |
226| INSTALL_TESTS | All | `OFF` | Controls whether or not the validation layer tests are installed. This option is only available when a copy of Google Test is available
227| BUILD_WSI_XCB_SUPPORT | Linux | `ON` | Build the components with XCB support. |
228| BUILD_WSI_XLIB_SUPPORT | Linux | `ON` | Build the components with Xlib support. |
229| BUILD_WSI_WAYLAND_SUPPORT | Linux | `ON` | Build the components with Wayland support. |
230| USE_CCACHE | Linux | `OFF` | Enable caching with the CCache program. |
231
232The following is a table of all string options currently supported by this repository:
233
234| Option | Platform | Default | Description |
235| ------ | -------- | ------- | ----------- |
236| CMAKE_OSX_DEPLOYMENT_TARGET | MacOS | `10.12` | The minimum version of MacOS for loader deployment. |
237
238These variables should be set using the `-D` option when invoking CMake to
239generate the native platform files.
240
241## Building On Windows
242
243### Windows Development Environment Requirements
244
245- Windows
246  - Any Personal Computer version supported by Microsoft
247- Microsoft [Visual Studio](https://www.visualstudio.com/)
248  - Versions
249    - [2015](https://www.visualstudio.com/vs/older-downloads/)
250    - [2017](https://www.visualstudio.com/vs/downloads/)
251  - The Community Edition of each of the above versions is sufficient, as
252    well as any more capable edition.
253- [CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-win64-x64.zip) is recommended.
254  - Use the installer option to add CMake to the system PATH
255- Git Client Support
256  - [Git for Windows](http://git-scm.com/download/win) is a popular solution
257    for Windows
258  - Some IDEs (e.g., [Visual Studio](https://www.visualstudio.com/),
259    [GitHub Desktop](https://desktop.github.com/)) have integrated
260    Git client support
261
262### Windows Build - Microsoft Visual Studio
263
264The general approach is to run CMake to generate the Visual Studio project
265files. Then either run CMake with the `--build` option to build from the
266command line or use the Visual Studio IDE to open the generated solution and
267work with the solution interactively.
268
269#### Windows Quick Start
270
271    cd Vulkan-ValidationLayers
272    mkdir build
273    cd build
274    cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
275                 -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir ..
276    cmake --build .
277
278The above commands instruct CMake to find and use the default Visual Studio
279installation to generate a Visual Studio solution and projects for the x64
280architecture. The second CMake command builds the Debug (default)
281configuration of the solution.
282
283See below for the details.
284
285#### Use `CMake` to Create the Visual Studio Project Files
286
287Change your current directory to the top of the cloned repository directory,
288create a build directory and generate the Visual Studio project files:
289
290    cd Vulkan-ValidationLayers
291    mkdir build
292    cd build
293    cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
294                 -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir ..
295
296> Note: The `..` parameter tells `cmake` the location of the top of the
297> repository. If you place your build directory someplace else, you'll need to
298> specify the location of the repository top differently.
299
300The `-A` option is used to select either the "Win32" or "x64" architecture.
301
302If a generator for a specific version of Visual Studio is required, you can
303specify it for Visual Studio 2015, for example, with:
304
305    64-bit: -G "Visual Studio 14 2015 Win64"
306    32-bit: -G "Visual Studio 14 2015"
307
308See this [list](#cmake-visual-studio-generators) of other possible generators
309for Visual Studio.
310
311When generating the project files, the absolute path to a Vulkan-Headers
312install directory must be provided. This can be done by setting the
313`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the
314`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
315either case, the variable should point to the installation directory of a
316Vulkan-Headers repository built with the install target.
317
318When generating the project files, the absolute path to a glslang install
319directory must be provided. This can be done by setting the
320`GLSLANG_INSTALL_DIR` environment variable or by setting the
321`GLSLANG_INSTALL_DIR` CMake variable with the `-D` CMake option. In either
322case, the variable should point to the installation directory of a glslang
323repository built with the install target.
324
325The above steps create a Windows solution file named
326`Vulkan-ValidationLayers.sln` in the build directory.
327
328At this point, you can build the solution from the command line or open the
329generated solution with Visual Studio.
330
331#### Build the Solution From the Command Line
332
333While still in the build directory:
334
335    cmake --build .
336
337to build the Debug configuration (the default), or:
338
339    cmake --build . --config Release
340
341to make a Release build.
342
343#### Build the Solution With Visual Studio
344
345Launch Visual Studio and open the "Vulkan-ValidationLayers.sln" solution file
346in the build folder. You may select "Debug" or "Release" from the Solution
347Configurations drop-down list. Start a build by selecting the Build->Build
348Solution menu item.
349
350#### Windows Install Target
351
352The CMake project also generates an "install" target that you can use to copy
353the primary build artifacts to a specific location using a "bin, include, lib"
354style directory structure. This may be useful for collecting the artifacts and
355providing them to another project that is dependent on them.
356
357The default location is `$CMAKE_BINARY_DIR\install`, but can be changed with
358the `CMAKE_INSTALL_PREFIX` variable when first generating the project build
359files with CMake.
360
361You can build the install target from the command line with:
362
363    cmake --build . --config Release --target install
364
365or build the `INSTALL` target from the Visual Studio solution explorer.
366
367#### Using a Loader Built from a Repository
368
369If you do need to build and use your own loader, build the Vulkan-Loader
370repository with the install target and modify your CMake invocation to add the
371location of the loader's install directory:
372
373    cmake -A x64 -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
374                 -DVULKAN_LOADER_INSTALL_DIR=absolute_path_to_install_dir \
375                 -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir ..
376
377### Windows Tests and Demos
378
379After making any changes to the repository, you should perform some quick
380sanity tests, including the run_all_tests Powershell script. In addition,
381running sample applications such as the
382[vkcube demo](https://www.github.com/KhronosGroup/Vulkan-Tools.git)
383with validation enabled is advised.
384
385To run the validation test script, open a Powershell Console, change to the
386build/tests directory, and run:
387
388For Release builds:
389
390    .\run_all_tests.ps1
391
392For Debug builds:
393
394    .\run_all_tests.ps1 -Debug
395
396This script will run the following tests:
397
398- `vk_layer_validation_tests`:
399  Test Vulkan validation layers
400
401### Windows Notes
402
403#### CMake Visual Studio Generators
404
405The chosen generator should match one of the Visual Studio versions that you
406have installed. Generator strings that correspond to versions of Visual Studio
407include:
408
409| Build Platform               | 64-bit Generator              | 32-bit Generator        |
410|------------------------------|-------------------------------|-------------------------|
411| Microsoft Visual Studio 2015 | "Visual Studio 14 2015 Win64" | "Visual Studio 14 2015" |
412| Microsoft Visual Studio 2017 | "Visual Studio 15 2017 Win64" | "Visual Studio 15 2017" |
413
414#### Using The Vulkan Loader Library in this Repository on Windows
415
416Vulkan programs must be able to find and use the Vulkan loader
417(`vulkan-1.dll`) library as well as any other libraries the program requires.
418One convenient way to do this is to copy the required libraries into the same
419directory as the program. If you provided a loader repository location via the
420`VULKAN_LOADER_INSTALL_DIR` variable, the projects in this solution copy the
421Vulkan loader library and the "googletest" libraries to the
422`build\tests\Debug` or the `build\tests\Release` directory, which is where the
423test executables are found, depending on what configuration you built. (The
424layer validation tests use the "googletest" testing framework.)
425
426## Building On Linux
427
428### Linux Build Requirements
429
430This repository has been built and tested on the two most recent Ubuntu LTS
431versions. Currently, the oldest supported version is Ubuntu 16.04, meaning
432that the minimum officially supported C++11 compiler version is GCC 5.4.0,
433although earlier versions may work. It should be straightforward to adapt this
434repository to other Linux distributions.
435
436[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Linux-x86_64.tar.gz) is recommended.
437
438#### Required Package List
439
440    sudo apt-get install git build-essential libx11-xcb-dev \
441        libxkbcommon-dev libwayland-dev libxrandr-dev \
442        libegl1-mesa-dev
443
444### Linux Build
445
446The general approach is to run CMake to generate make files. Then either run
447CMake with the `--build` option or `make` to build from the command line.
448
449#### Linux Quick Start
450
451    cd Vulkan-ValidationLayers
452    mkdir build
453    cd build
454    cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
455          -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir ..
456    make
457
458See below for the details.
459
460#### Use CMake to Create the Make Files
461
462Change your current directory to the top of the cloned repository directory,
463create a build directory and generate the make files.
464
465    cd Vulkan-ValidationLayers
466    mkdir build
467    cd build
468    cmake -DCMAKE_BUILD_TYPE=Debug \
469          -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
470          -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \
471          -DCMAKE_INSTALL_PREFIX=install ..
472
473> Note: The `..` parameter tells `cmake` the location of the top of the
474> repository. If you place your `build` directory someplace else, you'll need
475> to specify the location of the repository top differently.
476
477Use `-DCMAKE_BUILD_TYPE` to specify a Debug or Release build.
478
479When generating the project files, the absolute path to a Vulkan-Headers
480install directory must be provided. This can be done by setting the
481`VULKAN_HEADERS_INSTALL_DIR` environment variable or by setting the
482`VULKAN_HEADERS_INSTALL_DIR` CMake variable with the `-D` CMake option. In
483either case, the variable should point to the installation directory of a
484Vulkan-Headers repository built with the install target.
485
486When generating the project files, the absolute path to a glslang install
487directory must be provided. This can be done by setting the
488`GLSLANG_INSTALL_DIR` environment variable or by setting the
489`GLSLANG_INSTALL_DIR` CMake variable with the `-D` CMake option. In either
490case, the variable should point to the installation directory of a glslang
491repository built with the install target.
492
493> Note: For Linux, the default value for `CMAKE_INSTALL_PREFIX` is
494> `/usr/local`, which would be used if you do not specify
495> `CMAKE_INSTALL_PREFIX`. In this case, you may need to use `sudo` to install
496> to system directories later when you run `make install`.
497
498#### Build the Project
499
500You can just run `make` to begin the build.
501
502To speed up the build on a multi-core machine, use the `-j` option for `make`
503to specify the number of cores to use for the build. For example:
504
505    make -j4
506
507You can also use
508
509    cmake --build .
510
511If your build system supports ccache, you can enable that via CMake option `-DUSE_CCACHE=On`
512
513### Linux Notes
514
515#### WSI Support Build Options
516
517By default, the repository components are built with support for the
518Vulkan-defined WSI display servers: Xcb, Xlib, and Wayland. It is recommended
519to build the repository components with support for these display servers to
520maximize their usability across Linux platforms. If it is necessary to build
521these modules without support for one of the display servers, the appropriate
522CMake option of the form `BUILD_WSI_xxx_SUPPORT` can be set to `OFF`.
523
524#### Linux Install to System Directories
525
526Installing the files resulting from your build to the systems directories is
527optional since environment variables can usually be used instead to locate the
528binaries. There are also risks with interfering with binaries installed by
529packages. If you are certain that you would like to install your binaries to
530system directories, you can proceed with these instructions.
531
532Assuming that you've built the code as described above and the current
533directory is still `build`, you can execute:
534
535    sudo make install
536
537This command installs files to `/usr/local` if no `CMAKE_INSTALL_PREFIX` is
538specified when creating the build files with CMake:
539
540- `/usr/local/lib`:  Vulkan layers shared objects
541- `/usr/local/share/vulkan/explicit_layer.d`:  Layer JSON files
542
543You may need to run `ldconfig` in order to refresh the system loader search
544cache on some Linux systems.
545
546You can further customize the installation location by setting additional
547CMake variables to override their defaults. For example, if you would like to
548install to `/tmp/build` instead of `/usr/local`, on your CMake command line
549specify:
550
551    -DCMAKE_INSTALL_PREFIX=/tmp/build
552
553Then run `make install` as before. The install step places the files in
554`/tmp/build`. This may be useful for collecting the artifacts and providing
555them to another project that is dependent on them.
556
557See the CMake documentation for more details on using these variables to
558further customize your installation.
559
560Also see the `LoaderAndLayerInterface` document in the `loader` folder of the
561Vulkan-Loader repository for more information about loader and layer
562operation.
563
564#### Linux Uninstall
565
566To uninstall the files from the system directories, you can execute:
567
568    sudo make uninstall
569
570#### Linux Tests
571
572To run the **validation test script**, in a terminal change to the build/tests directory and run:
573
574    VK_LAYER_PATH=../layers ./run_all_tests.sh
575
576This script will run the following tests:
577
578- `vk_layer_validation_tests`: Test Vulkan validation layers
579
580#### Linux 32-bit support
581
582Usage of this repository's contents in 32-bit Linux environments is not
583officially supported. However, since this repository is supported on 32-bit
584Windows, these modules should generally work on 32-bit Linux.
585
586Here are some notes for building 32-bit targets on a 64-bit Ubuntu "reference"
587platform:
588
589If not already installed, install the following 32-bit development libraries:
590
591`gcc-multilib g++-multilib libx11-dev:i386`
592
593This list may vary depending on your distribution and which windowing systems
594you are building for.
595
596Set up your environment for building 32-bit targets:
597
598    export ASFLAGS=--32
599    export CFLAGS=-m32
600    export CXXFLAGS=-m32
601    export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu
602
603Again, your PKG_CONFIG configuration may be different, depending on your distribution.
604
605Finally, rebuild the repository using `cmake` and `make`, as explained above.
606
607#### Using the new layers
608
609    export VK_LAYER_PATH=<path to your repository root>/build/layers
610
611You can run the `vkcube` or `vulkaninfo` applications from the Vulkan-Tools
612repository to see which driver, loader and layers are being used.
613
614## Building On Android
615
616Install the required tools for Linux and Windows covered above, then add the
617following.
618
619### Android Build Requirements
620
621Note that the minimum supported Android SDK API Level is 26, revision
622level 3.
623
624- Install [Android Studio 2.3](https://developer.android.com/studio/index.html)
625  or later.
626- From the "Welcome to Android Studio" splash screen, add the following
627  components using Configure > SDK Manager:
628  - SDK Platforms > Android 8.0.0 and newer
629  - SDK Tools > Android SDK Build-Tools
630  - SDK Tools > Android SDK Platform-Tools
631  - SDK Tools > Android SDK Tools
632  - SDK Tools > NDK
633
634#### Add Android specifics to environment
635
636For each of the below, you may need to specify a different build-tools
637version, as Android Studio will roll it forward fairly regularly.
638
639On Linux:
640
641    export ANDROID_SDK_HOME=$HOME/Android/sdk
642    export ANDROID_NDK_HOME=$HOME/Android/sdk/ndk-bundle
643    export PATH=$ANDROID_SDK_HOME:$PATH
644    export PATH=$ANDROID_NDK_HOME:$PATH
645    export PATH=$ANDROID_SDK_HOME/build-tools/26.0.3:$PATH
646
647On Windows:
648
649    set ANDROID_SDK_HOME=%LOCALAPPDATA%\Android\sdk
650    set ANDROID_NDK_HOME=%LOCALAPPDATA%\Android\sdk\ndk-bundle
651    set PATH=%LOCALAPPDATA%\Android\sdk\ndk-bundle;%PATH%
652
653On OSX:
654
655    export ANDROID_SDK_HOME=$HOME/Library/Android/sdk
656    export ANDROID_NDK_HOME=$HOME/Library/Android/sdk/ndk-bundle
657    export PATH=$ANDROID_NDK_PATH:$PATH
658    export PATH=$ANDROID_SDK_HOME/build-tools/26.0.3:$PATH
659
660Note: If `jarsigner` is missing from your platform, you can find it in the
661Android Studio install or in your Java installation. If you do not have Java,
662you can get it with something like the following:
663
664  sudo apt-get install openjdk-8-jdk
665
666#### Additional OSX System Requirements
667
668Tested on OSX version 10.13.3
669
670Setup Homebrew and components
671
672- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed.
673
674      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
675
676- Ensure Homebrew is at the beginning of your PATH:
677
678      export PATH=/usr/local/bin:$PATH
679
680- Add packages with the following:
681
682      brew install python
683
684### Android Build
685
686There are two options for building the Android layers. Either using the SPIRV
687tools provided as part of the Android NDK, or using upstream sources. To build
688with SPIRV tools from the NDK, remove the build-android/third_party directory
689created by running update_external_sources_android.sh, (or avoid running
690update_external_sources_android.sh). Use the following script to build
691everything in the repository for Android, including validation layers, tests,
692demos, and APK packaging: This script does retrieve and use the upstream SPRIV
693tools.
694
695    cd build-android
696    ./build_all.sh
697
698Resulting validation layer binaries will be in build-android/libs. Test and
699demo APKs can be installed on production devices with:
700
701    ./install_all.sh [-s <serial number>]
702
703Note that there are no equivalent scripts on Windows yet, that work needs to
704be completed. The following per platform commands can be used for layer only
705builds:
706
707#### Linux and OSX
708
709Follow the setup steps for Linux or OSX above, then from your terminal:
710
711    cd build-android
712    ./update_external_sources_android.sh --no-build
713    ndk-build -j4
714
715#### Windows
716
717Follow the setup steps for Windows above, then from Developer Command Prompt
718for VS2015:
719
720    cd build-android
721    update_external_sources_android.bat
722    ndk-build
723
724### Android Tests and Demos
725
726After making any changes to the repository you should perform some quick
727sanity tests, including the layer validation tests and the vkcube
728demo with validation enabled.
729
730#### Run Layer Validation Tests
731
732Use the following steps to build, install, and run the layer validation tests
733for Android:
734
735    cd build-android
736    ./build_all.sh
737    adb install -r bin/VulkanLayerValidationTests.apk
738    adb shell am start com.example.VulkanLayerValidationTests/android.app.NativeActivity
739
740Alternatively, you can use the test_APK script to install and run the layer
741validation tests:
742
743    test_APK.sh -s <serial number> -p <plaform name> -f <gtest_filter>
744
745## Building on MacOS
746
747### MacOS Build Requirements
748
749Tested on OSX version 10.12.6
750
751[CMake 3.10.2](https://cmake.org/files/v3.10/cmake-3.10.2-Darwin-x86_64.tar.gz) is recommended.
752
753Setup Homebrew and components
754
755- Follow instructions on [brew.sh](http://brew.sh) to get Homebrew installed.
756
757      /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
758
759- Ensure Homebrew is at the beginning of your PATH:
760
761      export PATH=/usr/local/bin:$PATH
762
763- Add packages with the following (may need refinement)
764
765      brew install python python3 git
766
767### Clone the Repository
768
769Clone the Vulkan-ValidationLayers repository:
770
771    git clone https://github.com/KhronosGroup/Vulkan-ValidationLayers.git
772
773### MacOS build
774
775#### CMake Generators
776
777This repository uses CMake to generate build or project files that are then
778used to build the repository. The CMake generators explicitly supported in
779this repository are:
780
781- Unix Makefiles
782- Xcode
783
784#### Building with the Unix Makefiles Generator
785
786This generator is the default generator, so all that is needed for a debug
787build is:
788
789    mkdir build
790    cd build
791    cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
792          -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \
793          -DCMAKE_BUILD_TYPE=Debug ..
794    make
795
796To speed up the build on a multi-core machine, use the `-j` option for `make`
797to specify the number of cores to use for the build. For example:
798
799    make -j4
800
801#### Building with the Xcode Generator
802
803To create and open an Xcode project:
804
805    mkdir build-xcode
806    cd build-xcode
807    cmake -DVULKAN_HEADERS_INSTALL_DIR=absolute_path_to_install_dir \
808          -DGLSLANG_INSTALL_DIR=absolute_path_to_install_dir \
809          -GXcode ..
810    open VULKAN.xcodeproj
811
812Within Xcode, you can select Debug or Release builds in the Build Settings of the project.
813
814#### Using the new layers on MacOS
815
816    export VK_LAYER_PATH=<path to your repository root>/build/layers
817
818You can run the `vulkaninfo` applications from the Vulkan-Tools repository to
819see which driver, loader and layers are being used.
820
821### MacOS Tests
822
823After making any changes to the repository, you should perform the included sanity tests by running
824the run_all_tests shell script.
825
826These test require a manual path to an ICD to run properly on MacOS.
827
828You can use:
829
830- MoltenVK ICD
831- Mock ICD
832
833#### Using MoltenVK ICD
834
835Clone and build the [MoltenVK](https://github.com/KhronosGroup/MoltenVK) repository.
836
837You will have to direct the loader from Vulkan-Loader to the MoltenVK ICD:
838
839    export VK_ICD_FILENAMES=<path to MoltenVK repository>/Package/Latest/MoltenVK/macOS/MoltenVK_icd.json
840
841#### Using Mock ICD
842
843Clone and build the [Vulkan-Tools](https://github.com/KhronosGroup/Vulkan-Tools) repository.
844
845You will have to direct the loader from Vulkan-Loader to the Mock ICD:
846
847    export VK_ICD_FILENAMES=<path to Vulkan-Tools repository>/build/icd/VkICD_mock_icd.json
848
849#### Running the Tests
850
851To run the **validation test script**, in a terminal change to the build/tests directory and run:
852
853    VK_LAYER_PATH=../layers ./run_all_tests.sh
854
855This script will run the following tests:
856
857- `vk_layer_validation_tests`: Test Vulkan validation layers
858
859Further testing and sanity checking can be achieved by running the vkcube and
860vulkaninfo applications in the
861[Vulkan-Tools](https://github.com/KhronosGroup/Vulkan-Tools)
862repository.
863
864Note that MoltenVK is still adding Vulkan features and some tests may fail.
865