Revert "FFI plugins (#94101)" (#96122)

This reverts commit 5257f0290c.
This commit is contained in:
Zachary Anderson
2022-01-04 08:09:12 -08:00
committed by GitHub
parent 5257f0290c
commit 65c6e88223
52 changed files with 236 additions and 1195 deletions

View File

@@ -48,8 +48,6 @@ void main() {
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'module', 'common'),
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'package'),
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'plugin'),
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'plugin_ffi'),
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'plugin_shared'),
];
for (final String templatePath in templatePaths) {
globals.fs.directory(templatePath).createSync(recursive: true);
@@ -98,9 +96,6 @@ void main() {
await runner.run(<String>['create', '--no-pub', '--template=plugin', 'testy']);
expect((await command.usageValues).commandCreateProjectType, 'plugin');
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', 'testy']);
expect((await command.usageValues).commandCreateProjectType, 'plugin_ffi');
}));
testUsingContext('set iOS host language type as usage value', () => testbed.run(() async {

View File

@@ -2761,71 +2761,6 @@ void main() {
platform: globals.platform,
),
});
testUsingContext('create an FFI plugin with ios, then add macos', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', '--platform=ios', projectDir.path]);
expect(projectDir.childDirectory('src'), exists);
expect(projectDir.childDirectory('ios'), exists);
expect(projectDir.childDirectory('example').childDirectory('ios'), exists);
validatePubspecForPlugin(
projectDir: projectDir.absolute.path,
expectedPlatforms: const <String>[
'ios',
],
ffiPlugin: true,
unexpectedPlatforms: <String>['some_platform'],
);
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', '--platform=macos', projectDir.path]);
expect(projectDir.childDirectory('macos'), exists);
expect(
projectDir.childDirectory('example').childDirectory('macos'), exists);
expect(projectDir.childDirectory('ios'), exists);
expect(projectDir.childDirectory('example').childDirectory('ios'), exists);
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(isMacOSEnabled: true),
});
testUsingContext('FFI plugins error android and ios language', () async {
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
final List<String> args = <String>[
'create',
'--no-pub',
'--template=plugin_ffi',
'-a',
'kotlin',
'--ios-language',
'swift',
'--platforms=ios,android',
projectDir.path,
];
await expectLater(
runner.run(args),
throwsToolExit(
message:
'The "ios-language" option is not supported with the plugin_ffi template: the language will always be C or C++.'));
});
testUsingContext('should show warning when disabled platforms are selected while creating an FFI plugin', () async {
Cache.flutterRoot = '../..';
final CreateCommand command = CreateCommand();
final CommandRunner<void> runner = createTestCommandRunner(command);
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', '--platforms=android,ios,windows,macos,linux', projectDir.path]);
await runner.run(<String>['create', '--no-pub', '--template=plugin_ffi', projectDir.path]);
expect(logger.statusText, contains(_kDisabledPlatformRequestedMessage));
}, overrides: <Type, Generator>{
FeatureFlags: () => TestFeatureFlags(),
Logger: () => logger,
});
}
Future<void> _createProject(

View File

@@ -9,43 +9,33 @@ import '../src/common.dart';
import 'test_utils.dart';
void main() {
late Directory tempDirPluginMethodChannels;
late Directory tempDirPluginFfi;
late Directory tempDir;
setUp(() async {
tempDirPluginMethodChannels = createResolvedTempDirectorySync('flutter_plugin_test.');
tempDirPluginFfi =
createResolvedTempDirectorySync('flutter_ffi_plugin_test.');
tempDir = createResolvedTempDirectorySync('flutter_plugin_test.');
});
tearDown(() async {
tryToDelete(tempDirPluginMethodChannels);
tryToDelete(tempDirPluginFfi);
tryToDelete(tempDir);
});
Future<void> testPlugin({
required String template,
required Directory tempDir,
}) async {
test('plugin example can be built using current Flutter Gradle plugin', () async {
final String flutterBin = fileSystem.path.join(
getFlutterRoot(),
'bin',
'flutter',
);
final String testName = '${template}_test';
processManager.runSync(<String>[
flutterBin,
...getLocalEngineArguments(),
'create',
'--template=$template',
'--template=plugin',
'--platforms=android',
testName,
'plugin_test',
], workingDirectory: tempDir.path);
final Directory exampleAppDir =
tempDir.childDirectory(testName).childDirectory('example');
final Directory exampleAppDir = tempDir.childDirectory('plugin_test').childDirectory('example');
final File buildGradleFile = exampleAppDir.childDirectory('android').childFile('build.gradle');
expect(buildGradleFile, exists);
@@ -78,11 +68,6 @@ void main() {
));
expect(exampleApk, exists);
if (template == 'plugin_ffi') {
// Does not support AGP 3.3.0.
return;
}
// Clean
processManager.runSync(<String>[
flutterBin,
@@ -116,21 +101,5 @@ android.enableR8=true''');
'--target-platform=android-arm',
], workingDirectory: exampleAppDir.path);
expect(exampleApk, exists);
}
test('plugin example can be built using current Flutter Gradle plugin',
() async {
await testPlugin(
template: 'plugin',
tempDir: tempDirPluginMethodChannels,
);
});
test('FFI plugin example can be built using current Flutter Gradle plugin',
() async {
await testPlugin(
template: 'plugin_ffi',
tempDir: tempDirPluginFfi,
);
});
}

View File

@@ -11,23 +11,19 @@ import 'common.dart';
/// Check if the pubspec.yaml file under the `projectDir` is valid for a plugin project.
void validatePubspecForPlugin({
required String projectDir,
String? pluginClass,
bool ffiPlugin = false,
required String pluginClass,
required List<String> expectedPlatforms,
List<String> unexpectedPlatforms = const <String>[],
String? androidIdentifier,
String? webFileName,
}) {
assert(pluginClass != null || ffiPlugin);
final FlutterManifest manifest =
FlutterManifest.createFromPath('$projectDir/pubspec.yaml', fileSystem: globals.fs, logger: globals.logger)!;
final YamlMap platformMaps = YamlMap.wrap(manifest.supportedPlatforms!);
for (final String platform in expectedPlatforms) {
expect(platformMaps[platform], isNotNull);
final YamlMap platformMap = platformMaps[platform]! as YamlMap;
if (pluginClass != null) {
expect(platformMap['pluginClass'], pluginClass);
}
expect(platformMap['pluginClass'], pluginClass);
if (platform == 'android') {
expect(platformMap['package'], androidIdentifier);
}