From 3f4b2602649d3b1ee7392cfce23700e4202b01a7 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Mon, 11 Apr 2022 20:10:10 +0000 Subject: [PATCH] dawn/node: Define NAPI_DISABLE_CPP_EXCEPTIONS Wrap `napi.h` with a Dawn header that defines `NAPI_DISABLE_CPP_EXCEPTIONS`, and then includes the napi.h header. Required now that CMake correctly disables exceptions with `-fno-exceptions`. Change-Id: If31b28d331f2071a0119339c60cc3ab8ab801a98 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/86301 Reviewed-by: Corentin Wallez Commit-Queue: Ben Clayton --- src/dawn/node/binding/AsyncRunner.h | 3 ++- src/dawn/node/binding/Converter.h | 3 ++- src/dawn/node/binding/Errors.h | 2 +- src/dawn/node/binding/GPU.h | 3 ++- src/dawn/node/binding/GPUAdapter.h | 3 ++- src/dawn/node/binding/GPUBindGroup.h | 3 ++- src/dawn/node/binding/GPUBindGroupLayout.h | 3 ++- src/dawn/node/binding/GPUBuffer.h | 3 ++- src/dawn/node/binding/GPUCommandBuffer.h | 3 ++- src/dawn/node/binding/GPUCommandEncoder.h | 3 ++- src/dawn/node/binding/GPUComputePassEncoder.h | 3 ++- src/dawn/node/binding/GPUComputePipeline.h | 3 ++- src/dawn/node/binding/GPUDevice.h | 3 ++- src/dawn/node/binding/GPUPipelineLayout.h | 3 ++- src/dawn/node/binding/GPUQuerySet.h | 3 ++- src/dawn/node/binding/GPUQueue.h | 3 ++- src/dawn/node/binding/GPURenderBundle.h | 3 ++- .../node/binding/GPURenderBundleEncoder.h | 3 ++- src/dawn/node/binding/GPURenderPassEncoder.h | 3 ++- src/dawn/node/binding/GPURenderPipeline.h | 3 ++- src/dawn/node/binding/GPUSampler.h | 3 ++- src/dawn/node/binding/GPUShaderModule.h | 3 ++- src/dawn/node/binding/GPUSupportedLimits.h | 3 ++- src/dawn/node/binding/GPUTexture.h | 3 ++- src/dawn/node/binding/GPUTextureView.h | 3 ++- src/dawn/node/interop/Core.h | 4 ++-- src/dawn/node/interop/Napi.h | 23 +++++++++++++++++++ 27 files changed, 74 insertions(+), 27 deletions(-) create mode 100644 src/dawn/node/interop/Napi.h diff --git a/src/dawn/node/binding/AsyncRunner.h b/src/dawn/node/binding/AsyncRunner.h index ec68e87b41..53e75d7793 100644 --- a/src/dawn/node/binding/AsyncRunner.h +++ b/src/dawn/node/binding/AsyncRunner.h @@ -19,7 +19,8 @@ #include #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/Converter.h b/src/dawn/node/binding/Converter.h index 8ab9e533a5..befa1fa35b 100644 --- a/src/dawn/node/binding/Converter.h +++ b/src/dawn/node/binding/Converter.h @@ -20,8 +20,9 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/Errors.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/Errors.h b/src/dawn/node/binding/Errors.h index d22fe48cb7..640a702418 100644 --- a/src/dawn/node/binding/Errors.h +++ b/src/dawn/node/binding/Errors.h @@ -15,7 +15,7 @@ #ifndef SRC_DAWN_NODE_BINDING_ERRORS_H_ #define SRC_DAWN_NODE_BINDING_ERRORS_H_ -#include "node-addon-api/napi.h" +#include "src/dawn/node/interop/Napi.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPU.h b/src/dawn/node/binding/GPU.h index f9861a7afd..b6ac9f36c8 100644 --- a/src/dawn/node/binding/GPU.h +++ b/src/dawn/node/binding/GPU.h @@ -17,8 +17,9 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/Flags.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUAdapter.h b/src/dawn/node/binding/GPUAdapter.h index 21fe9a4216..4a071399c9 100644 --- a/src/dawn/node/binding/GPUAdapter.h +++ b/src/dawn/node/binding/GPUAdapter.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUBindGroup.h b/src/dawn/node/binding/GPUBindGroup.h index 37bd298f3b..5a2e93ec83 100644 --- a/src/dawn/node/binding/GPUBindGroup.h +++ b/src/dawn/node/binding/GPUBindGroup.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUBindGroupLayout.h b/src/dawn/node/binding/GPUBindGroupLayout.h index e3ff31df33..02cb0099c8 100644 --- a/src/dawn/node/binding/GPUBindGroupLayout.h +++ b/src/dawn/node/binding/GPUBindGroupLayout.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUBuffer.h b/src/dawn/node/binding/GPUBuffer.h index 1d26ca41b9..953c7c158d 100644 --- a/src/dawn/node/binding/GPUBuffer.h +++ b/src/dawn/node/binding/GPUBuffer.h @@ -17,8 +17,9 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/AsyncRunner.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUCommandBuffer.h b/src/dawn/node/binding/GPUCommandBuffer.h index 36325b2ff5..5507ae0b5a 100644 --- a/src/dawn/node/binding/GPUCommandBuffer.h +++ b/src/dawn/node/binding/GPUCommandBuffer.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUCommandEncoder.h b/src/dawn/node/binding/GPUCommandEncoder.h index e752d82381..f425d469c1 100644 --- a/src/dawn/node/binding/GPUCommandEncoder.h +++ b/src/dawn/node/binding/GPUCommandEncoder.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUComputePassEncoder.h b/src/dawn/node/binding/GPUComputePassEncoder.h index 53d894e253..2e8cb1384f 100644 --- a/src/dawn/node/binding/GPUComputePassEncoder.h +++ b/src/dawn/node/binding/GPUComputePassEncoder.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUComputePipeline.h b/src/dawn/node/binding/GPUComputePipeline.h index 027e1ed466..df8ccfabf5 100644 --- a/src/dawn/node/binding/GPUComputePipeline.h +++ b/src/dawn/node/binding/GPUComputePipeline.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUDevice.h b/src/dawn/node/binding/GPUDevice.h index a0a6be0290..9dc249cb41 100644 --- a/src/dawn/node/binding/GPUDevice.h +++ b/src/dawn/node/binding/GPUDevice.h @@ -16,8 +16,9 @@ #define SRC_DAWN_NODE_BINDING_GPUDEVICE_H_ #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/AsyncRunner.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUPipelineLayout.h b/src/dawn/node/binding/GPUPipelineLayout.h index e6b1bcd8ef..f6cfa14059 100644 --- a/src/dawn/node/binding/GPUPipelineLayout.h +++ b/src/dawn/node/binding/GPUPipelineLayout.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUQuerySet.h b/src/dawn/node/binding/GPUQuerySet.h index bbfd26f50e..ea01cf3f1f 100644 --- a/src/dawn/node/binding/GPUQuerySet.h +++ b/src/dawn/node/binding/GPUQuerySet.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUQueue.h b/src/dawn/node/binding/GPUQueue.h index 6111ae0b49..3710405f7a 100644 --- a/src/dawn/node/binding/GPUQueue.h +++ b/src/dawn/node/binding/GPUQueue.h @@ -17,8 +17,9 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/AsyncRunner.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPURenderBundle.h b/src/dawn/node/binding/GPURenderBundle.h index e61b9d63c4..7eeabb22cb 100644 --- a/src/dawn/node/binding/GPURenderBundle.h +++ b/src/dawn/node/binding/GPURenderBundle.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPURenderBundleEncoder.h b/src/dawn/node/binding/GPURenderBundleEncoder.h index 9823824f23..8d8d5a3637 100644 --- a/src/dawn/node/binding/GPURenderBundleEncoder.h +++ b/src/dawn/node/binding/GPURenderBundleEncoder.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPURenderPassEncoder.h b/src/dawn/node/binding/GPURenderPassEncoder.h index dbebd01669..ca5d857b53 100644 --- a/src/dawn/node/binding/GPURenderPassEncoder.h +++ b/src/dawn/node/binding/GPURenderPassEncoder.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPURenderPipeline.h b/src/dawn/node/binding/GPURenderPipeline.h index f0c5d67954..e35bb85d64 100644 --- a/src/dawn/node/binding/GPURenderPipeline.h +++ b/src/dawn/node/binding/GPURenderPipeline.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUSampler.h b/src/dawn/node/binding/GPUSampler.h index a467dcf3a7..0eddc8fc83 100644 --- a/src/dawn/node/binding/GPUSampler.h +++ b/src/dawn/node/binding/GPUSampler.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUShaderModule.h b/src/dawn/node/binding/GPUShaderModule.h index fd5016eb23..2f7396ae3f 100644 --- a/src/dawn/node/binding/GPUShaderModule.h +++ b/src/dawn/node/binding/GPUShaderModule.h @@ -17,8 +17,9 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + #include "src/dawn/node/binding/AsyncRunner.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUSupportedLimits.h b/src/dawn/node/binding/GPUSupportedLimits.h index c9074f8920..27ea31982f 100644 --- a/src/dawn/node/binding/GPUSupportedLimits.h +++ b/src/dawn/node/binding/GPUSupportedLimits.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUTexture.h b/src/dawn/node/binding/GPUTexture.h index 66e7afe392..fc2582cf6a 100644 --- a/src/dawn/node/binding/GPUTexture.h +++ b/src/dawn/node/binding/GPUTexture.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/binding/GPUTextureView.h b/src/dawn/node/binding/GPUTextureView.h index 0aa23e5a84..5f4db27ef8 100644 --- a/src/dawn/node/binding/GPUTextureView.h +++ b/src/dawn/node/binding/GPUTextureView.h @@ -17,7 +17,8 @@ #include "dawn/native/DawnNative.h" #include "dawn/webgpu_cpp.h" -#include "node-addon-api/napi.h" + +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/interop/WebGPU.h" namespace wgpu::binding { diff --git a/src/dawn/node/interop/Core.h b/src/dawn/node/interop/Core.h index 51a99d32ea..1ad90adf05 100644 --- a/src/dawn/node/interop/Core.h +++ b/src/dawn/node/interop/Core.h @@ -26,7 +26,7 @@ #include #include -#include "node-addon-api/napi.h" +#include "src/dawn/node/interop/Napi.h" #include "src/dawn/node/utils/Debug.h" @@ -119,7 +119,7 @@ namespace wgpu::interop { // stringified values append to the error message. // If Result is a success, then a success Result is returned. template - Result Append(VALUES && ... values) { + Result Append(VALUES&&... values) { if (*this) { return *this; } diff --git a/src/dawn/node/interop/Napi.h b/src/dawn/node/interop/Napi.h new file mode 100644 index 0000000000..b0e77ad2d3 --- /dev/null +++ b/src/dawn/node/interop/Napi.h @@ -0,0 +1,23 @@ +// Copyright 2022 The Tint 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. + +#ifndef SRC_DAWN_NODE_INTEROP_NAPI_H_ +#define SRC_DAWN_NODE_INTEROP_NAPI_H_ + +// Dawn is built with exceptions disabled. +#define NAPI_DISABLE_CPP_EXCEPTIONS + +#include "node-addon-api/napi.h" + +#endif // SRC_DAWN_NODE_INTEROP_NAPI_H_