From 71a363bcf9c9c45eb9b9fc7ebf4dd03d035b48ff Mon Sep 17 00:00:00 2001 From: Shrek Shao Date: Wed, 9 Feb 2022 19:42:51 +0000 Subject: [PATCH] Add error directives for api.h/api_cpp.h #ifdef __EMSCRIPTEN__ This could avoid including dawn's version of webgpu headers and confusion at runtime when build with emscripten. Emscripten's system/include/webgpu headers should be used. Bug: None Change-Id: Ie8c6ebc23f28a56b1cb887ae7f11d3f738151aec Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/79740 Reviewed-by: Austin Eng Commit-Queue: Shrek Shao --- generator/templates/api.h | 5 +++++ generator/templates/api_cpp.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/generator/templates/api.h b/generator/templates/api.h index b55647aa6e..36488a0a4b 100644 --- a/generator/templates/api.h +++ b/generator/templates/api.h @@ -24,6 +24,11 @@ //* //* {% include 'BSD_LICENSE' %} +{% if 'dawn' in enabled_tags %} + #ifdef __EMSCRIPTEN__ + #error "Do not include this header. Emscripten already provides headers needed for {{metadata.api}}." + #endif +{% endif %} #ifndef {{metadata.api.upper()}}_H_ #define {{metadata.api.upper()}}_H_ diff --git a/generator/templates/api_cpp.h b/generator/templates/api_cpp.h index d54dcc3349..2a207cc1ec 100644 --- a/generator/templates/api_cpp.h +++ b/generator/templates/api_cpp.h @@ -13,6 +13,11 @@ //* limitations under the License. {% set API = metadata.api.upper() %} {% set api = API.lower() %} +{% if 'dawn' not in enabled_tags %} + #ifdef __EMSCRIPTEN__ + #error "Do not include this header. Emscripten already provides headers needed for {{metadata.api}}." + #endif +{% endif %} #ifndef {{API}}_CPP_H_ #define {{API}}_CPP_H_