From 21a23857dce8b2ccef5326ee10d2db64c4b16019 Mon Sep 17 00:00:00 2001 From: Corentin Wallez Date: Tue, 31 Jul 2018 18:50:03 +0200 Subject: [PATCH] Add initial BUILD.gn files for libdawn[|_native|_wire] --- .gitignore | 10 + .gn | 21 + BUILD.gn | 648 ++++++++++++++++++ DEPS | 154 +++++ build_overrides/build.gni | 27 + build_overrides/dawn.gni | 19 + generator/templates/dawn_native/ProcTable.cpp | 5 +- src/Empty.cpp | 16 + 8 files changed, 898 insertions(+), 2 deletions(-) create mode 100644 .gn create mode 100644 BUILD.gn create mode 100644 DEPS create mode 100644 build_overrides/build.gni create mode 100644 build_overrides/dawn.gni create mode 100644 src/Empty.cpp diff --git a/.gitignore b/.gitignore index e492566c19..15e4d574a4 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,16 @@ x86 x64 +# Directories added by the standalone GN build +.gclient +.gclient_entries +build +buildtools +testing +third_party/llvm-build +tools +out + # Modified from https://www.gitignore.io/api/vim,macos,linux,emacs,cmake,windows,sublimetext,visualstudio,visualstudiocode ### CMake ### diff --git a/.gn b/.gn new file mode 100644 index 0000000000..84eeec7d8e --- /dev/null +++ b/.gn @@ -0,0 +1,21 @@ +# Copyright 2018 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. + +buildconfig = "//build/config/BUILDCONFIG.gn" + +default_args = { + use_custom_libcxx = false + clang_use_chrome_plugins = false + use_sysroot = true +} diff --git a/BUILD.gn b/BUILD.gn new file mode 100644 index 0000000000..db9bd4a0d6 --- /dev/null +++ b/BUILD.gn @@ -0,0 +1,648 @@ +# Copyright 2018 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("//build_overrides/dawn.gni") + +declare_args() { + # Enable Dawn's ASSERTs even in release builds + dawn_always_assert = false + + # Enables the compilation of Dawn's D3D12 backend + dawn_enable_d3d12 = is_win + + # Enables the compilation of Dawn's Metal backend + dawn_enable_metal = is_mac + + # Enables the compilation of Dawn's Null backend + # (required for unittests, obviously non-conformant) + dawn_enable_null = true + + # Enables the compilation of Dawn's OpenGL backend + # (best effort, non-conformant) + dawn_enable_opengl = is_linux + + # Enables the compilation of Dawn's Vulkan backend + dawn_enable_vulkan = is_linux || is_win +} + +############################################################################### +# template to wrap the Dawn code generator +############################################################################### + +template("dawn_generator") { + generator = "generator/main.py" + json = "dawn.json" + template_dir = "generator/templates" + + target = invoker.target + + common_args = [ + rebase_path(json, root_build_dir), + "-t", + rebase_path(template_dir, root_build_dir), + "-o", + rebase_path(target_gen_dir, root_build_dir), + "-T", + target, + ] + + # TODO(cwallez@chromium.org): Use depfile instead of this exec_script + script_inputs = exec_script(generator, + common_args + [ + "--print-dependencies", + "--gn", + ], + "list lines", + [ json ]) + + # Gather the outputs of the code generator for this target. + script_outputs = exec_script(generator, + common_args + [ + "--print-outputs", + "--gn", + ], + "list lines", + [ json ]) + + rebased_outputs = [] + foreach(path, script_outputs) { + rebased_outputs += + [ root_build_dir + "/" + rebase_path(path, root_build_dir) ] + } + + # Make an action to execute the code generator + action(target_name + "_gen") { + script = generator + inputs = script_inputs + outputs = rebased_outputs + args = common_args + } + + if (defined(invoker.target_type)) { + # Make a target with a custom target_type that will contain the outputs of + # the code generator in sources. + target(invoker.target_type, target_name) { + deps = [ ":" + target_name + "_gen" ] + sources = script_outputs + + # Forward variables from the invoker. deps, configs and source are + # special cased because the invoker's must be added to the lists already + # present in this target + forward_variables_from(invoker, + "*", + [ + "deps", + "target", + "configs", + "sources", + ]) + + if (defined(invoker.deps)) { + deps += invoker.deps + } + if (defined(invoker.sources)) { + sources += invoker.sources + } + if (defined(invoker.configs)) { + configs += invoker.configs + } + } + } +} + +############################################################################### +# Dawn headers and libdawn.so +############################################################################### + +config("libdawn_public") { + include_dirs = [ + target_gen_dir, + "src/include", + ] +} + +dawn_generator("dawn_headers") { + target = "dawn_headers" + target_type = "source_set" + + public_configs = [ ":libdawn_public" ] +} + +dawn_generator("libdawn") { + target = "libdawn" + target_type = "shared_library" + + defines = [ "DAWN_IMPLEMENTATION" ] + sources = [ + "src/include/dawn/EnumClassBitmasks.h", + "src/include/dawn/dawn_export.h", + "src/include/dawn/dawn_wsi.h", + ] + + public_deps = [ + ":dawn_headers", + ] +} + +############################################################################### +# Common dawn libraries and configs +############################################################################### + +config("dawn_internal") { + include_dirs = [ "src" ] + + defines = [] + if (dawn_always_assert || is_debug) { + defines += [ "DAWN_ENABLE_ASSERTS" ] + } + + 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_opengl) { + defines += [ "DAWN_ENABLE_BACKEND_OPENGL" ] + } + if (dawn_enable_vulkan) { + defines += [ "DAWN_ENABLE_BACKEND_VULKAN" ] + } + + configs = [ ":libdawn_public" ] +} + +static_library("dawn_common") { + sources = [ + "src/common/Assert.cpp", + "src/common/Assert.h", + "src/common/BitSetIterator.h", + "src/common/Compiler.h", + "src/common/DynamicLib.cpp", + "src/common/DynamicLib.h", + "src/common/HashUtils.h", + "src/common/Math.cpp", + "src/common/Math.h", + "src/common/Platform.h", + "src/common/Result.h", + "src/common/Serial.h", + "src/common/SerialQueue.h", + "src/common/SwapChainUtils.h", + "src/common/vulkan_platform.h", + "src/common/windows_with_undefs.h", + ] + + configs += [ ":dawn_internal" ] +} + +############################################################################### +# Third-party dependencies needed by libdawn_native +############################################################################### + +config("glad_public") { + include_dirs = [ "third_party/glad/include" ] +} + +static_library("glad") { + sources = [ + "third_party/glad/include/KHR/khrplatform.h", + "third_party/glad/include/glad/glad.h", + "third_party/glad/src/glad.c", + ] + + public_configs = [ ":glad_public" ] +} + +config("spirv_cross_public") { + include_dirs = [ "third_party" ] + defines = [ "SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS" ] +} + +static_library("spirv_cross") { + public_configs = [ ":spirv_cross_public" ] + + cflags_cc = [ "-Wno-implicit-fallthrough" ] + + sources = [ + dawn_spirv_cross_dir + "GLSL.std.450.h", + dawn_spirv_cross_dir + "spirv_common.hpp", + dawn_spirv_cross_dir + "spirv_cfg.cpp", + dawn_spirv_cross_dir + "spirv_cfg.hpp", + dawn_spirv_cross_dir + "spirv_cross.cpp", + dawn_spirv_cross_dir + "spirv_cross.hpp", + dawn_spirv_cross_dir + "spirv.hpp", + ] + + need_glsl_cross = dawn_enable_opengl + + if (dawn_enable_d3d12) { + sources += [ + dawn_spirv_cross_dir + "spirv_hlsl.cpp", + dawn_spirv_cross_dir + "spirv_hlsl.hpp", + ] + need_glsl_cross = true + } + + if (dawn_enable_metal) { + sources += [ + dawn_spirv_cross_dir + "spirv_msl.cpp", + dawn_spirv_cross_dir + "spirv_msl.hpp", + ] + need_glsl_cross = true + } + + if (need_glsl_cross) { + sources += [ + dawn_spirv_cross_dir + "spirv_glsl.cpp", + dawn_spirv_cross_dir + "spirv_glsl.hpp", + ] + } +} + +# An empty Vulkan target to add the include dirs and list the sources +# for the header inclusion check. +config("vulkan_headers_public") { + include_dirs = [ "third_party" ] +} + +source_set("vulkan_headers") { + sources = [ + "third_party/vulkan/vk_platform.h", + "third_party/vulkan/vulkan.h", + ] + + public_configs = [ ":vulkan_headers_public" ] +} + +############################################################################### +# libdawn_native.so +############################################################################### + +config("libdawn_native_internal") { + configs = [ ":dawn_internal" ] + defines = [ "DAWN_NATIVE_IMPLEMENTATION" ] + + # Suppress warnings that Metal isn't in the deployment target of Chrome + if (is_mac) { + cflags_objcc = [ "-Wno-unguarded-availability" ] + } +} + +dawn_generator("libdawn_native_utils") { + target = "dawn_native_utils" + target_type = "source_set" + + configs = [ ":libdawn_native_internal" ] + deps = [ + ":dawn_headers", + ] +} + +# The meat of the compilation for libdawn_native so that we can cheaply have +# shared_library / static_library / component versions of it. +source_set("libdawn_native_sources") { + deps = [ + ":dawn_common", + ":dawn_headers", + ":libdawn_native_utils", + ":spirv_cross", + ] + + configs += [ ":libdawn_native_internal" ] + libs = [] + + sources = [ + "src/dawn_native/BindGroup.cpp", + "src/dawn_native/BindGroup.h", + "src/dawn_native/BindGroupLayout.cpp", + "src/dawn_native/BindGroupLayout.h", + "src/dawn_native/BlendState.cpp", + "src/dawn_native/BlendState.h", + "src/dawn_native/Buffer.cpp", + "src/dawn_native/Buffer.h", + "src/dawn_native/Builder.cpp", + "src/dawn_native/Builder.h", + "src/dawn_native/CommandAllocator.cpp", + "src/dawn_native/CommandAllocator.h", + "src/dawn_native/CommandBuffer.cpp", + "src/dawn_native/CommandBuffer.h", + "src/dawn_native/CommandBufferStateTracker.cpp", + "src/dawn_native/CommandBufferStateTracker.h", + "src/dawn_native/Commands.cpp", + "src/dawn_native/Commands.h", + "src/dawn_native/ComputePipeline.cpp", + "src/dawn_native/ComputePipeline.h", + "src/dawn_native/DawnNative.cpp", + "src/dawn_native/DepthStencilState.cpp", + "src/dawn_native/DepthStencilState.h", + "src/dawn_native/Device.cpp", + "src/dawn_native/Device.h", + "src/dawn_native/Error.cpp", + "src/dawn_native/Error.h", + "src/dawn_native/ErrorData.cpp", + "src/dawn_native/ErrorData.h", + "src/dawn_native/Forward.h", + "src/dawn_native/InputState.cpp", + "src/dawn_native/InputState.h", + "src/dawn_native/PassResourceUsage.h", + "src/dawn_native/PerStage.cpp", + "src/dawn_native/PerStage.h", + "src/dawn_native/Pipeline.cpp", + "src/dawn_native/Pipeline.h", + "src/dawn_native/PipelineLayout.cpp", + "src/dawn_native/PipelineLayout.h", + "src/dawn_native/Queue.cpp", + "src/dawn_native/Queue.h", + "src/dawn_native/RefCounted.cpp", + "src/dawn_native/RefCounted.h", + "src/dawn_native/RenderPassDescriptor.cpp", + "src/dawn_native/RenderPassDescriptor.h", + "src/dawn_native/RenderPipeline.cpp", + "src/dawn_native/RenderPipeline.h", + "src/dawn_native/Sampler.cpp", + "src/dawn_native/Sampler.h", + "src/dawn_native/ShaderModule.cpp", + "src/dawn_native/ShaderModule.h", + "src/dawn_native/SwapChain.cpp", + "src/dawn_native/SwapChain.h", + "src/dawn_native/Texture.cpp", + "src/dawn_native/Texture.h", + "src/dawn_native/ToBackend.h", + "src/dawn_native/dawn_platform.h", + "src/include/dawn_native/DawnNative.h", + "src/include/dawn_native/dawn_native_export.h", + + # Include all backend's public headers so that dependencies can include + # them even when the backends are disabled. + "src/include/dawn_native/D3D12Backend.h", + "src/include/dawn_native/MetalBackend.h", + "src/include/dawn_native/NullBackend.h", + "src/include/dawn_native/OpenGLBackend.h", + "src/include/dawn_native/VulkanBackend.h", + ] + + if (dawn_enable_d3d12) { + libs += [ + "d3d12.lib", + "dxgi.lib", + "d3dcompiler.lib", + ] + sources += [ + "src/dawn_native/d3d12/BindGroupD3D12.cpp", + "src/dawn_native/d3d12/BindGroupD3D12.h", + "src/dawn_native/d3d12/BindGroupLayoutD3D12.cpp", + "src/dawn_native/d3d12/BindGroupLayoutD3D12.h", + "src/dawn_native/d3d12/BlendStateD3D12.cpp", + "src/dawn_native/d3d12/BlendStateD3D12.h", + "src/dawn_native/d3d12/BufferD3D12.cpp", + "src/dawn_native/d3d12/BufferD3D12.h", + "src/dawn_native/d3d12/CommandAllocatorManager.cpp", + "src/dawn_native/d3d12/CommandAllocatorManager.h", + "src/dawn_native/d3d12/CommandBufferD3D12.cpp", + "src/dawn_native/d3d12/CommandBufferD3D12.h", + "src/dawn_native/d3d12/ComputePipelineD3D12.cpp", + "src/dawn_native/d3d12/ComputePipelineD3D12.h", + "src/dawn_native/d3d12/DepthStencilStateD3D12.cpp", + "src/dawn_native/d3d12/DepthStencilStateD3D12.h", + "src/dawn_native/d3d12/DescriptorHeapAllocator.cpp", + "src/dawn_native/d3d12/DescriptorHeapAllocator.h", + "src/dawn_native/d3d12/DeviceD3D12.cpp", + "src/dawn_native/d3d12/DeviceD3D12.h", + "src/dawn_native/d3d12/Forward.h", + "src/dawn_native/d3d12/InputStateD3D12.cpp", + "src/dawn_native/d3d12/InputStateD3D12.h", + "src/dawn_native/d3d12/NativeSwapChainImplD3D12.cpp", + "src/dawn_native/d3d12/NativeSwapChainImplD3D12.h", + "src/dawn_native/d3d12/PipelineLayoutD3D12.cpp", + "src/dawn_native/d3d12/PipelineLayoutD3D12.h", + "src/dawn_native/d3d12/QueueD3D12.cpp", + "src/dawn_native/d3d12/QueueD3D12.h", + "src/dawn_native/d3d12/RenderPassDescriptorD3D12.cpp", + "src/dawn_native/d3d12/RenderPassDescriptorD3D12.h", + "src/dawn_native/d3d12/RenderPipelineD3D12.cpp", + "src/dawn_native/d3d12/RenderPipelineD3D12.h", + "src/dawn_native/d3d12/ResourceAllocator.cpp", + "src/dawn_native/d3d12/ResourceAllocator.h", + "src/dawn_native/d3d12/ResourceUploader.cpp", + "src/dawn_native/d3d12/ResourceUploader.h", + "src/dawn_native/d3d12/SamplerD3D12.cpp", + "src/dawn_native/d3d12/SamplerD3D12.h", + "src/dawn_native/d3d12/ShaderModuleD3D12.cpp", + "src/dawn_native/d3d12/ShaderModuleD3D12.h", + "src/dawn_native/d3d12/SwapChainD3D12.cpp", + "src/dawn_native/d3d12/SwapChainD3D12.h", + "src/dawn_native/d3d12/TextureCopySplitter.cpp", + "src/dawn_native/d3d12/TextureCopySplitter.h", + "src/dawn_native/d3d12/TextureD3D12.cpp", + "src/dawn_native/d3d12/TextureD3D12.h", + "src/dawn_native/d3d12/d3d12_platform.h", + ] + } + + if (dawn_enable_metal) { + libs += [ + "Metal.framework", + "Cocoa.framework", + ] + sources += [ + "src/dawn_native/metal/BlendStateMTL.h", + "src/dawn_native/metal/BlendStateMTL.mm", + "src/dawn_native/metal/BufferMTL.h", + "src/dawn_native/metal/BufferMTL.mm", + "src/dawn_native/metal/CommandBufferMTL.h", + "src/dawn_native/metal/CommandBufferMTL.mm", + "src/dawn_native/metal/ComputePipelineMTL.h", + "src/dawn_native/metal/ComputePipelineMTL.mm", + "src/dawn_native/metal/DepthStencilStateMTL.h", + "src/dawn_native/metal/DepthStencilStateMTL.mm", + "src/dawn_native/metal/DeviceMTL.h", + "src/dawn_native/metal/DeviceMTL.mm", + "src/dawn_native/metal/Forward.h", + "src/dawn_native/metal/InputStateMTL.h", + "src/dawn_native/metal/InputStateMTL.mm", + "src/dawn_native/metal/PipelineLayoutMTL.h", + "src/dawn_native/metal/PipelineLayoutMTL.mm", + "src/dawn_native/metal/QueueMTL.h", + "src/dawn_native/metal/QueueMTL.mm", + "src/dawn_native/metal/RenderPipelineMTL.h", + "src/dawn_native/metal/RenderPipelineMTL.mm", + "src/dawn_native/metal/ResourceUploader.h", + "src/dawn_native/metal/ResourceUploader.mm", + "src/dawn_native/metal/SamplerMTL.h", + "src/dawn_native/metal/SamplerMTL.mm", + "src/dawn_native/metal/ShaderModuleMTL.h", + "src/dawn_native/metal/ShaderModuleMTL.mm", + "src/dawn_native/metal/SwapChainMTL.h", + "src/dawn_native/metal/SwapChainMTL.mm", + "src/dawn_native/metal/TextureMTL.h", + "src/dawn_native/metal/TextureMTL.mm", + ] + } + + if (dawn_enable_null) { + sources += [ + "src/dawn_native/null/NullBackend.cpp", + "src/dawn_native/null/NullBackend.h", + ] + } + + if (dawn_enable_opengl) { + deps += [ ":glad" ] + sources += [ + "src/dawn_native/opengl/BlendStateGL.cpp", + "src/dawn_native/opengl/BlendStateGL.h", + "src/dawn_native/opengl/BufferGL.cpp", + "src/dawn_native/opengl/BufferGL.h", + "src/dawn_native/opengl/CommandBufferGL.cpp", + "src/dawn_native/opengl/CommandBufferGL.h", + "src/dawn_native/opengl/ComputePipelineGL.cpp", + "src/dawn_native/opengl/ComputePipelineGL.h", + "src/dawn_native/opengl/DepthStencilStateGL.cpp", + "src/dawn_native/opengl/DepthStencilStateGL.h", + "src/dawn_native/opengl/DeviceGL.cpp", + "src/dawn_native/opengl/DeviceGL.h", + "src/dawn_native/opengl/Forward.h", + "src/dawn_native/opengl/InputStateGL.cpp", + "src/dawn_native/opengl/InputStateGL.h", + "src/dawn_native/opengl/PersistentPipelineStateGL.cpp", + "src/dawn_native/opengl/PersistentPipelineStateGL.h", + "src/dawn_native/opengl/PipelineGL.cpp", + "src/dawn_native/opengl/PipelineGL.h", + "src/dawn_native/opengl/PipelineLayoutGL.cpp", + "src/dawn_native/opengl/PipelineLayoutGL.h", + "src/dawn_native/opengl/QueueGL.cpp", + "src/dawn_native/opengl/QueueGL.h", + "src/dawn_native/opengl/RenderPipelineGL.cpp", + "src/dawn_native/opengl/RenderPipelineGL.h", + "src/dawn_native/opengl/SamplerGL.cpp", + "src/dawn_native/opengl/SamplerGL.h", + "src/dawn_native/opengl/ShaderModuleGL.cpp", + "src/dawn_native/opengl/ShaderModuleGL.h", + "src/dawn_native/opengl/SwapChainGL.cpp", + "src/dawn_native/opengl/SwapChainGL.h", + "src/dawn_native/opengl/TextureGL.cpp", + "src/dawn_native/opengl/TextureGL.h", + ] + } + + if (dawn_enable_vulkan) { + deps += [ ":vulkan_headers" ] + sources += [ + "src/dawn_native/vulkan/BindGroupLayoutVk.cpp", + "src/dawn_native/vulkan/BindGroupLayoutVk.h", + "src/dawn_native/vulkan/BindGroupVk.cpp", + "src/dawn_native/vulkan/BindGroupVk.h", + "src/dawn_native/vulkan/BlendStateVk.cpp", + "src/dawn_native/vulkan/BlendStateVk.h", + "src/dawn_native/vulkan/BufferUploader.cpp", + "src/dawn_native/vulkan/BufferUploader.h", + "src/dawn_native/vulkan/BufferVk.cpp", + "src/dawn_native/vulkan/BufferVk.h", + "src/dawn_native/vulkan/CommandBufferVk.cpp", + "src/dawn_native/vulkan/CommandBufferVk.h", + "src/dawn_native/vulkan/ComputePipelineVk.cpp", + "src/dawn_native/vulkan/ComputePipelineVk.h", + "src/dawn_native/vulkan/DepthStencilStateVk.cpp", + "src/dawn_native/vulkan/DepthStencilStateVk.h", + "src/dawn_native/vulkan/DeviceVk.cpp", + "src/dawn_native/vulkan/DeviceVk.h", + "src/dawn_native/vulkan/FencedDeleter.cpp", + "src/dawn_native/vulkan/FencedDeleter.h", + "src/dawn_native/vulkan/Forward.h", + "src/dawn_native/vulkan/InputStateVk.cpp", + "src/dawn_native/vulkan/InputStateVk.h", + "src/dawn_native/vulkan/MemoryAllocator.cpp", + "src/dawn_native/vulkan/MemoryAllocator.h", + "src/dawn_native/vulkan/NativeSwapChainImplVk.cpp", + "src/dawn_native/vulkan/NativeSwapChainImplVk.h", + "src/dawn_native/vulkan/PipelineLayoutVk.cpp", + "src/dawn_native/vulkan/PipelineLayoutVk.h", + "src/dawn_native/vulkan/QueueVk.cpp", + "src/dawn_native/vulkan/QueueVk.h", + "src/dawn_native/vulkan/RenderPassCache.cpp", + "src/dawn_native/vulkan/RenderPassCache.h", + "src/dawn_native/vulkan/RenderPassDescriptorVk.cpp", + "src/dawn_native/vulkan/RenderPassDescriptorVk.h", + "src/dawn_native/vulkan/RenderPipelineVk.cpp", + "src/dawn_native/vulkan/RenderPipelineVk.h", + "src/dawn_native/vulkan/SamplerVk.cpp", + "src/dawn_native/vulkan/SamplerVk.h", + "src/dawn_native/vulkan/ShaderModuleVk.cpp", + "src/dawn_native/vulkan/ShaderModuleVk.h", + "src/dawn_native/vulkan/SwapChainVk.cpp", + "src/dawn_native/vulkan/SwapChainVk.h", + "src/dawn_native/vulkan/TextureVk.cpp", + "src/dawn_native/vulkan/TextureVk.h", + "src/dawn_native/vulkan/VulkanFunctions.cpp", + "src/dawn_native/vulkan/VulkanFunctions.h", + "src/dawn_native/vulkan/VulkanInfo.cpp", + "src/dawn_native/vulkan/VulkanInfo.h", + ] + } +} + +# The shared library for libdawn_native for use by samples, tests, etc. +shared_library("libdawn_native") { + deps = [ + ":libdawn_native_sources", + ] + public_configs = [ ":libdawn_public" ] +} + +# The static library for libdawn_native for use by unittests +static_library("libdawn_native_static") { + deps = [ + ":libdawn_native_sources", + ] + + sources = [ + "src/Empty.cpp", + ] + + # Put the internal config public so that unittests can see internal headers + public_configs = [ ":libdawn_native_internal" ] +} + +############################################################################### +# libdawn_wire.so +############################################################################### + +# The meat of the compilation for libdawn_wire so that we can cheaply have +# shared_library / static_library / component versions of it. +dawn_generator("libdawn_wire_sources") { + target = "dawn_wire" + target_type = "source_set" + + configs = [ ":dawn_internal" ] + deps = [ + ":dawn_common", + ":dawn_headers", + ] + defines = [ "DAWN_WIRE_IMPLEMENTATION" ] + sources = [ + "src/dawn_wire/WireCmd.h", + "src/include/dawn_wire/Wire.h", + "src/include/dawn_wire/dawn_wire_export.h", + ] +} + +shared_library("libdawn_wire") { + deps = [ + ":libdawn_wire_sources", + ] + public_configs = [ ":libdawn_public" ] +} diff --git a/DEPS b/DEPS new file mode 100644 index 0000000000..a0bd2410bb --- /dev/null +++ b/DEPS @@ -0,0 +1,154 @@ +vars = { + 'chromium_git': 'https://chromium.googlesource.com', + 'github_git': 'https://github.com', + + 'dawn_root': '.', + 'dawn_standalone': True, +} + +deps = { + # Dependencies required to use GN/Clang in standalone + '{dawn_root}/build': { + 'url': '{chromium_git}/chromium/src/build.git@b944b99e72923c5a6699235ed858e725db21f81f', + 'condition': 'dawn_standalone', + }, + '{dawn_root}/buildtools': { + 'url': '{chromium_git}/chromium/buildtools.git@94288c26d2ffe3aec9848c147839afee597acefd', + 'condition': 'dawn_standalone', + }, + '{dawn_root}/tools/clang': { + 'url': '{chromium_git}/chromium/src/tools/clang.git@c893c7eec4706f8c7fc244ee254b1dadd8f8d158', + 'condition': 'dawn_standalone', + }, + + # GTest and GMock + '{dawn_root}/testing': { + 'url': '{chromium_git}/chromium/src/testing@4d706fd80be9e8989aec5235540e7b46d0672826', + 'condition': 'dawn_standalone', + }, + + # SPIRV-Cross + '{dawn_root}/third_party/spirv-cross': { + 'url': '{github_git}/Kangz/SPIRV-Cross.git@694cad533296df02b4562f4a5a20cba1d1a9dbaf', + }, +} + +hooks = [ + # Pull clang-format binaries using checked-in hashes. + { + 'name': 'clang_format_win', + 'pattern': '.', + 'condition': 'host_os == "win" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=win32', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', '{dawn_root}/buildtools/win/clang-format.exe.sha1', + ], + }, + { + 'name': 'clang_format_mac', + 'pattern': '.', + 'condition': 'host_os == "mac" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=darwin', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', '{dawn_root}/buildtools/mac/clang-format.sha1', + ], + }, + { + 'name': 'clang_format_linux', + 'pattern': '.', + 'condition': 'host_os == "linux" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=linux*', + '--no_auth', + '--bucket', 'chromium-clang-format', + '-s', '{dawn_root}/buildtools/linux64/clang-format.sha1', + ], + }, + + # Pull GN binaries using checked-in hashes. + { + 'name': 'gn_win', + 'pattern': '.', + 'condition': 'host_os == "win" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=win32', + '--no_auth', + '--bucket', 'chromium-gn', + '-s', '{dawn_root}/buildtools/win/gn.exe.sha1', + ], + }, + { + 'name': 'gn_mac', + 'pattern': '.', + 'condition': 'host_os == "mac" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=darwin', + '--no_auth', + '--bucket', 'chromium-gn', + '-s', '{dawn_root}/buildtools/mac/gn.sha1', + ], + }, + { + 'name': 'gn_linux64', + 'pattern': '.', + 'condition': 'host_os == "linux" and dawn_standalone', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--platform=linux*', + '--no_auth', + '--bucket', 'chromium-gn', + '-s', '{dawn_root}/buildtools/linux64/gn.sha1', + ], + }, + + # Pull the compilers and system libraries for hermetic builds + { + 'name': 'sysroot_x86', + 'pattern': '.', + 'condition': 'checkout_linux and ((checkout_x86 or checkout_x64) and dawn_standalone)', + 'action': ['python', '{dawn_root}/build/linux/sysroot_scripts/install-sysroot.py', + '--arch=x86'], + }, + { + 'name': 'sysroot_x64', + 'pattern': '.', + 'condition': 'checkout_linux and (checkout_x64 and dawn_standalone)', + 'action': ['python', '{dawn_root}/build/linux/sysroot_scripts/install-sysroot.py', + '--arch=x64'], + }, + { + # Update the Windows toolchain if necessary. Must run before 'clang' below. + 'name': 'win_toolchain', + 'pattern': '.', + 'condition': 'checkout_win and dawn_standalone', + 'action': ['python', '{dawn_root}/build/vs_toolchain.py', 'update', '--force'], + }, + { + # Note: On Win, this should run after win_toolchain, as it may use it. + 'name': 'clang', + 'pattern': '.', + 'action': ['python', '{dawn_root}/tools/clang/scripts/update.py'], + 'condition': 'dawn_standalone', + }, + { + # Pull rc binaries using checked-in hashes. + 'name': 'rc_win', + 'pattern': '.', + 'condition': 'checkout_win and (host_os == "win" and dawn_standalone)', + 'action': [ 'download_from_google_storage', + '--no_resume', + '--no_auth', + '--bucket', 'chromium-browser-clang/rc', + '-s', '{dawn_root}/build/toolchain/win/rc/win/rc.exe.sha1', + ], + }, +] diff --git a/build_overrides/build.gni b/build_overrides/build.gni new file mode 100644 index 0000000000..d0a630200e --- /dev/null +++ b/build_overrides/build.gni @@ -0,0 +1,27 @@ +# Copyright 2018 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. + +# Tell Dawn and dependencies to not do Chromium-specific things +build_with_chromium = false + +# Don't use Chromium's third_party/binutils +linux_use_bundled_binutils_override = false + +# In standalone Dawn builds, don't try to use the hermetic install of Xcode +# that Chromium uses +use_system_xcode = true + +# Android 32-bit non-component, non-clang builds cannot have symbol_level=2 +# due to 4GiB file size limit, see https://crbug.com/648948. +ignore_elf32_limitations = false diff --git a/build_overrides/dawn.gni b/build_overrides/dawn.gni new file mode 100644 index 0000000000..0878635c1e --- /dev/null +++ b/build_overrides/dawn.gni @@ -0,0 +1,19 @@ +# Copyright 2018 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. + +# Whether we are building from Dawn's repository +dawn_standalone = true + +# Where to find SPIRV-Cross if we aren't in standalone +dawn_spirv_cross_dir = "//third_party/spirv-cross/" diff --git a/generator/templates/dawn_native/ProcTable.cpp b/generator/templates/dawn_native/ProcTable.cpp index f967ccb4f1..e3f9d35efc 100644 --- a/generator/templates/dawn_native/ProcTable.cpp +++ b/generator/templates/dawn_native/ProcTable.cpp @@ -52,9 +52,10 @@ namespace dawn_native { return false; } {% else %} - (void) self; + DAWN_UNUSED(self); {% endif %} bool error = false; + DAWN_UNUSED(error); {% for arg in method.arguments %} {% set cppType = as_cppType(arg.type.name) %} {% set argName = as_varName(arg.name) %} @@ -65,7 +66,7 @@ namespace dawn_native { error = true; } {% else %} - (void) {{argName}}; + DAWN_UNUSED({{argName}}); {% endif %} if (error) { {% if type.is_builder %} diff --git a/src/Empty.cpp b/src/Empty.cpp new file mode 100644 index 0000000000..c35419c087 --- /dev/null +++ b/src/Empty.cpp @@ -0,0 +1,16 @@ +// Copyright 2018 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. + +// This is an empty file used as a workaround for OSX's libtool requiring that a response file +// contains at least one file.