Flutter Impeller
blobcat_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 
11 namespace impeller {
12 
13 bool Main(const fml::CommandLine& command_line) {
14  BlobWriter writer;
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.AddBlobAtPath(std::string{input})) {
24  std::cerr << "Could not add blob at path: " << input << std::endl;
25  return false;
26  }
27  }
28 
29  auto blob = writer.CreateMapping();
30  if (!blob) {
31  std::cerr << "Could not create combined shader blob." << std::endl;
32  return false;
33  }
34 
35  auto current_directory =
36  fml::OpenDirectory(std::filesystem::current_path().string().c_str(),
37  false, fml::FilePermission::kReadWrite);
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  *blob)) {
42  std::cerr << "Could not write shader blob to path " << output << std::endl;
43  return false;
44  }
45 
46  return true;
47 }
48 
49 } // namespace impeller
50 
51 int main(int argc, char const* argv[]) {
52  return impeller::Main(fml::CommandLineFromPlatformOrArgcArgv(argc, argv))
53  ? EXIT_SUCCESS
54  : EXIT_FAILURE;
55 }
impeller::BlobWriter::CreateMapping
std::shared_ptr< fml::Mapping > CreateMapping() const
Definition: blob_writer.cc:98
impeller::BlobWriter
Definition: blob_writer.h:17
impeller::Main
bool Main(const fml::CommandLine &command_line)
Definition: blobcat_main.cc:13
main
int main(int argc, char const *argv[])
Definition: blobcat_main.cc:51
blob_writer.h
impeller::BlobWriter::AddBlobAtPath
bool AddBlobAtPath(const std::string &path)
Definition: blob_writer.cc:31
impeller
Definition: aiks_context.cc:10