vulkaninfo: WIP: Modified for use from iOS
[platform/upstream/Vulkan-Tools.git] / BUILD.gn
1 # Copyright (C) 2018-2019 The ANGLE Project Authors.
2 # Copyright (C) 2019 LunarG, Inc.
3 #
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
7 #
8 #     https://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 import("//build_overrides/vulkan_tools.gni")
17
18 # Vulkan-tools isn't ported to Fuchsia yet.
19 # TODO(spang): Port mock ICD to Fuchsia.
20 assert(!is_fuchsia)
21
22 vulkan_undefine_configs = []
23 if (is_win) {
24   vulkan_undefine_configs += [
25     "//build/config/win:nominmax",
26     "//build/config/win:unicode",
27   ]
28 }
29
30 raw_vulkan_icd_dir = rebase_path("icd", root_build_dir)
31
32 vulkan_data_dir = "$root_out_dir/$vulkan_data_subdir"
33 raw_vulkan_data_dir = rebase_path(vulkan_data_dir, root_build_dir)
34
35 config("vulkan_internal_config") {
36   defines = [ "VULKAN_NON_CMAKE_BUILD" ]
37   if (is_clang || !is_win) {
38     cflags = [ "-Wno-unused-function" ]
39   }
40   if (is_linux) {
41     defines += [
42       "SYSCONFDIR=\"/etc\"",
43       "FALLBACK_CONFIG_DIRS=\"/etc/xdg\"",
44       "FALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"",
45     ]
46   }
47 }
48
49 if (!is_android) {
50   # Vulkan Mock ICD
51   # ---------------
52   shared_library("VkICD_mock_icd") {
53     configs -= vulkan_undefine_configs
54     public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
55     data_deps = [ ":vulkan_gen_icd_json_file" ]
56     sources = [
57       "icd/generated/mock_icd.cpp",
58       "icd/generated/mock_icd.h",
59       "icd/generated/vk_typemap_helper.h",
60     ]
61     if (is_win) {
62       sources += [ "icd/VkICD_mock_icd.def" ]
63     }
64     configs -= [ "//build/config/compiler:chromium_code" ]
65     configs += [ "//build/config/compiler:no_chromium_code" ]
66   }
67
68   action("vulkan_gen_icd_json_file") {
69     script = "build-gn/generate_vulkan_layers_json.py"
70     public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
71     sources = [ "$vulkan_headers_dir/include/vulkan/vulkan_core.h" ]
72     args = [ "--icd" ]
73     if (is_win) {
74       sources += [ "icd/windows/VkICD_mock_icd.json" ]
75       args += [ "$raw_vulkan_icd_dir/windows" ]
76     }
77     if (is_linux) {
78       sources += [ "icd/linux/VkICD_mock_icd.json" ]
79       args += [ "$raw_vulkan_icd_dir/linux" ]
80     }
81     if (is_mac) {
82       sources += [ "icd/macos/VkICD_mock_icd.json" ]
83       args += [ "$raw_vulkan_icd_dir/macos" ]
84     }
85
86     # The layer JSON files are part of the necessary data deps.
87     outputs = [ "$vulkan_data_dir/VkICD_mock_icd.json" ]
88     data = outputs
89     args += [ raw_vulkan_data_dir ] + rebase_path(sources, root_build_dir)
90   }
91 }