Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
shader_archive_main.cc
Go to the documentation of this file.
1// Copyright 2013 The Flutter Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#include <filesystem>
6#include <iostream>
7
8#include "flutter/fml/command_line.h"
10
11namespace impeller {
12
13bool Main(const fml::CommandLine& command_line) {
15
16 std::string output;
17 if (!command_line.GetOptionValue("output", &output)) {
18 std::cerr << "Output path not specified." << std::endl;
19 return false;
20 }
21
22 for (const auto& input : command_line.GetOptionValues("input")) {
23 if (!writer.AddShaderAtPath(std::string{input})) {
24 std::cerr << "Could not add shader at path: " << input << std::endl;
25 return false;
26 }
27 }
28
29 auto archive = writer.CreateMapping();
30 if (!archive) {
31 std::cerr << "Could not create shader archive." << std::endl;
32 return false;
33 }
34
35 auto current_directory =
36 fml::OpenDirectory(std::filesystem::current_path().string().c_str(),
38 auto output_path =
39 std::filesystem::absolute(std::filesystem::current_path() / output);
40 if (!fml::WriteAtomically(current_directory, output_path.string().c_str(),
41 *archive)) {
42 std::cerr << "Could not write shader archive to path " << output
43 << std::endl;
44 return false;
45 }
46
47 return true;
48}
49
50} // namespace impeller
51
52int main(int argc, char const* argv[]) {
54 ? EXIT_SUCCESS
55 : EXIT_FAILURE;
56}
std::vector< std::string_view > GetOptionValues(std::string_view name) const
bool GetOptionValue(std::string_view name, std::string *value) const
bool AddShaderAtPath(const std::string &path)
std::shared_ptr< fml::Mapping > CreateMapping() const
char ** argv
Definition library.h:9
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)
Definition file_posix.cc:97
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)
bool Main(const fml::CommandLine &command_line)
Definition main.py:1