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 <enga@chromium.org>
Commit-Queue: Shrek Shao <shrekshao@google.com>
This commit is contained in:
Shrek Shao 2022-02-09 19:42:51 +00:00 committed by Dawn LUCI CQ
parent b626409c4b
commit 71a363bcf9
2 changed files with 10 additions and 0 deletions

View File

@ -24,6 +24,11 @@
//* //*
//* //*
{% include 'BSD_LICENSE' %} {% 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_ #ifndef {{metadata.api.upper()}}_H_
#define {{metadata.api.upper()}}_H_ #define {{metadata.api.upper()}}_H_

View File

@ -13,6 +13,11 @@
//* limitations under the License. //* limitations under the License.
{% set API = metadata.api.upper() %} {% set API = metadata.api.upper() %}
{% set api = API.lower() %} {% 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_ #ifndef {{API}}_CPP_H_
#define {{API}}_CPP_H_ #define {{API}}_CPP_H_