• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16import("//build_overrides/build.gni")
17import("//build_overrides/vulkan_loader.gni")
18
19declare_args() {
20  custom_vulkan_loader_library_name = ""
21}
22
23if (is_fuchsia) {
24  import("//build/cpp/sdk_shared_library.gni")
25  import("//build/sdk/sdk_documentation.gni")
26}
27
28if (!is_android) {
29  vulkan_undefine_configs = []
30}
31if (is_win) {
32  vulkan_undefine_configs += [
33    "//build/config/win:nominmax",
34    "//build/config/win:unicode",
35  ]
36}
37
38config("vulkan_internal_config") {
39  defines = [
40    "VK_ENABLE_BETA_EXTENSIONS",
41  ]
42  if (is_clang || !is_win) {
43    cflags = [
44      "-Wno-conversion",
45      "-Wno-extra-semi",
46      "-Wno-implicit-fallthrough",
47      "-Wno-sign-compare",
48      "-Wno-unreachable-code",
49      "-Wno-unused-function",
50      "-Wno-unused-variable",
51    ]
52  }
53  if (is_fuchsia) {
54    defines += [
55      "SYSCONFDIR=\"/config\"",
56      "EXTRASYSCONFDIR=\"/pkg/data\"",
57    ]
58  }
59  if (is_linux || is_chromeos || is_mac) {
60    defines += [
61      "SYSCONFDIR=\"/etc\"",
62      "FALLBACK_CONFIG_DIRS=\"/etc/xdg\"",
63      "FALLBACK_DATA_DIRS=\"/usr/local/share:/usr/share\"",
64    ]
65  }
66}
67
68# Vulkan loader
69# -------------
70
71config("vulkan_loader_config") {
72  include_dirs = [
73    "loader/generated",
74    "loader",
75  ]
76  defines = [
77    "API_NAME=\"Vulkan\"",
78    "USE_UNSAFE_FILE_SEARCH=1",
79  ]
80
81  if (is_win) {
82    cflags = [ "/wd4201" ]
83  }
84  if (is_linux || is_chromeos) {
85    # assume secure_getenv() is available
86    defines += [
87      "HAVE_SECURE_GETENV",
88      "LOADER_ENABLE_LINUX_SORT",
89    ]
90  }
91}
92
93if (!is_android) {
94  if (is_fuchsia) {
95    library_type = "sdk_shared_library"
96  } else if (vulkan_loader_shared) {
97    library_type = "shared_library"
98  } else {
99    library_type = "static_library"
100  }
101
102  target(library_type, "libvulkan") {
103    sources = [
104      "loader/adapters.h",
105      "loader/allocation.c",
106      "loader/allocation.h",
107      "loader/asm_offset.c",
108      "loader/cJSON.c",
109      "loader/cJSON.h",
110      "loader/debug_utils.c",
111      "loader/debug_utils.h",
112      "loader/dev_ext_trampoline.c",
113      "loader/extension_manual.c",
114      "loader/extension_manual.h",
115      "loader/get_environment.c",
116      "loader/get_environment.h",
117      "loader/generated/vk_layer_dispatch_table.h",
118      "loader/generated/vk_loader_extensions.h",
119      "loader/generated/vk_object_types.h",
120      "loader/gpa_helper.h",
121      "loader/gpa_helper.c",
122      "loader/loader_common.h",
123      "loader/loader.c",
124      "loader/loader.h",
125      "loader/log.c",
126      "loader/log.h",
127      "loader/phys_dev_ext.c",
128      "loader/stack_allocation.h",
129      "loader/terminator.c",
130      "loader/trampoline.c",
131      "loader/unknown_function_handling.h",
132      "loader/unknown_function_handling.c",
133      "loader/vk_loader_layer.h",
134
135      # TODO(jmadill): Use assembler where available.
136      "loader/unknown_ext_chain.c",
137      "loader/vk_loader_platform.h",
138      "loader/wsi.c",
139      "loader/wsi.h",
140    ]
141
142    if (custom_vulkan_loader_library_name != "") {
143      output_name = custom_vulkan_loader_library_name
144    } else {
145      if (is_win) {
146        output_name = "vulkan-1"
147      } else {
148        output_name = "vulkan"
149
150        # Create libvulkan.so.1 on Linux instead of libvulkan.so
151        if ((is_linux || is_chromeos) && vulkan_loader_shared) {
152          output_extension = "so.1"
153        }
154      }
155    }
156
157    if (is_win) {
158      sources += [
159        "loader/dirent_on_windows.c",
160        "loader/dirent_on_windows.h",
161        "loader/loader_windows.c",
162        "loader/loader_windows.h",
163        "loader/loader.rc",
164        "loader/vulkan-1.def",
165      ]
166      if (!is_clang) {
167        cflags = [
168          "/wd4054",  # Type cast from function pointer
169          "/wd4055",  # Type cast from data pointer
170          "/wd4100",  # Unreferenced formal parameter
171          "/wd4152",  # Nonstandard extension used (pointer conversion)
172          "/wd4201",  # Nonstandard extension used: nameless struct/union
173          "/wd4214",  # Nonstandard extension used: bit field types other than
174                      # int
175          "/wd4232",  # Nonstandard extension used: address of dllimport is not
176                      # static
177          "/wd4305",  # Type cast truncation
178          "/wd4706",  # Assignment within conditional expression
179          "/wd4996",  # Unsafe stdlib function
180        ]
181      }
182      if (is_clang) {
183        cflags = [ "-Wno-incompatible-pointer-types" ]
184      }
185      libs = [ "Cfgmgr32.lib" ]
186    }
187    if (is_linux || is_chromeos) {
188      sources += [
189        "loader/loader_linux.c",
190        "loader/loader_linux.h",
191      ]
192    }
193    if (is_mac) {
194      frameworks = [ "CoreFoundation.framework" ]
195    }
196    public_deps = [ "$vulkan_headers_dir:vulkan_headers" ]
197    configs -= [ "//build/config/compiler:chromium_code" ]
198    configs += [ "//build/config/compiler:no_chromium_code" ]
199    configs += [ ":vulkan_internal_config" ]
200    public_configs = [ ":vulkan_loader_config" ]
201    configs -= vulkan_undefine_configs
202
203    if (is_fuchsia) {
204      category = "partner"
205
206      # The Vulkan loader's interface is defined by standard Khronos vulkan headers
207      # which can be obtained separately from the loader implementation itself.
208      no_headers = true
209
210      deps = [
211        ":dlopen_fuchsia",
212        "//sdk/lib/fdio",
213      ]
214
215      runtime_deps = [ "//sdk/lib/fdio:fdio_sdk" ]
216    }
217  }
218}
219
220if (is_fuchsia) {
221  config("fuchsia_config") {
222    include_dirs = [ "fuchsia" ]
223  }
224
225  source_set("dlopen_fuchsia") {
226    public_configs = [ ":fuchsia_config" ]
227
228    sources = [
229      "fuchsia/dlopen_fuchsia.c",
230      "fuchsia/dlopen_fuchsia.h",
231    ]
232
233    deps = [
234      "//sdk/fidl/fuchsia.vulkan.loader:fuchsia.vulkan.loader_c_client",
235      "//sdk/lib/fdio",
236    ]
237  }
238
239  sdk_documentation("vulkan_license") {
240    name = "vulkan_license"
241    category = "public"
242
243    files = [
244      {
245        source = "LICENSE.txt"
246        dest = "LICENSE.vulkan"
247      },
248    ]
249  }
250}
251