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 <string_view>
6
7#include "flutter/common/settings.h"
8#include "flutter/fml/command_line.h"
9
10#ifndef SHELL_COMMON_SWITCHES_H_
11#define SHELL_COMMON_SWITCHES_H_
12
13namespace flutter {
14
15// clang-format off
16#ifndef DEF_SWITCHES_START
17#define DEF_SWITCHES_START enum class Switch {
18#endif
19#ifndef DEF_SWITCH
20#define DEF_SWITCH(swtch, flag, help) swtch,
21#endif
22#ifndef DEF_SWITCHES_END
23#define DEF_SWITCHES_END Sentinel, } ;
24#endif
25// clang-format on
26
27DEF_SWITCHES_START
28DEF_SWITCH(AotSharedLibraryName,
29 "aot-shared-library-name",
30 "Name of the *.so containing AOT compiled Dart assets.")
31DEF_SWITCH(SnapshotAssetPath,
32 "snapshot-asset-path",
33 "Path to the directory containing the four files specified by "
34 "VmSnapshotData, VmSnapshotInstructions, "
35 "VmSnapshotInstructions and IsolateSnapshotInstructions.")
36DEF_SWITCH(VmSnapshotData,
37 "vm-snapshot-data",
38 "The VM snapshot data that will be memory mapped as read-only. "
39 "SnapshotAssetPath must be present.")
40DEF_SWITCH(VmSnapshotInstructions,
41 "vm-snapshot-instr",
42 "The VM instructions snapshot that will be memory mapped as read "
43 "and executable. SnapshotAssetPath must be present.")
44DEF_SWITCH(IsolateSnapshotData,
45 "isolate-snapshot-data",
46 "The isolate snapshot data that will be memory mapped as read-only. "
47 "SnapshotAssetPath must be present.")
48DEF_SWITCH(IsolateSnapshotInstructions,
49 "isolate-snapshot-instr",
50 "The isolate instructions snapshot that will be memory mapped as "
51 "read and executable. SnapshotAssetPath must be present.")
52DEF_SWITCH(CacheDirPath,
53 "cache-dir-path",
54 "Path to the cache directory. "
55 "This is different from the persistent_cache_path in embedder.h, "
56 "which is used for Skia shader cache.")
57DEF_SWITCH(ICUDataFilePath, "icu-data-file-path", "Path to the ICU data file.")
58DEF_SWITCH(ICUSymbolPrefix,
59 "icu-symbol-prefix",
60 "Prefix for the symbols representing ICU data linked into the "
61 "Flutter library.")
62DEF_SWITCH(ICUNativeLibPath,
63 "icu-native-lib-path",
64 "Path to the library file that exports the ICU data.")
65DEF_SWITCH(DartFlags,
66 "dart-flags",
67 "Flags passed directly to the Dart VM without being interpreted "
68 "by the Flutter shell.")
69DEF_SWITCH(DeviceObservatoryHost,
70 "observatory-host",
71 "The hostname/IP address on which the Dart Observatory should "
72 "be served. If not set, defaults to 127.0.0.1 or ::1 depending on "
73 "whether --ipv6 is specified.")
74DEF_SWITCH(DeviceObservatoryPort,
75 "observatory-port",
76 "A custom Dart Observatory port. The default is to pick a randomly "
77 "available open port.")
78DEF_SWITCH(DisableObservatory,
79 "disable-observatory",
80 "Disable the Dart Observatory. The observatory is never available "
81 "in release mode.")
82DEF_SWITCH(IPv6,
83 "ipv6",
84 "Bind to the IPv6 localhost address for the Dart Observatory. "
85 "Ignored if --observatory-host is set.")
86DEF_SWITCH(EnableDartProfiling,
87 "enable-dart-profiling",
88 "Enable Dart profiling. Profiling information can be viewed from "
89 "the observatory.")
90DEF_SWITCH(EndlessTraceBuffer,
91 "endless-trace-buffer",
92 "Enable an endless trace buffer. The default is a ring buffer. "
93 "This is useful when very old events need to viewed. For example, "
94 "during application launch. Memory usage will continue to grow "
95 "indefinitely however.")
96DEF_SWITCH(EnableSoftwareRendering,
97 "enable-software-rendering",
98 "Enable rendering using the Skia software backend. This is useful "
99 "when testing Flutter on emulators. By default, Flutter will "
100 "attempt to either use OpenGL or Vulkan.")
101DEF_SWITCH(SkiaDeterministicRendering,
102 "skia-deterministic-rendering",
103 "Skips the call to SkGraphics::Init(), thus avoiding swapping out "
104 "some Skia function pointers based on available CPU features. This "
105 "is used to obtain 100% deterministic behavior in Skia rendering.")
106DEF_SWITCH(FlutterAssetsDir,
107 "flutter-assets-dir",
108 "Path to the Flutter assets directory.")
109DEF_SWITCH(Help, "help", "Display this help text.")
110DEF_SWITCH(LogTag, "log-tag", "Tag associated with log messages.")
111DEF_SWITCH(DisableServiceAuthCodes,
112 "disable-service-auth-codes",
113 "Disable the requirement for authentication codes for communicating"
114 " with the VM service.")
115DEF_SWITCH(EnableServicePortFallback,
116 "enable-service-port-fallback",
117 "Allow the VM service to fallback to automatic port selection if"
118 " binding to a specified port fails.")
119DEF_SWITCH(StartPaused,
120 "start-paused",
121 "Start the application paused in the Dart debugger.")
122DEF_SWITCH(EnableCheckedMode, "enable-checked-mode", "Enable checked mode.")
123DEF_SWITCH(TraceStartup,
124 "trace-startup",
125 "Trace early application lifecycle. Automatically switches to an "
126 "endless trace buffer.")
127DEF_SWITCH(TraceSkia,
128 "trace-skia",
129 "Trace Skia calls. This is useful when debugging the GPU threed."
130 "By default, Skia tracing is not enabled to reduce the number of "
131 "traced events")
132DEF_SWITCH(TraceWhitelist,
133 "trace-whitelist",
134 "(deprecated) Use --trace-allowlist instead.")
135DEF_SWITCH(
136 TraceAllowlist,
137 "trace-allowlist",
138 "Filters out all trace events except those that are specified in this "
139 "comma separated list of allowed prefixes.")
140DEF_SWITCH(DumpSkpOnShaderCompilation,
141 "dump-skp-on-shader-compilation",
142 "Automatically dump the skp that triggers new shader compilations. "
143 "This is useful for writing custom ShaderWarmUp to reduce jank. "
144 "By default, this is not enabled to reduce the overhead. ")
145DEF_SWITCH(CacheSkSL,
146 "cache-sksl",
147 "Only cache the shader in SkSL instead of binary or GLSL. This "
148 "should only be used during development phases. The generated SkSLs "
149 "can later be used in the release build for shader precompilation "
150 "at launch in order to eliminate the shader-compile jank.")
151DEF_SWITCH(PurgePersistentCache,
152 "purge-persistent-cache",
153 "Remove all existing persistent cache. This is mainly for debugging "
154 "purposes such as reproducing the shader compilation jank.")
155DEF_SWITCH(
156 TraceSystrace,
157 "trace-systrace",
158 "Trace to the system tracer (instead of the timeline) on platforms where "
159 "such a tracer is available. Currently only supported on Android and "
160 "Fuchsia.")
161DEF_SWITCH(UseTestFonts,
162 "use-test-fonts",
163 "Running tests that layout and measure text will not yield "
164 "consistent results across various platforms. Enabling this option "
165 "will make font resolution default to the Ahem test font on all "
166 "platforms (See https://www.w3.org/Style/CSS/Test/Fonts/Ahem/). "
167 "This option is only available on the desktop test shells.")
168DEF_SWITCH(VerboseLogging,
169 "verbose-logging",
170 "By default, only errors are logged. This flag enabled logging at "
171 "all severity levels. This is NOT a per shell flag and affect log "
172 "levels for all shells in the process.")
173DEF_SWITCH(RunForever,
174 "run-forever",
175 "In non-interactive mode, keep the shell running after the Dart "
176 "script has completed.")
177DEF_SWITCH(DisableDartAsserts,
178 "disable-dart-asserts",
179 "Dart code runs with assertions enabled when the runtime mode is "
180 "debug. In profile and release product modes, assertions are "
181 "disabled. This flag may be specified if the user wishes to run "
182 "with assertions disabled in the debug product mode (i.e. with JIT "
183 "or DBC).")
184DEF_SWITCH(DisallowInsecureConnections,
185 "disallow-insecure-connections",
186 "By default, dart:io allows all socket connections. If this switch "
187 "is set, all insecure connections are rejected.")
188DEF_SWITCH(DomainNetworkPolicy,
189 "domain-network-policy",
190 "JSON encoded network policy per domain. This overrides the "
191 "DisallowInsecureConnections switch. Embedder can specify whether "
192 "to allow or disallow insecure connections at a domain level.")
193DEF_SWITCH(
194 ForceMultithreading,
195 "force-multithreading",
196 "Uses separate threads for the platform, UI, GPU and IO task runners. "
197 "By default, a single thread is used for all task runners. Only available "
198 "in the flutter_tester.")
199// TODO(cyanlaz): Remove this when dynamic thread merging is done.
200// https://github.com/flutter/flutter/issues/59930
201DEF_SWITCH(UseEmbeddedView,
202 "use-embedded-view",
203 "Whether an android application uses embedded views."
204 "This is a temporary flag to make the raster task runner runs on "
205 "the platform thread."
206 "This flag should be removed once the dynamic thread merging is "
207 "enabled on android.")
208DEF_SWITCHES_END
209
210void PrintUsage(const std::string& executable_name);
211
212const std::string_view FlagForSwitch(Switch swtch);
213
214Settings SettingsFromCommandLine(const fml::CommandLine& command_line);
215
216} // namespace flutter
217
218#endif // SHELL_COMMON_SWITCHES_H_
219