6 #include <system_error>
8 #include "flutter/fml/backtrace.h"
9 #include "flutter/fml/command_line.h"
10 #include "flutter/fml/file.h"
11 #include "flutter/fml/mapping.h"
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) {
59 FML_DCHECK(switches.
iplr);
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(
156 if (!fml::WriteAtomically(
160 std::cerr <<
"Could not write reflection json to "
167 auto reflection_header_name =
168 std::filesystem::absolute(std::filesystem::current_path() /
170 if (!fml::WriteAtomically(
174 std::cerr <<
"Could not write reflection header to "
181 auto reflection_cc_name =
182 std::filesystem::absolute(std::filesystem::current_path() /
187 std::cerr <<
"Could not write reflection CC to "
202 std::string result_file;
220 auto depfile_path = std::filesystem::absolute(
221 std::filesystem::current_path() / switches.
depfile_path.c_str());
225 std::cerr <<
"Could not write depfile to " << switches.
depfile_path
234 bool Main(
const fml::CommandLine& command_line) {
235 fml::InstallCrashHandler();
236 if (command_line.HasOption(
"help")) {
242 if (!switches.
AreValid(std::cerr)) {
243 std::cerr <<
"Invalid flags specified." << std::endl;
254 std::shared_ptr<fml::FileMapping> source_file_mapping =
256 if (!source_file_mapping) {
257 std::cerr <<
"Could not open input file." << std::endl;
261 if (switches.
iplr && !
OutputIPLR(switches, source_file_mapping)) {
275 Compiler compiler(source_file_mapping, options, reflector_options);
277 std::cerr <<
"Compilation failed." << std::endl;
282 auto spriv_file_name = std::filesystem::absolute(
310 int main(
int argc,
char const* argv[]) {
312 fml::CommandLineFromPlatformOrArgcArgv(argc, argv))
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::string reflection_json_name
std::string reflection_header_name
std::string shader_bundle
std::shared_ptr< fml::UniqueFD > working_directory
SourceOptions CreateSourceOptions(std::optional< TargetPlatform > target_platform=std::nullopt) const
std::string reflection_cc_name
std::string spirv_file_name
bool AreValid(std::ostream &explain) const
static void PrintHelp(std::ostream &stream)
std::string source_file_name
TargetPlatform SelectDefaultTargetPlatform() const
int main(int argc, 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.
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 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)
static std::shared_ptr< RuntimeStageData::Shader > CompileSkSL(std::shared_ptr< fml::Mapping > source_file_mapping, const Switches &switches)
bool TargetPlatformNeedsReflection(TargetPlatform platform)
static bool OutputSLFile(const Compiler &compiler, const Switches &switches)
std::string InferShaderNameFromPath(std::string_view path)
TargetPlatform target_platform
std::string entry_point_name
std::string header_file_name
std::string entry_point_name
TargetPlatform target_platform