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