Add static library versions of libdawn*

Chromium will want to have both static and shared library versions of
Dawn to use in non-component and component builds respectively.

The *_export.h files are modified to noop when *_SHARED_LIBRARY is not
defined so that the static library doesn't export symbols that aren't
imported in dependents (this would break compilation on Windows).

A dawn_library_combo is introduced in BUILD.gn that factors out all the
logic needed to produce shared libraries and handle the _EXPORT macros.

Also contains a fix to dawncpp to export only the methods that aren't
defined in the header (otherwise they get defined multiple times)

BUG=dawn:85

Change-Id: Ib747deb9308e1165dd66002487147ba279d3eac0
Reviewed-on: https://dawn-review.googlesource.com/c/3761
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez
2019-01-09 09:05:18 +00:00
committed by Commit Bot service account
parent 97d2a71684
commit bd48385d50
6 changed files with 209 additions and 156 deletions

View File

@@ -130,9 +130,9 @@ namespace dawn {
{% macro render_cpp_method_declaration(type, method) %}
{% set CppType = as_cppType(type.name) %}
{% if method.return_type.name.concatcase() == "void" and type.is_builder -%}
{{CppType}} const&
DAWN_EXPORT {{CppType}} const&
{%- else -%}
{{as_cppType(method.return_type.name)}}
DAWN_EXPORT {{as_cppType(method.return_type.name)}}
{%- endif -%}
{{" "}}{{method.name.CamelCase()}}(
{%- for arg in method.arguments -%}
@@ -149,7 +149,7 @@ namespace dawn {
{% for type in by_category["object"] %}
{% set CppType = as_cppType(type.name) %}
{% set CType = as_cType(type.name) %}
class DAWN_EXPORT {{CppType}} : public ObjectBase<{{CppType}}, {{CType}}> {
class {{CppType}} : public ObjectBase<{{CppType}}, {{CType}}> {
public:
using ObjectBase::ObjectBase;
using ObjectBase::operator=;
@@ -160,8 +160,8 @@ namespace dawn {
private:
friend ObjectBase<{{CppType}}, {{CType}}>;
static void DawnReference({{CType}} handle);
static void DawnRelease({{CType}} handle);
static DAWN_EXPORT void DawnReference({{CType}} handle);
static DAWN_EXPORT void DawnRelease({{CType}} handle);
};
{% endfor %}