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"
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;
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;
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;
48 
50 
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;
60 
61  // Creates source options from these switches for the specified
62  // TargetPlatform. Uses SelectDefaultTargetPlatform if not specified.
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_
std::vector< TargetPlatform > PlatformsToCompile() const
A vector containing at least one valid platform.
Definition: switches.cc:305
std::filesystem::path reflection_cc_name
Definition: switches.h:37
std::string entry_point_prefix
Definition: switches.h:45
std::filesystem::path sl_file_name
Definition: switches.h:31
SourceLanguage source_language
Definition: switches.h:41
std::vector< std::string > defines
Definition: switches.h:39
std::shared_ptr< fml::UniqueFD > working_directory
Definition: switches.h:24
SourceOptions CreateSourceOptions(std::optional< TargetPlatform > target_platform=std::nullopt) const
Definition: switches.cc:320
bool AreValid(std::ostream &explain) const
Definition: switches.cc:252
static void PrintHelp(std::ostream &stream)
Definition: switches.cc:42
std::filesystem::path reflection_json_name
Definition: switches.h:35
std::filesystem::path spirv_file_name
Definition: switches.h:34
std::filesystem::path depfile_path
Definition: switches.h:38
std::vector< IncludeDir > include_directories
Definition: switches.h:25
std::filesystem::path source_file_name
Definition: switches.h:26
std::filesystem::path reflection_header_name
Definition: switches.h:36
TargetPlatform SelectDefaultTargetPlatform() const
Definition: switches.cc:312