• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 The Dawn Authors
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import("../../scripts/dawn_overrides_with_defaults.gni")
16
17import("${skia_root_dir}/build_overrides/build.gni")
18import("${dawn_root}/scripts/dawn_features.gni")
19
20# Use Chromium's dcheck_always_on when available so that we respect it when
21# running tests on the GPU builders
22if (build_with_chromium) {
23  import("${skia_root_dir}/build/config/dcheck_always_on.gni")
24} else {
25  dcheck_always_on = false
26}
27
28if (build_with_chromium) {
29  import("${skia_root_dir}/build/config/sanitizers/sanitizers.gni")
30} else {
31  use_fuzzing_engine = false
32}
33
34###############################################################################
35# Common dawn configs
36###############################################################################
37
38config("dawn_public_include_dirs") {
39  include_dirs = [
40    "${target_gen_dir}/../../src/include",
41    "${dawn_root}/src/include",
42  ]
43}
44
45config("dawn_internal") {
46  include_dirs = [
47    "${target_gen_dir}/../../src",
48    "${dawn_root}/src",
49  ]
50
51  defines = []
52  if (dawn_always_assert || dcheck_always_on || is_debug ||
53      use_fuzzing_engine) {
54    defines += [ "DAWN_ENABLE_ASSERTS" ]
55  }
56
57  if (use_fuzzing_engine) {
58    # Does a hard abort when an assertion fails so that fuzzers catch and parse the failure.
59    defines += [ "DAWN_ABORT_ON_ASSERT" ]
60  }
61
62  if (dawn_enable_d3d12) {
63    defines += [ "DAWN_ENABLE_BACKEND_D3D12" ]
64  }
65  if (dawn_enable_metal) {
66    defines += [ "DAWN_ENABLE_BACKEND_METAL" ]
67  }
68  if (dawn_enable_null) {
69    defines += [ "DAWN_ENABLE_BACKEND_NULL" ]
70  }
71  if (dawn_enable_opengl) {
72    defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ]
73  }
74  if (dawn_enable_desktop_gl) {
75    defines += [ "DAWN_ENABLE_BACKEND_DESKTOP_GL" ]
76  }
77  if (dawn_enable_opengles) {
78    defines += [ "DAWN_ENABLE_BACKEND_OPENGLES" ]
79  }
80  if (dawn_enable_vulkan) {
81    defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ]
82  }
83
84  if (dawn_use_x11) {
85    defines += [ "DAWN_USE_X11" ]
86  }
87
88  if (dawn_enable_error_injection) {
89    defines += [ "DAWN_ENABLE_ERROR_INJECTION" ]
90  }
91
92  # Only internal Dawn targets can use this config, this means only targets in
93  # this BUILD.gn file and related subdirs.
94  visibility = [ "../*" ]
95
96  cflags = []
97  if (is_clang) {
98    cflags += [ "-Wno-shadow" ]
99  }
100
101  # Enable more warnings that were found when using Dawn in other projects.
102  # Add them only when building in standalone because we control which clang
103  # version we use. Otherwise we risk breaking projects depending on Dawn when
104  # the use a different clang version.
105  if (dawn_standalone && is_clang) {
106    cflags += [
107      "-Wconditional-uninitialized",
108      "-Wcstring-format-directive",
109      "-Wc++11-narrowing",
110      "-Wdeprecated-copy",
111      "-Wdeprecated-copy-dtor",
112      "-Wduplicate-enum",
113      "-Wextra-semi-stmt",
114      "-Wimplicit-fallthrough",
115      "-Winconsistent-missing-destructor-override",
116      "-Winvalid-offsetof",
117      "-Wmissing-field-initializers",
118      "-Wnon-c-typedef-for-linkage",
119      "-Wpessimizing-move",
120      "-Wrange-loop-analysis",
121      "-Wredundant-move",
122      "-Wshadow-field",
123      "-Wstrict-prototypes",
124      "-Wtautological-unsigned-zero-compare",
125      "-Wunreachable-code-aggressive",
126      "-Wunused-but-set-variable",
127    ]
128
129    if (is_win) {
130      cflags += [
131        # clang-cl doesn't know -pedantic, pass it explicitly to the clang driver
132        "/clang:-pedantic",
133
134        # Allow the use of __uuidof()
135        "-Wno-language-extension-token",
136      ]
137    } else {
138      cflags += [ "-pedantic" ]
139    }
140  }
141
142  if (!is_clang && is_win) {
143    # Dawn extends wgpu enums with internal enums.
144    # MSVC considers these invalid switch values. crbug.com/dawn/397.
145    cflags += [ "/wd4063" ]
146    if (dawn_is_winuwp) {
147      # /ZW makes sure we don't add calls that are forbidden in UWP.
148      # and /EHsc is required to be used in combination with it,
149      # even if it is already added by the windows GN defaults,
150      # we still add it to make every /ZW paired with a /EHsc
151      cflags_cc = [
152        "/ZW:nostdlib",
153        "/EHsc",
154      ]
155    }
156  }
157}
158
159###############################################################################
160# Common dawn library
161###############################################################################
162
163# This GN file is discovered by all Chromium builds, but common doesn't support
164# all of Chromium's OSes so we explicitly make the target visible only on
165# systems we know Dawn is able to compile on.
166if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
167  static_library("common") {
168    sources = [
169      "Alloc.h",
170      "Assert.cpp",
171      "Assert.h",
172      "BitSetIterator.h",
173      "Compiler.h",
174      "ConcurrentCache.h",
175      "Constants.h",
176      "CoreFoundationRef.h",
177      "DynamicLib.cpp",
178      "DynamicLib.h",
179      "GPUInfo.cpp",
180      "GPUInfo.h",
181      "HashUtils.h",
182      "IOKitRef.h",
183      "LinkedList.h",
184      "Log.cpp",
185      "Log.h",
186      "Math.cpp",
187      "Math.h",
188      "NSRef.h",
189      "NonCopyable.h",
190      "PlacementAllocated.h",
191      "Platform.h",
192      "Preprocessor.h",
193      "RefBase.h",
194      "RefCounted.cpp",
195      "RefCounted.h",
196      "Result.cpp",
197      "Result.h",
198      "SerialMap.h",
199      "SerialQueue.h",
200      "SerialStorage.h",
201      "SlabAllocator.cpp",
202      "SlabAllocator.h",
203      "StackContainer.h",
204      "SwapChainUtils.h",
205      "SystemUtils.cpp",
206      "SystemUtils.h",
207      "TypeTraits.h",
208      "TypedInteger.h",
209      "UnderlyingType.h",
210      "ityp_array.h",
211      "ityp_bitset.h",
212      "ityp_span.h",
213      "ityp_stack_vec.h",
214      "ityp_vector.h",
215      "vulkan_platform.h",
216      "xlib_with_undefs.h",
217    ]
218
219    if (is_mac) {
220      sources += [ "SystemUtils_mac.mm" ]
221    }
222
223    public_configs = [ ":dawn_internal" ]
224    deps = [
225      "${dawn_root}/src/dawn:dawn_headers",
226      "${dawn_root}/src/dawn:dawncpp_headers",
227    ]
228
229    if (is_win) {
230      sources += [
231        "WindowsUtils.cpp",
232        "WindowsUtils.h",
233        "windows_with_undefs.h",
234      ]
235    }
236    if (dawn_enable_vulkan) {
237      public_deps = [ "${dawn_root}/third_party/khronos:vulkan_headers" ]
238    }
239    if (is_android) {
240      libs = [ "log" ]
241    }
242  }
243}
244