| # Copyright 2019 The Dawn & Tint Authors |
| # |
| # Redistribution and use in source and binary forms, with or without |
| # modification, are permitted provided that the following conditions are met: |
| # |
| # 1. Redistributions of source code must retain the above copyright notice, this |
| # list of conditions and the following disclaimer. |
| # |
| # 2. Redistributions in binary form must reproduce the above copyright notice, |
| # this list of conditions and the following disclaimer in the documentation |
| # and/or other materials provided with the distribution. |
| # |
| # 3. Neither the name of the copyright holder nor the names of its |
| # contributors may be used to endorse or promote products derived from |
| # this software without specific prior written permission. |
| # |
| # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
| # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| |
| import("../../../scripts/dawn_overrides_with_defaults.gni") |
| |
| import("//build_overrides/build.gni") |
| import("${dawn_root}/generator/dawn_generator.gni") |
| import("${dawn_root}/scripts/dawn_features.gni") |
| |
| ############################################################################### |
| # Common dawn configs |
| ############################################################################### |
| |
| config("internal_config") { |
| configs = [ "${dawn_root}/src/utils:internal_config" ] |
| include_dirs = [ "${target_gen_dir}/../../../src" ] |
| |
| defines = [] |
| |
| if (dawn_enable_d3d11) { |
| defines += [ "DAWN_ENABLE_BACKEND_D3D11" ] |
| } |
| if (dawn_enable_d3d12) { |
| defines += [ "DAWN_ENABLE_BACKEND_D3D12" ] |
| } |
| if (dawn_enable_metal) { |
| defines += [ "DAWN_ENABLE_BACKEND_METAL" ] |
| } |
| if (dawn_enable_null) { |
| defines += [ "DAWN_ENABLE_BACKEND_NULL" ] |
| } |
| if (dawn_enable_webgpu_on_webgpu) { |
| defines += [ "DAWN_ENABLE_BACKEND_WEBGPU" ] |
| } |
| if (dawn_enable_opengl) { |
| defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ] |
| } |
| if (dawn_enable_desktop_gl) { |
| defines += [ "DAWN_ENABLE_BACKEND_DESKTOP_GL" ] |
| } |
| if (dawn_enable_opengles) { |
| defines += [ "DAWN_ENABLE_BACKEND_OPENGLES" ] |
| } |
| if (dawn_enable_vulkan) { |
| defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ] |
| } |
| |
| if (dawn_use_wayland) { |
| defines += [ "DAWN_USE_WAYLAND" ] |
| } |
| if (dawn_use_x11) { |
| defines += [ "DAWN_USE_X11" ] |
| } |
| if (dawn_use_windows_ui) { |
| defines += [ "DAWN_USE_WINDOWS_UI" ] |
| } |
| |
| if (dawn_supports_glfw_for_windowing) { |
| defines += [ "DAWN_SUPPORTS_GLFW_FOR_WINDOWING" ] |
| } |
| |
| if (dawn_enable_error_injection) { |
| defines += [ "DAWN_ENABLE_ERROR_INJECTION" ] |
| } |
| |
| if (dawn_force_system_component_load) { |
| defines += [ "DAWN_FORCE_SYSTEM_COMPONENT_LOAD" ] |
| } |
| |
| # Only internal Dawn targets can use this config, this means only targets in |
| # this BUILD.gn file and related subdirs. |
| visibility = [ "${dawn_root}/src/dawn/*" ] |
| |
| cflags = [] |
| |
| if (!is_clang && is_win) { |
| # Dawn extends wgpu enums with internal enums. |
| # MSVC considers these invalid switch values. crbug.com/dawn/397. |
| cflags += [ "/wd4063" ] |
| |
| # MSVC things that a switch over all the enum values of an enum class is not |
| # sufficient to cover all control paths. Turn off this warning so that the |
| # respective clang warning tells us where to add switch cases (otherwise we |
| # have to add default: DAWN_UNREACHABLE() that silences clang too) |
| cflags += [ "/wd4715" ] |
| |
| # MSVC needs a flag to enable a standard-compliant preprocessor. |
| cflags += [ "/Zc:preprocessor" ] |
| |
| if (dawn_is_winuwp) { |
| # /ZW makes sure we don't add calls that are forbidden in UWP. |
| # and /EHsc is required to be used in combination with it, |
| # even if it is already added by the windows GN defaults, |
| # we still add it to make every /ZW paired with a /EHsc |
| cflags_cc = [ |
| "/ZW:nostdlib", |
| "/EHsc", |
| ] |
| } |
| } |
| } |
| |
| ############################################################################### |
| # Common dawn library |
| ############################################################################### |
| |
| group("dawn_version_gen") { |
| public_deps = [ "${dawn_root}/src/dawn:dawn_version_gen" ] |
| } |
| |
| dawn_generator("dawn_gpu_info_gen") { |
| script = "${dawn_root}/generator/dawn_gpu_info_generator.py" |
| args = [ |
| "--gpu-info-json", |
| rebase_path("${dawn_root}/src/dawn/gpu_info.json", root_build_dir), |
| ] |
| outputs = [ |
| "src/dawn/common/GPUInfo_autogen.h", |
| "src/dawn/common/GPUInfo_autogen.cpp", |
| ] |
| inputs = [ |
| "${dawn_root}/src/dawn/gpu_info.json", |
| "${dawn_root}/generator/templates/dawn/common/GPUInfo.h", |
| "${dawn_root}/generator/templates/dawn/common/GPUInfo.cpp", |
| ] |
| } |
| |
| # This GN file is discovered by all Chromium builds, but common doesn't support |
| # all of Chromium's OSes so we explicitly make the target visible only on |
| # systems we know Dawn is able to compile on. |
| if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android || |
| is_ios || is_wasm) { |
| static_library("common") { |
| sources = [ |
| "Algebra.h", |
| "AlignedAlloc.cpp", |
| "AlignedAlloc.h", |
| "Atomic.h", |
| "BitSetRangeIterator.h", |
| "ColorSpace.h", |
| "Compiler.h", |
| "Constants.h", |
| "ContentLessObjectCache.h", |
| "ContentLessObjectCacheable.h", |
| "CoreFoundationRef.h", |
| "Defer.cpp", |
| "Defer.h", |
| "DynamicLib.cpp", |
| "DynamicLib.h", |
| "Enumerator.h", |
| "FutureUtils.cpp", |
| "FutureUtils.h", |
| "GPUInfo.cpp", |
| "GPUInfo.h", |
| "HashUtils.h", |
| "IOKitRef.h", |
| "LRUCache.h", |
| "LinkedList.h", |
| "MatchVariant.h", |
| "Math.cpp", |
| "Math.h", |
| "Mutex.h", |
| "MutexProtected.h", |
| "NSRef.h", |
| "Numeric.h", |
| "PlacementAllocated.h", |
| "Preprocessor.h", |
| "Range.h", |
| "Ref.h", |
| "RefBase.h", |
| "RefCounted.cpp", |
| "RefCounted.h", |
| "RefCountedWithExternalCount.h", |
| "Result.cpp", |
| "Result.h", |
| "SerialMap.h", |
| "SerialQueue.h", |
| "SerialStorage.h", |
| "Sha3.cpp", |
| "Sha3.h", |
| "SlabAllocator.cpp", |
| "SlabAllocator.h", |
| "StackAllocated.h", |
| "StringViewUtils.cpp", |
| "StringViewUtils.h", |
| "Strings.h", |
| "SystemUtils.cpp", |
| "SystemUtils.h", |
| "ThreadLocal.cpp", |
| "ThreadLocal.h", |
| "Time.h", |
| "TypeTraits.h", |
| "WGSLFeatureMapping.h", |
| "WeakRef.h", |
| "WeakRefSupport.cpp", |
| "WeakRefSupport.h", |
| "egl_platform.h", |
| "ityp_array.h", |
| "ityp_bitset.h", |
| "ityp_stack_vec.h", |
| "ityp_vector.h", |
| "vulkan_platform.h", |
| "xlib_with_undefs.h", |
| ] |
| sources += get_target_outputs(":dawn_gpu_info_gen") |
| |
| if (!is_wasm) { |
| sources += [ |
| "ExternalTextureParams.cpp", |
| "ExternalTextureParams.h", |
| "WGPUDeviceCallbackInfos.cpp", |
| "WGPUDeviceCallbackInfos.h", |
| ] |
| } |
| |
| public_deps = [ |
| ":dawn_gpu_info_gen", |
| ":dawn_version_gen", |
| "${dawn_abseil_dir}:absl", |
| "${dawn_root}/src/dawn/partition_alloc:raw_ptr", |
| "${dawn_root}/src/utils", |
| ] |
| |
| if (is_apple) { |
| sources += [ |
| "IOSurfaceUtils.cpp", |
| "IOSurfaceUtils.h", |
| ] |
| } |
| |
| if (is_mac) { |
| sources += [ "SystemUtils_mac.mm" ] |
| } |
| |
| # Note that while this doesn't make `internal_config` a public config of |
| # Dawn libraries because `:common` is only used as a private deps of Dawn |
| # targets, so `internal_config` doesn't leak out of Dawn. |
| public_configs = [ ":internal_config" ] |
| deps = [ "${dawn_root}/include/dawn:cpp_headers" ] |
| |
| if (is_win) { |
| sources += [ |
| "WindowsUtils.cpp", |
| "WindowsUtils.h", |
| ] |
| } |
| if (dawn_enable_vulkan) { |
| public_deps += [ "${dawn_vulkan_headers_dir}:vulkan_headers" ] |
| } |
| if (is_android) { |
| libs = [ "log" ] |
| } |
| } |
| } |