Stop tint.h from including program_builder.h
ProgramBuilder is about as internal as you can get - this really should not be public.
MSVC seems to try an instantiate some of the template methods in ProgramBuilder when it is included externally (for PCH or DLL exports perhaps?), and failing with bizzare error messages that contain no point-of-instantiation.
As this header was never intended to be public in the first place, detect and error if the tint.h include guard is found while processing program_builder.h, and fix up the couple of bad transitive includes.
Fixes tint -> dawn autoroller
Change-Id: Ic9a81a44ab1b4a29a7297b94bbf85bcfdb1310b5
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53384
Auto-Submit: Ben Clayton <bclayton@google.com>
Commit-Queue: James Price <jrprice@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: James Price <jrprice@google.com>
diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc
index 00bc302..2dddfbe 100644
--- a/src/inspector/inspector_test.cc
+++ b/src/inspector/inspector_test.cc
@@ -18,6 +18,7 @@
#include "src/ast/stage_decoration.h"
#include "src/ast/struct_block_decoration.h"
#include "src/ast/workgroup_decoration.h"
+#include "src/program_builder.h"
#include "src/sem/depth_texture_type.h"
#include "src/sem/external_texture_type.h"
#include "src/sem/multisampled_texture_type.h"
diff --git a/src/program_builder.h b/src/program_builder.h
index 55995b5..8a38e18 100644
--- a/src/program_builder.h
+++ b/src/program_builder.h
@@ -78,6 +78,10 @@
#include "src/sem/vector_type.h"
#include "src/sem/void_type.h"
+#ifdef INCLUDE_TINT_TINT_H_
+#error "internal tint header being #included from tint.h"
+#endif
+
namespace tint {
// Forward declarations
diff --git a/src/writer/hlsl/generator.cc b/src/writer/hlsl/generator.cc
index 7fdc28a..d55e70c 100644
--- a/src/writer/hlsl/generator.cc
+++ b/src/writer/hlsl/generator.cc
@@ -14,6 +14,8 @@
#include "src/writer/hlsl/generator.h"
+#include "src/writer/hlsl/generator_impl.h"
+
namespace tint {
namespace writer {
namespace hlsl {
diff --git a/src/writer/hlsl/generator.h b/src/writer/hlsl/generator.h
index 614a62d..3623dd5 100644
--- a/src/writer/hlsl/generator.h
+++ b/src/writer/hlsl/generator.h
@@ -18,13 +18,15 @@
#include <memory>
#include <string>
-#include "src/writer/hlsl/generator_impl.h"
#include "src/writer/text.h"
namespace tint {
namespace writer {
namespace hlsl {
+// Forward declarations
+class GeneratorImpl;
+
/// Class to generate HLSL source
class Generator : public Text {
public:
diff --git a/src/writer/spirv/generator.cc b/src/writer/spirv/generator.cc
index d000b11..8a1e598 100644
--- a/src/writer/spirv/generator.cc
+++ b/src/writer/spirv/generator.cc
@@ -14,6 +14,8 @@
#include "src/writer/spirv/generator.h"
+#include "src/writer/spirv/binary_writer.h"
+
namespace tint {
namespace writer {
namespace spirv {
@@ -35,6 +37,10 @@
return true;
}
+const std::vector<uint32_t>& Generator::result() const {
+ return writer_->result();
+}
+
} // namespace spirv
} // namespace writer
} // namespace tint
diff --git a/src/writer/spirv/generator.h b/src/writer/spirv/generator.h
index b5b1614..5227a3f 100644
--- a/src/writer/spirv/generator.h
+++ b/src/writer/spirv/generator.h
@@ -19,13 +19,16 @@
#include <string>
#include <vector>
-#include "src/writer/spirv/binary_writer.h"
#include "src/writer/writer.h"
namespace tint {
namespace writer {
namespace spirv {
+/// Forward declarations
+class Builder;
+class BinaryWriter;
+
/// Class to generate SPIR-V from a Tint program
class Generator : public writer::Writer {
public:
@@ -41,7 +44,7 @@
bool Generate() override;
/// @returns the result data
- const std::vector<uint32_t>& result() const { return writer_->result(); }
+ const std::vector<uint32_t>& result() const;
private:
std::unique_ptr<Builder> builder_;