18 std::replace(test_name.begin(), test_name.end(),
'/',
'_');
19 std::replace(test_name.begin(), test_name.end(),
'.',
'_');
20 std::stringstream dir_name;
28 intermediates_directory_ =
36 intermediates_directory_.
reset();
38 std::filesystem::remove_all(std::filesystem::path(intermediates_path_));
42 std::stringstream stream;
43 stream << fixture_name <<
".h";
48 std::stringstream stream;
49 stream << fixture_name <<
".cc";
54 std::stringstream stream;
55 stream << fixture_name <<
".json";
60 std::stringstream stream;
61 stream << fixture_name <<
".spv";
67 std::stringstream stream;
73 const char* fixture_name)
const {
80 const char* fixture_name,
82 auto filename =
SLFileName(fixture_name, platform);
88 const char* fixture_name,
91 const char* entry_point_name)
const {
92 std::shared_ptr<fml::Mapping> fixture =
94 if (!fixture || !fixture->GetMapping()) {
95 VALIDATION_LOG <<
"Could not find shader in fixtures: " << fixture_name;
112 Compiler compiler(fixture, source_options, reflector_options);
119 if (!spirv_assembly) {
148 <<
"No reflector was found for target platform SL compiler.";
153 auto reflection_header = reflector->GetReflectionHeader();
154 auto reflection_source = reflector->GetReflectionCC();
156 if (!reflection_json) {
161 if (!reflection_header) {
166 if (!reflection_source) {
173 *reflection_header)) {
174 VALIDATION_LOG <<
"Could not write reflection header intermediates.";
180 *reflection_source)) {
188 VALIDATION_LOG <<
"Could not write reflection json intermediates.";
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
void reset(const T &value=Traits::InvalidValue())
std::shared_ptr< fml::Mapping > GetSPIRVAssembly() const
const Reflector * GetReflector() const
std::shared_ptr< fml::Mapping > GetSLShaderSource() const
std::string GetErrorMessages() const
std::shared_ptr< fml::Mapping > GetReflectionJSON() const
bool CanCompileAndReflect(const char *fixture_name, SourceType source_type=SourceType::kUnknown, SourceLanguage source_language=SourceLanguage::kGLSL, const char *entry_point_name="main") const
std::unique_ptr< fml::FileMapping > GetReflectionJson(const char *fixture_name) const
std::unique_ptr< fml::FileMapping > GetShaderFile(const char *fixture_name, TargetPlatform platform) const
#define FML_CHECK(condition)
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
const char * GetFixturesPath()
Returns the directory containing the test fixture for the target if this target has fixtures configur...
fml::UniqueFD OpenFixturesDirectory()
Opens the fixtures directory for the unit-test harness.
std::unique_ptr< fml::Mapping > OpenFixtureAsMapping(const std::string &fixture_name)
Opens a fixture of the given file name and returns a mapping to its contents.
std::string JoinPaths(std::initializer_list< std::string > components)
fml::UniqueFD OpenFileReadOnly(const fml::UniqueFD &base_directory, const char *path)
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
static std::string ReflectionCCName(const char *fixture_name)
static std::string ReflectionJSONName(const char *fixture_name)
static std::string GetIntermediatesPath()
static std::string ReflectionHeaderName(const char *fixture_name)
static std::string SLFileName(const char *fixture_name, TargetPlatform platform)
static std::string SPIRVFileName(const char *fixture_name)
std::string TargetPlatformSLExtension(TargetPlatform platform)
SourceType SourceTypeFromFileName(const std::filesystem::path &file_name)
std::string EntryPointFunctionNameFromSourceName(const std::filesystem::path &file_name, SourceType type, SourceLanguage source_language, const std::string &entry_point_name)
bool TargetPlatformNeedsReflection(TargetPlatform platform)
std::string header_file_name
SourceLanguage source_language
std::string entry_point_name
TargetPlatform target_platform
std::shared_ptr< fml::UniqueFD > working_directory