| Flutter Impeller |

switches.h
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 #ifndef FLUTTER_IMPELLER_COMPILER_SWITCHES_H_
6 #define FLUTTER_IMPELLER_COMPILER_SWITCHES_H_
7
8 #include <cstdint>
9 #include <iostream>
10 #include <memory>
11
12 #include "flutter/fml/command_line.h"
13 #include "flutter/fml/unique_fd.h"
14 #include "impeller/compiler/include_dir.h"
15 #include "impeller/compiler/source_options.h"
16 #include "impeller/compiler/types.h"
17
18 namespace impeller {
19 namespace compiler {
20
21 class Switches {
22 public:
23 std::shared_ptr<fml::UniqueFD> working_directory = nullptr;
24 std::vector<IncludeDir> include_directories = {};
25 std::string source_file_name = "";
26 SourceType input_type = SourceType::kUnknown;
27 /// The raw shader file output by the compiler. For --iplr and
28 /// --shader-bundle modes, this is used as the filename for the output
29 /// flatbuffer output.
30 std::string sl_file_name = "";
31 bool iplr = false;
32 std::string shader_bundle = "";
33 std::string spirv_file_name = "";
34 std::string reflection_json_name = "";
35 std::string reflection_header_name = "";
36 std::string reflection_cc_name = "";
37 std::string depfile_path = "";
38 std::vector<std::string> defines = {};
39 bool json_format = false;
40 SourceLanguage source_language = SourceLanguage::kUnknown;
41 uint32_t gles_language_version = 0;
42 std::string metal_version = "";
43 std::string entry_point = "";
44 bool use_half_textures = false;
45 bool require_framebuffer_fetch = false;
46
47 Switches();
48
49 ~Switches();
50
51 explicit Switches(const fml::CommandLine& command_line);
52
53 bool AreValid(std::ostream& explain) const;
54
55 /// A vector containing at least one valid platform.
56 std::vector<TargetPlatform> PlatformsToCompile() const;
57 TargetPlatform SelectDefaultTargetPlatform() const;
58
59 // Creates source options from these switches for the specified
60 // TargetPlatform. Uses SelectDefaultTargetPlatform if not specified.
61 SourceOptions CreateSourceOptions(
62 std::optional<TargetPlatform> target_platform = std::nullopt) const;
63
64 static void PrintHelp(std::ostream& stream);
65
66 private:
67 // Use |SelectDefaultTargetPlatform|.
68 TargetPlatform target_platform_ = TargetPlatform::kUnknown;
69 // Use |PlatformsToCompile|.
70 std::vector<TargetPlatform> runtime_stages_ = {};
71 };
72
73 } // namespace compiler
74 } // namespace impeller
75
76 #endif // FLUTTER_IMPELLER_COMPILER_SWITCHES_H_
impeller::compiler::Switches::reflection_cc_name
std::string reflection_cc_name
Definition: switches.h:36
impeller::compiler::Switches::reflection_header_name
std::string reflection_header_name
Definition: switches.h:35
impeller::compiler::SourceType::kUnknown
@ kUnknown
impeller::compiler::Switches::PrintHelp
static void PrintHelp(std::ostream &stream)
Definition: switches.cc:41
impeller::compiler::Switches::SelectDefaultTargetPlatform
TargetPlatform SelectDefaultTargetPlatform() const
Definition: switches.cc:298
impeller::compiler::SourceOptions
Definition: source_options.h:20
impeller::compiler::Switches::metal_version
std::string metal_version
Definition: switches.h:42
impeller::compiler::Switches::gles_language_version
uint32_t gles_language_version
Definition: switches.h:41
impeller::compiler::TargetPlatform
TargetPlatform
Definition: types.h:28
impeller::compiler::Switches::spirv_file_name
std::string spirv_file_name
Definition: switches.h:33
impeller::compiler::Switches::json_format
bool json_format
Definition: switches.h:39
impeller::compiler::Switches::use_half_textures
bool use_half_textures
Definition: switches.h:44
impeller::compiler::Switches::reflection_json_name
std::string reflection_json_name
Definition: switches.h:34
impeller::compiler::Switches::require_framebuffer_fetch
bool require_framebuffer_fetch
Definition: switches.h:45
impeller::compiler::Switches::defines
std::vector< std::string > defines
Definition: switches.h:38
source_options.h
impeller::compiler::SourceType
SourceType
Definition: types.h:21
impeller::compiler::SourceLanguage::kUnknown
@ kUnknown
impeller::compiler::Switches::sl_file_name
std::string sl_file_name
Definition: switches.h:30
impeller::compiler::Switches::PlatformsToCompile
std::vector< TargetPlatform > PlatformsToCompile() const
A vector containing at least one valid platform.
Definition: switches.cc:291
impeller::compiler::Switches::iplr
bool iplr
Definition: switches.h:31
impeller::compiler::Switches::input_type
SourceType input_type
Definition: switches.h:26
impeller::compiler::SourceLanguage
SourceLanguage
Definition: types.h:41
impeller::compiler::TargetPlatform::kUnknown
@ kUnknown
impeller::compiler::Switches::CreateSourceOptions
SourceOptions CreateSourceOptions(std::optional< TargetPlatform > target_platform=std::nullopt) const
Definition: switches.cc:305
impeller::compiler::Switches::source_language
SourceLanguage source_language
Definition: switches.h:40
impeller::compiler::Switches::entry_point
std::string entry_point
Definition: switches.h:43
impeller::compiler::Switches
Definition: switches.h:21
impeller::compiler::Switches::include_directories
std::vector< IncludeDir > include_directories
Definition: switches.h:24
impeller::compiler::Switches::depfile_path
std::string depfile_path
Definition: switches.h:37
impeller
Definition: aiks_context.cc:10
impeller::compiler::Switches::source_file_name
std::string source_file_name
Definition: switches.h:25
impeller::compiler::Switches::~Switches
~Switches()
impeller::compiler::Switches::working_directory
std::shared_ptr< fml::UniqueFD > working_directory
Definition: switches.h:23
types.h
include_dir.h
impeller::compiler::Switches::shader_bundle
std::string shader_bundle
Definition: switches.h:32
impeller::compiler::Switches::Switches
Switches()
impeller::compiler::Switches::AreValid
bool AreValid(std::ostream &explain) const
Definition: switches.cc:239