[dawn][wire] Put most of the wire in a source_set. And change dawn_unittests to use the static version of dawn_wire, such that in a follow-up CL it can test using its internals directly instead of having to only rely on the public interface. Bug: 492139412 Change-Id: I43a26073382545d7502b8765c78525ea040812c3 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/297036 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Loko Kung <lokokung@google.com>
diff --git a/generator/templates/dawn/wire/client/ApiProcs.cpp b/generator/templates/dawn/wire/client/ApiProcs.cpp index 29b1f37..01691aa 100644 --- a/generator/templates/dawn/wire/client/ApiProcs.cpp +++ b/generator/templates/dawn/wire/client/ApiProcs.cpp
@@ -183,7 +183,7 @@ static {{Prefix}}ProcTable gProcTable = MakeProcTable(); - const {{Prefix}}ProcTable& GetProcs() { + const {{Prefix}}ProcTable& GetAutogenProcs() { return gProcTable; }
diff --git a/src/dawn/tests/BUILD.gn b/src/dawn/tests/BUILD.gn index 6d1f264..04900b6 100644 --- a/src/dawn/tests/BUILD.gn +++ b/src/dawn/tests/BUILD.gn
@@ -304,7 +304,8 @@ "${dawn_root}/src/dawn/utils:system_utils", "${dawn_root}/src/dawn/utils:test_utils", "${dawn_root}/src/dawn/utils:wgpu_utils", - "${dawn_root}/src/dawn/wire", + "${dawn_root}/src/dawn/wire:sources", + "${dawn_root}/src/dawn/wire:static", "${dawn_root}/src/utils/chromium_test_compat", ] @@ -538,7 +539,6 @@ "${dawn_root}/src/dawn/utils:system_utils", "${dawn_root}/src/dawn/utils:test_utils", "${dawn_root}/src/dawn/utils:wgpu_utils", - "${dawn_root}/src/dawn/wire", ] public = [ @@ -607,7 +607,7 @@ "${dawn_root}/src/dawn/utils:system_utils", "${dawn_root}/src/dawn/utils:test_utils", "${dawn_root}/src/dawn/utils:wgpu_utils", - "${dawn_root}/src/dawn/wire", + "${dawn_root}/src/dawn/wire:headers", ] sources = [ @@ -825,7 +825,8 @@ "${dawn_root}/src/dawn/utils:system_utils", "${dawn_root}/src/dawn/utils:test_utils", "${dawn_root}/src/dawn/utils:wgpu_utils", - "${dawn_root}/src/dawn/wire", + "${dawn_root}/src/dawn/wire:sources", + "${dawn_root}/src/dawn/wire:static", ] sources = [ @@ -976,7 +977,6 @@ "${dawn_root}/src/dawn/utils:system_utils", "${dawn_root}/src/dawn/utils:test_utils", "${dawn_root}/src/dawn/utils:wgpu_utils", - "${dawn_root}/src/dawn/wire", "${dawn_root}/src/utils/chromium_test_compat", ]
diff --git a/src/dawn/utils/BUILD.gn b/src/dawn/utils/BUILD.gn index 0f9b7c5..875d04c 100644 --- a/src/dawn/utils/BUILD.gn +++ b/src/dawn/utils/BUILD.gn
@@ -94,7 +94,7 @@ "${dawn_root}/src/dawn/common", "${dawn_root}/src/dawn/native:headers", "${dawn_root}/src/dawn/partition_alloc:raw_ptr", - "${dawn_root}/src/dawn/wire", + "${dawn_root}/src/dawn/wire:static", ] }
diff --git a/src/dawn/wire/BUILD.gn b/src/dawn/wire/BUILD.gn index 2cff2ca..b6ac346 100644 --- a/src/dawn/wire/BUILD.gn +++ b/src/dawn/wire/BUILD.gn
@@ -62,16 +62,14 @@ ] } -dawn_component("wire") { - DEFINE_PREFIX = "DAWN_WIRE" - +source_set("sources") { deps = [ ":gen", "${dawn_root}/src/dawn/common", "${dawn_root}/src/tint/lang/wgsl", ] - configs = [ "${dawn_root}/src/dawn/common:internal_config" ] + configs += [ "${dawn_root}/src/dawn/common:internal_config" ] sources = get_target_outputs(":gen") sources += [ "BufferConsumer.h", @@ -84,12 +82,9 @@ "ObjectHandle.h", "SupportedFeatures.cpp", "SupportedFeatures.h", - "Wire.cpp", - "WireClient.cpp", "WireDeserializeAllocator.cpp", "WireDeserializeAllocator.h", "WireResult.h", - "WireServer.cpp", "client/Adapter.cpp", "client/Adapter.h", "client/ApiObjects.h", @@ -143,10 +138,30 @@ "server/ServerSurface.cpp", ] - # Make headers publicly visible public_deps = [ ":headers", "${dawn_root}:abseil", "${dawn_root}/src/dawn/partition_alloc:raw_ptr", ] } + +# The static and shared libraries for dawn::wire. Most of the files are +# already compiled in :sources, but we still need to compile +# files defining exported symbols. +dawn_component("wire") { + DEFINE_PREFIX = "DAWN_WIRE" + + configs = [ "${dawn_root}/src/dawn/common:internal_config" ] + sources = [ + "Wire.cpp", + "WireClient.cpp", + "WireServer.cpp", + ] + deps = [ + ":sources", + "${dawn_root}/src/dawn/common", + ] + + # Make headers publicly visible + public_deps = [ ":headers" ] +}
diff --git a/src/dawn/wire/WireClient.cpp b/src/dawn/wire/WireClient.cpp index 92e0694..98b260a 100644 --- a/src/dawn/wire/WireClient.cpp +++ b/src/dawn/wire/WireClient.cpp
@@ -31,6 +31,15 @@ namespace dawn::wire { +// Forward GetProcs to the autogen code. It needs to be defined here so that it is exported. (the +// autogen code is part of the code that's agnostic to static vs. shared). +namespace client { +const DawnProcTable& GetAutogenProcs(); +const DawnProcTable& GetProcs() { + return GetAutogenProcs(); +} +} // namespace client + WireClient::WireClient(const WireClientDescriptor& descriptor) : mImpl(new client::Client(descriptor.serializer, descriptor.memoryTransferService)) {}