32 return reflector_options;
38 std::shared_ptr<fml::Mapping> source_file_mapping,
47 Compiler(std::move(source_file_mapping), options, sksl_reflector_options);
49 std::cerr <<
"Compilation to SkSL failed." << std::endl;
58 const std::shared_ptr<fml::Mapping>& source_file_mapping) {
62 std::shared_ptr<RuntimeStageData::Shader> sksl_shader;
64 sksl_shader =
CompileSkSL(source_file_mapping, switches);
82 Compiler compiler(source_file_mapping, options, reflector_options);
84 std::cerr <<
"Compilation failed." << std::endl;
90 if (reflector ==
nullptr) {
91 std::cerr <<
"Could not create reflector." << std::endl;
97 std::cerr <<
"Runtime stage information was nil." << std::endl;
106 if (!stage_data_mapping) {
107 std::cerr <<
"Runtime stage data could not be created." << std::endl;
114 std::cerr <<
"Could not write file to " << switches.
sl_file_name
132 auto sl_file_name = std::filesystem::absolute(
133 std::filesystem::current_path() / switches.
sl_file_name);
137 std::cerr <<
"Could not write file to " << switches.
sl_file_name
154 auto reflection_json_name = std::filesystem::absolute(
160 std::cerr <<
"Could not write reflection json to "
167 auto reflection_header_name = std::filesystem::absolute(
173 std::cerr <<
"Could not write reflection header to "
180 auto reflection_cc_name = std::filesystem::absolute(
185 std::cerr <<
"Could not write reflection CC to "
200 std::string result_file;
218 auto depfile_path = std::filesystem::absolute(
219 std::filesystem::current_path() / switches.
depfile_path);
223 std::cerr <<
"Could not write depfile to " << switches.
depfile_path
240 if (!switches.
AreValid(std::cerr)) {
241 std::cerr <<
"Invalid flags specified." << std::endl;
252 std::shared_ptr<fml::FileMapping> source_file_mapping =
254 if (!source_file_mapping) {
255 std::cerr <<
"Could not open input file." << std::endl;
259 if (switches.
iplr && !
OutputIPLR(switches, source_file_mapping)) {
273 Compiler compiler(source_file_mapping, options, reflector_options);
275 std::cerr <<
"Compilation failed." << std::endl;
280 auto spriv_file_name = std::filesystem::absolute(
bool HasOption(std::string_view name, size_t *index=nullptr) const
static std::unique_ptr< FileMapping > CreateReadOnly(const std::string &path)
std::shared_ptr< fml::Mapping > GetSPIRVAssembly() const
const Reflector * GetReflector() const
std::unique_ptr< fml::Mapping > CreateDepfileContents(std::initializer_list< std::string > targets) const
std::shared_ptr< fml::Mapping > GetSLShaderSource() const
std::string GetErrorMessages() const
std::shared_ptr< fml::Mapping > GetReflectionJSON() const
std::shared_ptr< fml::Mapping > GetReflectionCC() const
std::shared_ptr< RuntimeStageData::Shader > GetRuntimeStageShaderData() const
std::shared_ptr< fml::Mapping > GetReflectionHeader() const
std::shared_ptr< fml::Mapping > CreateMapping() const
void AddShader(const std::shared_ptr< Shader > &data)
std::shared_ptr< fml::Mapping > CreateJsonMapping() const
std::vector< TargetPlatform > PlatformsToCompile() const
A vector containing at least one valid platform.
std::filesystem::path reflection_cc_name
std::filesystem::path sl_file_name
std::string shader_bundle
std::shared_ptr< fml::UniqueFD > working_directory
SourceOptions CreateSourceOptions(std::optional< TargetPlatform > target_platform=std::nullopt) const
bool AreValid(std::ostream &explain) const
static void PrintHelp(std::ostream &stream)
std::filesystem::path reflection_json_name
std::filesystem::path spirv_file_name
std::filesystem::path depfile_path
std::filesystem::path source_file_name
std::filesystem::path reflection_header_name
TargetPlatform SelectDefaultTargetPlatform() const
#define FML_DCHECK(condition)
int main(int argc, char const *argv[])
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
void InstallCrashHandler()
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)
bool Main(const fml::CommandLine &command_line)
bool SetPermissiveAccess(const std::filesystem::path &p)
Sets the file access mode of the file at path 'p' to 0644.
std::string InferShaderNameFromPath(const std::filesystem::path &path)
static bool OutputDepfile(const Compiler &compiler, const Switches &switches)
bool GenerateShaderBundle(Switches &switches)
Parses the JSON shader bundle configuration and invokes the compiler multiple times to produce a shad...
static Reflector::Options CreateReflectorOptions(const SourceOptions &options, const Switches &switches)
static bool OutputReflectionData(const Compiler &compiler, const Switches &switches, const SourceOptions &options)
static std::shared_ptr< RuntimeStageData::Shader > CompileSkSL(std::shared_ptr< fml::Mapping > source_file_mapping, const Switches &switches)
static bool OutputIPLR(const Switches &switches, const std::shared_ptr< fml::Mapping > &source_file_mapping)
std::string Utf8FromPath(const std::filesystem::path &path)
Converts a native format path to a utf8 string.
bool TargetPlatformBundlesSkSL(TargetPlatform platform)
bool TargetPlatformNeedsReflection(TargetPlatform platform)
static bool OutputSLFile(const Compiler &compiler, const Switches &switches)
TargetPlatform target_platform
std::string entry_point_name
std::string header_file_name
std::string entry_point_name
TargetPlatform target_platform