FFI plugins (#96225)

This commit is contained in:
Daco Harkes
2022-01-26 23:44:45 +01:00
committed by GitHub
parent f15dd780d4
commit 0e2f51dfd0
59 changed files with 1441 additions and 254 deletions

View File

@@ -18,5 +18,7 @@ Future<void> main() async {
<String, String>{'ENABLE_ANDROID_EMBEDDING_V2': 'true'}),
// Test that Dart-only plugins are supported.
PluginTest('apk', <String>['--platforms=android'], dartOnlyPlugin: true),
// Test that FFI plugins are supported.
PluginTest('apk', <String>['--platforms=android'], template: 'plugin_ffi'),
]));
}

View File

@@ -13,5 +13,8 @@ Future<void> main() async {
// Test that Dart-only plugins are supported.
PluginTest('ios', <String>['--platforms=ios'], dartOnlyPlugin: true),
PluginTest('macos', <String>['--platforms=macos'], dartOnlyPlugin: true),
// Test that FFI plugins are supported.
PluginTest('ios', <String>['--platforms=ios'], template: 'plugin_ffi'),
PluginTest('macos', <String>['--platforms=macos'], template: 'plugin_ffi'),
]));
}

View File

@@ -32,6 +32,7 @@ class PluginTest {
this.pluginCreateEnvironment,
this.appCreateEnvironment,
this.dartOnlyPlugin = false,
this.template = 'plugin',
});
final String buildTarget;
@@ -39,20 +40,27 @@ class PluginTest {
final Map<String, String>? pluginCreateEnvironment;
final Map<String, String>? appCreateEnvironment;
final bool dartOnlyPlugin;
final String template;
Future<TaskResult> call() async {
final Directory tempDir =
Directory.systemTemp.createTempSync('flutter_devicelab_plugin_test.');
// FFI plugins do not have support for `flutter test`.
// `flutter test` does not do a native build.
// Supporting `flutter test` would require invoking a native build.
final bool runFlutterTest = template != 'plugin_ffi';
try {
section('Create plugin');
final _FlutterProject plugin = await _FlutterProject.create(
tempDir, options, buildTarget,
name: 'plugintest', template: 'plugin', environment: pluginCreateEnvironment);
name: 'plugintest', template: template, environment: pluginCreateEnvironment);
if (dartOnlyPlugin) {
await plugin.convertDefaultPluginToDartPlugin();
}
section('Test plugin');
await plugin.test();
if (runFlutterTest) {
await plugin.test();
}
section('Create Flutter app');
final _FlutterProject app = await _FlutterProject.create(tempDir, options, buildTarget,
name: 'plugintestapp', template: 'app', environment: appCreateEnvironment);
@@ -63,8 +71,10 @@ class PluginTest {
await app.addPlugin('path_provider');
section('Build app');
await app.build(buildTarget, validateNativeBuildProject: !dartOnlyPlugin);
section('Test app');
await app.test();
if (runFlutterTest) {
section('Test app');
await app.test();
}
} finally {
await plugin.delete();
await app.delete();

View File

@@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_windows
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries})
endforeach(plugin)
foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST})
add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)