From df0501c7d32e74a24d76c645862eee1f9552754b Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Mon, 4 Nov 2019 09:08:57 -0800 Subject: [PATCH] remove services code (#44052) --- packages/flutter_tools/lib/src/ios/mac.dart | 56 --------- packages/flutter_tools/lib/src/services.dart | 114 ------------------- 2 files changed, 170 deletions(-) delete mode 100644 packages/flutter_tools/lib/src/services.dart diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index d872f19fb5..6ee78cbc36 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -19,14 +19,12 @@ import '../base/process.dart'; import '../base/process_manager.dart'; import '../base/utils.dart'; import '../build_info.dart'; -import '../convert.dart'; import '../flutter_manifest.dart'; import '../globals.dart'; import '../macos/cocoapod_utils.dart'; import '../macos/xcode.dart'; import '../project.dart'; import '../reporting/reporting.dart'; -import '../services.dart'; import 'code_signing.dart'; import 'xcodeproj.dart'; @@ -348,10 +346,6 @@ Future buildXcodeProject({ autoSigningConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); } - // Before the build, all service definitions must be updated and the dylibs - // copied over to a location that is suitable for Xcodebuild to find them. - await _addServicesToBundle(app.project.hostAppRoot); - final FlutterProject project = FlutterProject.current(); await updateGeneratedXcodeProperties( project: project, @@ -686,56 +680,6 @@ bool _checkXcodeVersion() { return true; } -Future _addServicesToBundle(Directory bundle) async { - final List> services = >[]; - printTrace('Trying to resolve native pub services.'); - - // Step 1: Parse the service configuration yaml files present in the service - // pub packages. - await parseServiceConfigs(services); - printTrace('Found ${services.length} service definition(s).'); - - // Step 2: Copy framework dylibs to the correct spot for xcodebuild to pick up. - final Directory frameworksDirectory = fs.directory(fs.path.join(bundle.path, 'Frameworks')); - await _copyServiceFrameworks(services, frameworksDirectory); - - // Step 3: Copy the service definitions manifest at the correct spot for - // xcodebuild to pick up. - final File manifestFile = fs.file(fs.path.join(bundle.path, 'ServiceDefinitions.json')); - _copyServiceDefinitionsManifest(services, manifestFile); -} - -Future _copyServiceFrameworks(List> services, Directory frameworksDirectory) async { - printTrace("Copying service frameworks to '${fs.path.absolute(frameworksDirectory.path)}'."); - frameworksDirectory.createSync(recursive: true); - for (Map service in services) { - final String dylibPath = await getServiceFromUrl(service['ios-framework'], service['root'], service['name']); - final File dylib = fs.file(dylibPath); - printTrace('Copying ${dylib.path} into bundle.'); - if (!dylib.existsSync()) { - printError("The service dylib '${dylib.path}' does not exist."); - continue; - } - // Shell out so permissions on the dylib are preserved. - await processUtils.run( - ['/bin/cp', dylib.path, frameworksDirectory.path], - throwOnError: true, - ); - } -} - -void _copyServiceDefinitionsManifest(List> services, File manifest) { - printTrace("Creating service definitions manifest at '${manifest.path}'"); - final List> jsonServices = services.map>((Map service) => { - 'name': service['name'], - // Since we have already moved it to the Frameworks directory. Strip away - // the directory and basenames. - 'framework': fs.path.basenameWithoutExtension(service['ios-framework']), - }).toList(); - final Map jsonObject = {'services': jsonServices}; - manifest.writeAsStringSync(json.encode(jsonObject), mode: FileMode.write, flush: true); -} - bool upgradePbxProjWithFlutterAssets(IosProject project) { final File xcodeProjectFile = project.xcodeProjectInfoFile; assert(xcodeProjectFile.existsSync()); diff --git a/packages/flutter_tools/lib/src/services.dart b/packages/flutter_tools/lib/src/services.dart deleted file mode 100644 index 51a51dc28a..0000000000 --- a/packages/flutter_tools/lib/src/services.dart +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright 2015 The Chromium Authors. All rights reserved. -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:async'; - -import 'package:yaml/yaml.dart'; - -import 'android/android_sdk.dart'; -import 'base/file_system.dart'; -import 'convert.dart'; -import 'dart/package_map.dart'; -import 'globals.dart'; - -const String _kFlutterManifestPath = 'pubspec.yaml'; -const String _kFlutterServicesManifestPath = 'flutter_services.yaml'; - -dynamic _loadYamlFile(String path) { - printTrace("Looking for YAML at '$path'"); - if (!fs.isFileSync(path)) { - return null; - } - final String manifestString = fs.file(path).readAsStringSync(); - return loadYaml(manifestString); -} - -/// Loads all services specified in `pubspec.yaml`. Parses each service config file, -/// storing meta data in [services] and the list of jar files in [jars]. -Future parseServiceConfigs( - List> services, { - List jars, -}) async { - Map packageMap; - try { - packageMap = PackageMap(PackageMap.globalPackagesPath).map; - } on FormatException catch (error) { - printTrace('Invalid ".packages" file while parsing service configs:\n$error'); - return; - } - - dynamic manifest; - try { - manifest = _loadYamlFile(_kFlutterManifestPath); - manifest = manifest['flutter']; - } catch (error) { - printStatus('Error detected in pubspec.yaml:', emphasis: true); - printError('$error'); - return; - } - if (manifest == null || manifest['services'] == null) { - printTrace('No services specified in the manifest'); - return; - } - - for (String service in manifest['services']) { - final String serviceRoot = packageMap[service].path; - final dynamic serviceConfig = _loadYamlFile('$serviceRoot/$_kFlutterServicesManifestPath'); - if (serviceConfig == null) { - printStatus('No $_kFlutterServicesManifestPath found for service "$serviceRoot"; skipping.'); - continue; - } - - for (Map service in serviceConfig['services']) { - services.add({ - 'root': serviceRoot, - 'name': service['name'], - 'android-class': service['android-class'], - 'ios-framework': service['ios-framework'], - }); - } - - if (jars != null && serviceConfig['jars'] is Iterable) { - for (String jar in serviceConfig['jars']) { - jars.add(fs.file(await getServiceFromUrl(jar, serviceRoot, service))); - } - } - } -} - -Future getServiceFromUrl(String url, String rootDir, String serviceName) async { - if (url.startsWith('android-sdk:') && androidSdk != null) { - // It's something shipped in the standard android SDK. - return url.replaceAll('android-sdk:', '${androidSdk.directory}/'); - } else if (url.startsWith('http:') || url.startsWith('https:')) { - // It's a regular file to download. - return await cache.getThirdPartyFile(url, serviceName); - } else { - // Assume url is a path relative to the service's root dir. - return fs.path.join(rootDir, url); - } -} - -/// Outputs a services.json file for the flutter engine to read. Format: -/// { -/// services: [ -/// { name: string, framework: string }, -/// ... -/// ] -/// } -File generateServiceDefinitions( - String dir, - List> servicesIn, -) { - final List> services = - servicesIn.map>((Map service) => { - 'name': service['name'], - 'class': service['android-class'], - }).toList(); - - final Map jsonObject = {'services': services}; - final File servicesFile = fs.file(fs.path.join(dir, 'services.json')); - servicesFile.writeAsStringSync(json.encode(jsonObject), mode: FileMode.write, flush: true); - return servicesFile; -}