Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
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
"
9
#include "
impeller/shader_archive/shader_archive_writer.h
"
10
11
namespace
impeller
{
12
13
bool
Main
(
const
fml::CommandLine
& command_line) {
14
ShaderArchiveWriter
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
std::string prefix;
23
if
(command_line.
GetOptionValue
(
"entry-point-prefix"
, &prefix)) {
24
writer.
SetEntryPointPrefix
(prefix);
25
}
26
27
for
(
const
auto
&
input
: command_line.
GetOptionValues
(
"input"
)) {
28
if
(!writer.
AddShaderAtPath
(std::string{input})) {
29
std::cerr <<
"Could not add shader at path: "
<<
input
<< std::endl;
30
return
false
;
31
}
32
}
33
34
auto
archive = writer.
CreateMapping
();
35
if
(!archive) {
36
std::cerr <<
"Could not create shader archive."
<< std::endl;
37
return
false
;
38
}
39
40
auto
current_directory =
41
fml::OpenDirectory
(std::filesystem::current_path().
string
().c_str(),
42
false
,
fml::FilePermission::kReadWrite
);
43
auto
output_path =
44
std::filesystem::absolute(std::filesystem::current_path() / output);
45
if
(!
fml::WriteAtomically
(current_directory, output_path.string().c_str(),
46
*archive)) {
47
std::cerr <<
"Could not write shader archive to path "
<< output
48
<< std::endl;
49
return
false
;
50
}
51
52
return
true
;
53
}
54
55
}
// namespace impeller
56
57
int
main
(
int
argc,
char
const
*
argv
[]) {
58
return
impeller::Main
(
fml::CommandLineFromPlatformOrArgcArgv
(argc,
argv
))
59
? EXIT_SUCCESS
60
: EXIT_FAILURE;
61
}
fml::CommandLine
Definition
command_line.h:56
fml::CommandLine::GetOptionValues
std::vector< std::string_view > GetOptionValues(std::string_view name) const
Definition
command_line.cc:61
fml::CommandLine::GetOptionValue
bool GetOptionValue(std::string_view name, std::string *value) const
Definition
command_line.cc:51
impeller::ShaderArchiveWriter
Definition
shader_archive_writer.h:17
impeller::ShaderArchiveWriter::AddShaderAtPath
bool AddShaderAtPath(const std::string &path)
Definition
shader_archive_writer.cc:40
impeller::ShaderArchiveWriter::CreateMapping
std::shared_ptr< fml::Mapping > CreateMapping() const
Definition
shader_archive_writer.cc:111
impeller::ShaderArchiveWriter::SetEntryPointPrefix
void SetEntryPointPrefix(std::string prefix)
Definition
shader_archive_writer.cc:20
input
static int input(yyscan_t yyscanner)
command_line.h
argv
char ** argv
Definition
library.h:9
fml::WriteAtomically
bool WriteAtomically(const fml::UniqueFD &base_directory, const char *file_name, const Mapping &mapping)
Definition
file_posix.cc:191
fml::OpenDirectory
fml::UniqueFD OpenDirectory(const char *path, bool create_if_necessary, FilePermission permission)
Definition
file_posix.cc:97
fml::CommandLineFromPlatformOrArgcArgv
CommandLine CommandLineFromPlatformOrArgcArgv(int argc, const char *const *argv)
Definition
command_line.h:240
fml::FilePermission::kReadWrite
@ kReadWrite
impeller
Definition
texture.h:16
impeller::Main
bool Main(const fml::CommandLine &command_line)
Definition
shader_archive_main.cc:13
main
int main(int argc, char const *argv[])
Definition
shader_archive_main.cc:57
shader_archive_writer.h
impeller
shader_archive
shader_archive_main.cc
Generated on Wed Dec 31 2025 04:49:46 for Flutter Engine Uber Docs by
1.9.8