12#include "flutter/fml/native_library.h"
13#include "flutter/fml/paths.h"
14#include "flutter/fml/size.h"
15#include "flutter/shell/version/version.h"
18#include "flutter/shell/common/switches.h"
20#undef FLUTTER_SHELL_COMMON_SWITCHES_H_
24 const std::string_view
flag;
28#undef DEF_SWITCHES_START
30#undef DEF_SWITCHES_END
33#define DEF_SWITCHES_START static const struct SwitchDesc gSwitchDescs[] = {
34#define DEF_SWITCH(p_swtch, p_flag, p_help) \
35 { flutter::Switch:: p_swtch, p_flag, p_help },
36#define DEF_SWITCHES_END };
44 "--enable-isolate-groups",
45 "--no-enable-isolate-groups",
53 "--enable-isolate-groups",
54 "--no-enable-isolate-groups",
56 "--enable-service-port-fallback",
57 "--max_profile_depth",
60 "--sample-buffer-duration",
63 "--trace-reload-verbose",
64 "--write-service-info",
65 "--max_subtype_cache_entries",
73#include "flutter/shell/common/switches.h"
79extern uint8_t _binary_icudtl_dat_start[];
80extern size_t _binary_icudtl_dat_size;
82static std::unique_ptr<fml::Mapping> GetICUStaticMapping() {
83 return std::make_unique<fml::NonOwnedMapping>(_binary_icudtl_dat_start,
84 _binary_icudtl_dat_size);
91 std::cerr << std::endl <<
" " << executable_name << std::endl << std::endl;
93 std::cerr <<
"Versions: " << std::endl << std::endl;
99 std::cerr <<
"Dart Version: " <<
GetDartVersion() << std::endl << std::endl;
101 std::cerr <<
"Available Flags:" << std::endl;
103 const uint32_t column_width = 80;
105 const uint32_t flags_count =
static_cast<uint32_t
>(Switch::Sentinel);
107 uint32_t max_width = 2;
108 for (uint32_t
i = 0;
i < flags_count;
i++) {
109 auto desc = gSwitchDescs[
i];
110 max_width = std::max<uint32_t>(
desc.flag.size() + 2, max_width);
113 const uint32_t help_width = column_width - max_width - 3;
115 std::cerr << std::string(column_width,
'-') << std::endl;
116 for (uint32_t
i = 0;
i < flags_count;
i++) {
117 auto desc = gSwitchDescs[
i];
119 std::cerr << std::setw(max_width)
120 << std::string(
"--") +
121 std::string{
desc.flag.data(),
desc.flag.size()}
125 int32_t remaining = help_width;
129 remaining -= (
word.size() + 1);
130 if (remaining <= 0) {
131 std::cerr << std::endl
132 << std::string(max_width,
' ') <<
" " <<
word <<
" ";
133 remaining = help_width;
135 std::cerr <<
word <<
" ";
139 std::cerr << std::endl;
141 std::cerr << std::string(column_width,
'-') << std::endl;
145 for (uint32_t
i = 0; i < static_cast<uint32_t>(Switch::Sentinel);
i++) {
146 if (gSwitchDescs[
i].sw == swtch) {
147 return gSwitchDescs[
i].flag;
150 return std::string_view();
154 std::istringstream ss(input);
155 std::vector<std::string>
result;
157 while (std::getline(ss, token,
',')) {
172 if (
flag.length() >= allowed.length() &&
184 std::string switch_string;
190 std::stringstream
stream(switch_string);
201 const std::string& symbol_prefix,
202 const std::string& native_lib_path) {
203 const uint8_t* mapping =
nullptr;
206 auto lookup_symbol = [&mapping, &
size, symbol_prefix](
208 mapping = library->ResolveSymbol((symbol_prefix +
"_start").c_str());
209 size =
reinterpret_cast<intptr_t
>(
210 library->ResolveSymbol((symbol_prefix +
"_size").c_str()));
215 lookup_symbol(library);
217 if (!(mapping &&
size)) {
221 lookup_symbol(library);
224 FML_CHECK(mapping &&
size) <<
"Unable to resolve symbols: " << symbol_prefix;
225 return std::make_unique<fml::NonOwnedMapping>(mapping,
size);
244 settings.enable_vm_service_publication =
262 if (
settings.vm_service_host.empty()) {
273 <<
"VM Service port specified was malformed. Will default to "
283 <<
"VM Service port specified was malformed. Will default to "
296 settings.disable_service_auth_codes =
301 settings.enable_service_port_fallback =
317 settings.enable_software_rendering =
334 settings.trace_skia_allowlist.reset();
336 std::string trace_skia_allowlist;
338 &trace_skia_allowlist);
339 if (trace_skia_allowlist.size()) {
342 settings.trace_skia_allowlist = {
"skia.shaders"};
347 std::string trace_allowlist;
358 settings.skia_deterministic_rendering_on_cpu =
367 std::vector<std::string_view> aot_shared_library_name =
370 std::vector<std::string_view> vmservice_shared_library_name =
373 for (
auto path : vmservice_shared_library_name) {
374 settings.vmservice_snapshot_library_path.emplace_back(
path);
377 std::string snapshot_asset_path;
379 &snapshot_asset_path);
381 std::string vm_snapshot_data_filename;
383 &vm_snapshot_data_filename);
387 std::string vm_snapshot_instr_filename;
389 &vm_snapshot_instr_filename);
391 std::string isolate_snapshot_data_filename;
393 &isolate_snapshot_data_filename);
395 std::string isolate_snapshot_instr_filename;
398 &isolate_snapshot_instr_filename);
400 if (!aot_shared_library_name.empty()) {
401 for (std::string_view
name : aot_shared_library_name) {
404 }
else if (!snapshot_asset_path.empty()) {
408 {snapshot_asset_path, vm_snapshot_instr_filename});
410 {snapshot_asset_path, isolate_snapshot_data_filename});
412 {snapshot_asset_path, isolate_snapshot_instr_filename});
422 if (
settings.icu_initialization_required) {
426 std::string icu_symbol_prefix, native_lib_path;
433 settings.icu_mapper = GetICUStaticMapping;
435 settings.icu_mapper = [icu_symbol_prefix, native_lib_path] {
448 std::string enable_impeller_value;
450 &enable_impeller_value)) {
452 enable_impeller_value.empty() ||
"true" == enable_impeller_value;
457 std::string impeller_backend_value;
459 &impeller_backend_value)) {
460 if (!impeller_backend_value.empty()) {
461 settings.requested_rendering_backend = impeller_backend_value;
468 settings.enable_opengl_gpu_tracing =
470 settings.enable_vulkan_gpu_tracing =
479 std::string all_dart_flags;
496 settings.dump_skp_on_shader_compilation =
506 std::string old_gen_heap_size;
514 std::string resource_cache_max_bytes_threshold;
517 &resource_cache_max_bytes_threshold);
518 settings.resource_cache_max_bytes_threshold =
519 std::stoi(resource_cache_max_bytes_threshold);
static bool equal(const SkBitmap &a, const SkBitmap &b)
const std::string & argv0() const
std::vector< std::string_view > GetOptionValues(std::string_view name) const
std::string GetOptionValueWithDefault(std::string_view name, std::string_view default_value) const
bool HasOption(std::string_view name, size_t *index=nullptr) const
bool GetOptionValue(std::string_view name, std::string *value) const
static fml::RefPtr< NativeLibrary > CreateForCurrentProcess()
static fml::RefPtr< NativeLibrary > Create(const char *path)
FlutterSemanticsFlag flag
FlutterSemanticsFlag flags
#define FML_LOG(severity)
#define FML_CHECK(condition)
bool stoi(std::string_view s, SKSL_INT *value)
const char * GetDartVersion()
const char * GetSkiaVersion()
static bool IsAllowedDartVMFlag(const std::string &flag)
static bool GetSwitchValue(const fml::CommandLine &command_line, Switch sw, T *result)
void PrintUsage(const std::string &executable_name)
Settings SettingsFromCommandLine(const fml::CommandLine &command_line)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir path
const char * GetFlutterEngineVersion()
DEF_SWITCHES_START aot vmservice shared library name
static std::vector< std::string > ParseCommaDelimited(const std::string &input)
it will be possible to load the file into Perfetto s trace viewer disable asset Prevents usage of any non test fonts unless they were explicitly Loaded via prefetched default font Indicates whether the embedding started a prefetch of the default font manager before creating the engine run In non interactive keep the shell running after the Dart script has completed enable serial On low power devices with low core running concurrent GC tasks on threads can cause them to contend with the UI thread which could potentially lead to jank This option turns off all concurrent GC activities domain network JSON encoded network policy per domain This overrides the DisallowInsecureConnections switch Embedder can specify whether to allow or disallow insecure connections at a domain level old gen heap size
std::unique_ptr< fml::Mapping > GetSymbolMapping(const std::string &symbol_prefix, const std::string &native_lib_path)
const std::string_view FlagForSwitch(Switch swtch)
std::string JoinPaths(std::initializer_list< std::string > components)
constexpr std::size_t size(T(&array)[N])
static const std::string kAllowedDartFlags[]
const std::string_view flag