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/macros.h"
12 #include "flutter/fml/mapping.h"
19 #include "third_party/shaderc/libshaderc/include/shaderc/shaderc.hpp"
27 std::filesystem::perms::owner_read | std::filesystem::perms::owner_write |
28 std::filesystem::perms::group_read | std::filesystem::perms::others_read;
29 std::error_code error;
30 std::filesystem::permissions(p, permissions, error);
32 std::cerr <<
"Failed to set access on file '" << p
33 <<
"': " << error.message() << std::endl;
39 bool Main(
const fml::CommandLine& command_line) {
40 fml::InstallCrashHandler();
41 if (command_line.HasOption(
"help")) {
48 std::cerr <<
"Invalid flags specified." << std::endl;
53 std::shared_ptr<fml::FileMapping> source_file_mapping =
55 if (!source_file_mapping) {
56 std::cerr <<
"Could not open input file." << std::endl;
89 std::shared_ptr<fml::Mapping> sksl_mapping;
98 Compiler(source_file_mapping, sksl_options, sksl_reflector_options);
100 std::cerr <<
"Compilation to SkSL failed." << std::endl;
107 Compiler compiler(source_file_mapping, options, reflector_options);
109 std::cerr <<
"Compilation failed." << std::endl;
114 auto spriv_file_name = std::filesystem::absolute(
124 auto sl_file_name = std::filesystem::absolute(
125 std::filesystem::current_path() / switches.
sl_file_name);
128 if (reflector ==
nullptr) {
129 std::cerr <<
"Could not create reflector." << std::endl;
134 std::cerr <<
"Runtime stage information was nil." << std::endl;
138 stage_data->SetSkSLData(sksl_mapping);
141 ? stage_data->CreateJsonMapping()
142 : stage_data->CreateMapping();
143 if (!stage_data_mapping) {
144 std::cerr <<
"Runtime stage data could not be created." << std::endl;
151 std::cerr <<
"Could not write file to " << switches.
sl_file_name
164 std::cerr <<
"Could not write file to " << switches.
sl_file_name
172 auto reflection_json_name = std::filesystem::absolute(
174 if (!fml::WriteAtomically(
178 std::cerr <<
"Could not write reflection json to "
185 auto reflection_header_name =
186 std::filesystem::absolute(std::filesystem::current_path() /
188 if (!fml::WriteAtomically(
192 std::cerr <<
"Could not write reflection header to "
199 auto reflection_cc_name =
200 std::filesystem::absolute(std::filesystem::current_path() /
205 std::cerr <<
"Could not write reflection CC to "
213 std::string result_file;
230 auto depfile_path = std::filesystem::absolute(
231 std::filesystem::current_path() / switches.
depfile_path.c_str());
235 std::cerr <<
"Could not write depfile to " << switches.
depfile_path
247 int main(
int argc,
char const* argv[]) {
249 fml::CommandLineFromPlatformOrArgcArgv(argc, argv))