# Copyright 2020 The Dawn Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. import("../../scripts/dawn_overrides_with_defaults.gni") import("${dawn_root}/scripts/dawn_features.gni") ############################################################################### # GLFW wrapping target ############################################################################### # GLFW does not support ChromeOS, Android or Fuchsia, so provide a small mock # library that can be linked into the Dawn tests on these platforms. Otherwise, # use the real library from third_party/. if (dawn_supports_glfw_for_windowing) { group("dawn_glfw") { public_deps = [ "${dawn_root}/third_party/gn/glfw" ] } } else if (is_fuchsia) { # The mock implementation of GLFW on Fuchsia config("dawn_glfw_public_config") { # Allow inclusion of include_dirs = [ "${dawn_glfw_dir}/include" ] # The GLFW/glfw3.h header includes by default, but the latter # does not exist on Fuchsia. Defining GLFW_INCLUDE_NONE helps work around # the issue, but it needs to be defined for any file that includes the # header. defines = [ "GLFW_INCLUDE_NONE", "GLFW_INCLUDE_VULKAN", ] } static_library("dawn_glfw") { sources = [ # NOTE: The header below is required to pass "gn check". "${dawn_glfw_dir}/include/GLFW/glfw3.h", "Glfw3Fuchsia.cpp", ] public_configs = [ ":dawn_glfw_public_config" ] deps = [ "${dawn_root}/src/common" ] } } else { # Just skip GLFW on other systems group("dawn_glfw") { } } ############################################################################### # Utils for tests and samples ############################################################################### static_library("dawn_utils") { configs += [ "${dawn_root}/src/common:dawn_internal" ] sources = [ "ComboRenderBundleEncoderDescriptor.cpp", "ComboRenderBundleEncoderDescriptor.h", "ComboRenderPipelineDescriptor.cpp", "ComboRenderPipelineDescriptor.h", "PlatformDebugLogger.h", "SystemUtils.cpp", "SystemUtils.h", "TerribleCommandBuffer.cpp", "TerribleCommandBuffer.h", "TestUtils.cpp", "TestUtils.h", "TextureFormatUtils.cpp", "TextureFormatUtils.h", "Timer.h", "WGPUHelpers.cpp", "WGPUHelpers.h", "WireHelper.cpp", "WireHelper.h", ] deps = [ "${dawn_root}/src/common", "${dawn_root}/src/dawn:dawn_proc", "${dawn_root}/src/dawn_native:dawn_native_headers", "${dawn_root}/src/dawn_wire", "${dawn_shaderc_dir}:libshaderc", ] libs = [] frameworks = [] if (is_win) { sources += [ "WindowsDebugLogger.cpp" ] } else { sources += [ "EmptyDebugLogger.cpp" ] } if (is_win) { sources += [ "WindowsTimer.cpp" ] } else if (is_mac) { sources += [ "OSXTimer.cpp", "ObjCUtils.h", "ObjCUtils.mm", ] frameworks += [ "QuartzCore.framework" ] } else { sources += [ "PosixTimer.cpp" ] } if (dawn_supports_glfw_for_windowing) { sources += [ "GLFWUtils.cpp", "GLFWUtils.h", ] deps += [ ":dawn_glfw" ] if (dawn_enable_metal) { sources += [ "GLFWUtils_metal.mm" ] frameworks += [ "Metal.framework" ] } } public_deps = [ "${dawn_root}/src/dawn:dawncpp_headers" ] } ############################################################################### # Dawn samples, only in standalone builds ############################################################################### if (dawn_standalone) { # Library to handle the interaction of Dawn with GLFW windows in samples static_library("dawn_bindings") { configs += [ "${dawn_root}/src/common:dawn_internal" ] sources = [ "BackendBinding.cpp", "BackendBinding.h", ] public_deps = [ "${dawn_root}/src/dawn:dawn_headers" ] deps = [ ":dawn_glfw", "${dawn_root}/src/common", "${dawn_root}/src/dawn_native", ] libs = [] frameworks = [] if (dawn_enable_d3d12) { sources += [ "D3D12Binding.cpp" ] } if (dawn_enable_metal) { sources += [ "MetalBinding.mm" ] frameworks += [ "Metal.framework", "QuartzCore.framework", ] # Suppress warnings that Metal isn't in the deployment target of Chrome if (is_mac) { cflags_objcc = [ "-Wno-unguarded-availability" ] } } if (dawn_enable_null) { sources += [ "NullBinding.cpp" ] } if (dawn_enable_opengl) { sources += [ "OpenGLBinding.cpp" ] } if (dawn_enable_vulkan) { sources += [ "VulkanBinding.cpp" ] } } }