-
Notifications
You must be signed in to change notification settings - Fork 30.5k
adds linux impeller project flag #186982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
adds linux impeller project flag #186982
Changes from all commits
1ff0761
ebe2e50
6fa4a99
e05ec92
5506fcc
756e902
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,56 +16,126 @@ Future<TaskResult> run() async { | |||||||||||||||||||||
| deviceOperatingSystem = DeviceOperatingSystem.linux; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final Directory appDir = dir(path.join(flutterDirectory.path, 'examples/hello_world')); | ||||||||||||||||||||||
| final String myApplicationPath = path.join(appDir.path, 'linux', 'runner', 'my_application.cc'); | ||||||||||||||||||||||
| final myApplicationFile = File(myApplicationPath); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const vulkanBackendMessage = 'Using the Impeller rendering backend (VulkanSDF).'; | ||||||||||||||||||||||
| const openGLBackendMessage = 'Using the Impeller rendering backend (OpenGLESSDF).'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| var res = TaskResult.success(null); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| try { | ||||||||||||||||||||||
| await inDirectory(appDir, () async { | ||||||||||||||||||||||
| await flutter('packages', options: <String>['get']); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final Process process = await startFlutter( | ||||||||||||||||||||||
| 'run', | ||||||||||||||||||||||
| options: <String>['--enable-impeller', '-d', 'linux'], | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final completer = Completer<void>(); | ||||||||||||||||||||||
| var sawImpellerBackendMessage = false; | ||||||||||||||||||||||
| const vulkanBackendMessage = 'Using the Impeller rendering backend (VulkanSDF).'; | ||||||||||||||||||||||
| const openGLBackendMessage = 'Using the Impeller rendering backend (OpenGLESSDF).'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final StreamSubscription<String> subscription = process.stdout | ||||||||||||||||||||||
| .transform(utf8.decoder) | ||||||||||||||||||||||
| .transform(const LineSplitter()) | ||||||||||||||||||||||
| .listen((String line) { | ||||||||||||||||||||||
| print('[STDOUT]: $line'); | ||||||||||||||||||||||
| if (line.contains(vulkanBackendMessage) || line.contains(openGLBackendMessage)) { | ||||||||||||||||||||||
| sawImpellerBackendMessage = true; | ||||||||||||||||||||||
| if (!completer.isCompleted) { | ||||||||||||||||||||||
| completer.complete(); | ||||||||||||||||||||||
| // Step 1: Test using command line flag. | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| final Process process = await startFlutter( | ||||||||||||||||||||||
| 'run', | ||||||||||||||||||||||
| options: <String>['--enable-impeller', '-d', 'linux'], | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final completer = Completer<void>(); | ||||||||||||||||||||||
| var sawImpellerBackendMessage = false; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final StreamSubscription<String> subscription = process.stdout | ||||||||||||||||||||||
| .transform(utf8.decoder) | ||||||||||||||||||||||
| .transform(const LineSplitter()) | ||||||||||||||||||||||
| .listen((String line) { | ||||||||||||||||||||||
| print('[STDOUT 1]: $line'); | ||||||||||||||||||||||
| if (line.contains(vulkanBackendMessage) || line.contains(openGLBackendMessage)) { | ||||||||||||||||||||||
| sawImpellerBackendMessage = true; | ||||||||||||||||||||||
| if (!completer.isCompleted) { | ||||||||||||||||||||||
| completer.complete(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await Future.any(<Future<void>>[ | ||||||||||||||||||||||
| completer.future, | ||||||||||||||||||||||
| Future<void>.delayed(const Duration(minutes: 2)), | ||||||||||||||||||||||
| ]); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| process.stdin.writeln('q'); | ||||||||||||||||||||||
| final int exitCode = await process.exitCode; | ||||||||||||||||||||||
| await subscription.cancel(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (exitCode != 0) { | ||||||||||||||||||||||
| res = TaskResult.failure('Flutter process exited with non-zero exit code: $exitCode'); | ||||||||||||||||||||||
| } else if (!sawImpellerBackendMessage) { | ||||||||||||||||||||||
| res = TaskResult.failure( | ||||||||||||||||||||||
| 'Did not see "$vulkanBackendMessage" or ' | ||||||||||||||||||||||
| '"$openGLBackendMessage" in output', | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await Future.any(<Future<void>>[ | ||||||||||||||||||||||
| completer.future, | ||||||||||||||||||||||
| Future<void>.delayed(const Duration(minutes: 2)), | ||||||||||||||||||||||
| ]); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| process.stdin.writeln('q'); | ||||||||||||||||||||||
| final int exitCode = await process.exitCode; | ||||||||||||||||||||||
| await subscription.cancel(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (exitCode != 0) { | ||||||||||||||||||||||
| res = TaskResult.failure('Flutter process 1 exited with non-zero exit code: $exitCode'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } else if (!sawImpellerBackendMessage) { | ||||||||||||||||||||||
| res = TaskResult.failure( | ||||||||||||||||||||||
| 'Did not see "$vulkanBackendMessage" or ' | ||||||||||||||||||||||
| '"$openGLBackendMessage" in output (Step 1)', | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Step 2: Test using project flag. | ||||||||||||||||||||||
| { | ||||||||||||||||||||||
| if (!myApplicationFile.existsSync()) { | ||||||||||||||||||||||
| res = TaskResult.failure('my_application.cc not found at $myApplicationPath'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final String originalContent = myApplicationFile.readAsStringSync(); | ||||||||||||||||||||||
| final String modifiedContent = originalContent.replaceFirst( | ||||||||||||||||||||||
|
Comment on lines
+82
to
+83
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Assign the read content to the
Suggested change
|
||||||||||||||||||||||
| 'g_autoptr(FlDartProject) project = fl_dart_project_new();', | ||||||||||||||||||||||
| 'g_autoptr(FlDartProject) project = fl_dart_project_new();\n fl_dart_project_set_enable_impeller(project, TRUE);', | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| if (modifiedContent == originalContent) { | ||||||||||||||||||||||
| res = TaskResult.failure('Failed to modify my_application.cc'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| myApplicationFile.writeAsStringSync(modifiedContent); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| // Run 'flutter run' without command-line flag --enable-impeller. | ||||||||||||||||||||||
| final Process process = await startFlutter('run', options: <String>['-d', 'linux']); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final completer = Completer<void>(); | ||||||||||||||||||||||
| var sawImpellerBackendMessage = false; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| final StreamSubscription<String> subscription = process.stdout | ||||||||||||||||||||||
| .transform(utf8.decoder) | ||||||||||||||||||||||
| .transform(const LineSplitter()) | ||||||||||||||||||||||
| .listen((String line) { | ||||||||||||||||||||||
| print('[STDOUT 2]: $line'); | ||||||||||||||||||||||
| if (line.contains(vulkanBackendMessage) || line.contains(openGLBackendMessage)) { | ||||||||||||||||||||||
| sawImpellerBackendMessage = true; | ||||||||||||||||||||||
| if (!completer.isCompleted) { | ||||||||||||||||||||||
| completer.complete(); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| await Future.any(<Future<void>>[ | ||||||||||||||||||||||
| completer.future, | ||||||||||||||||||||||
| Future<void>.delayed(const Duration(minutes: 2)), | ||||||||||||||||||||||
| ]); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| process.stdin.writeln('q'); | ||||||||||||||||||||||
| final int exitCode = await process.exitCode; | ||||||||||||||||||||||
| await subscription.cancel(); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if (exitCode != 0) { | ||||||||||||||||||||||
| res = TaskResult.failure('Flutter process 2 exited with non-zero exit code: $exitCode'); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } else if (!sawImpellerBackendMessage) { | ||||||||||||||||||||||
| res = TaskResult.failure( | ||||||||||||||||||||||
| 'Did not see "$vulkanBackendMessage" or ' | ||||||||||||||||||||||
| '"$openGLBackendMessage" in output (Step 2)', | ||||||||||||||||||||||
| ); | ||||||||||||||||||||||
| return; | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| }); | ||||||||||||||||||||||
| } catch (e) { | ||||||||||||||||||||||
| res = TaskResult.failure('Test failed with exception: $e'); | ||||||||||||||||||||||
| } finally { | ||||||||||||||||||||||
| if (myApplicationFile.existsSync()) { | ||||||||||||||||||||||
| await exec('git', <String>['checkout', myApplicationPath]); | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
| } | ||||||||||||||||||||||
|
Comment on lines
+135
to
139
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Restore the original content of
Suggested change
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return res; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -812,6 +812,19 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { | |
| break; | ||
| } | ||
|
|
||
| gboolean enable_impeller = fl_dart_project_get_enable_impeller(self->project); | ||
| gboolean has_enable_impeller = FALSE; | ||
| for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) { | ||
| if (env_switch == "--enable-impeller" || | ||
| env_switch == "--enable-impeller=true") { | ||
| enable_impeller = TRUE; | ||
| has_enable_impeller = TRUE; | ||
| } else if (env_switch == "--enable-impeller=false") { | ||
| enable_impeller = FALSE; | ||
| has_enable_impeller = TRUE; | ||
| } | ||
| } | ||
|
Comment on lines
+815
to
+826
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use standard C++ bool enable_impeller = fl_dart_project_get_enable_impeller(self->project);
bool has_enable_impeller = false;
for (const auto& env_switch : flutter::GetSwitchesFromEnvironment()) {
if (env_switch == "--enable-impeller" ||
env_switch == "--enable-impeller=true") {
enable_impeller = true;
has_enable_impeller = true;
} else if (env_switch == "--enable-impeller=false") {
enable_impeller = false;
has_enable_impeller = true;
}
}References
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems like a reasonable suggestion, but I'd defer to @robert-ancell here
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is using gboolean so it's correct to use TRUE/FALSE instead (this is done elsewhere). |
||
|
|
||
| g_autoptr(GPtrArray) command_line_args = | ||
| g_ptr_array_new_with_free_func(g_free); | ||
| g_ptr_array_insert(command_line_args, 0, g_strdup("flutter")); | ||
|
|
@@ -821,6 +834,10 @@ gboolean fl_engine_start(FlEngine* self, GError** error) { | |
| // Linux (and other desktop platforms) always uses SDFs. | ||
| g_ptr_array_add(command_line_args, g_strdup("--impeller-use-sdfs")); | ||
|
|
||
| if (enable_impeller && !has_enable_impeller) { | ||
| g_ptr_array_add(command_line_args, g_strdup("--enable-impeller")); | ||
| } | ||
|
|
||
| gchar** dart_entrypoint_args = | ||
| fl_dart_project_get_dart_entrypoint_arguments(self->project); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Declare a variable to store the original content of
my_application.ccso we can restore it in thefinallyblock without spawning agit checkoutprocess.