mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00
Use --packages rather than --package-root
The .packages file is replacing the packages directory of symlinks.
This commit is contained in:
parent
6ffee20bd6
commit
2e062dfab4
2
bin/cache/engine.version
vendored
2
bin/cache/engine.version
vendored
@ -1 +1 @@
|
||||
f7909035f11b1347814ea2c2942426ef3cf7f44d
|
||||
ce3b4547ac579f67a6e473f7f5b5eac4357424ff
|
||||
|
@ -35,7 +35,7 @@ if [ ! -f "$SNAPSHOT_PATH" ] || [ ! -f "$STAMP_PATH" ] || [ `cat "$STAMP_PATH"`
|
||||
echo Building flutter tool...
|
||||
FLUTTER_DIR="$FLUTTER_ROOT/packages/flutter"
|
||||
(cd "$FLUTTER_TOOLS_DIR"; "../../bin/cache/dart-sdk/bin/pub" get --verbosity=warning)
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
||||
echo $REVISION > "$STAMP_PATH"
|
||||
fi
|
||||
|
||||
@ -51,7 +51,7 @@ set +e
|
||||
|
||||
if [ $FLUTTER_DEV ]; then
|
||||
echo -e "(FLUTTER_DEV set - ignoring $SNAPSHOT_PATH)\n"
|
||||
"$DART" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH" "$@"
|
||||
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" "$@"
|
||||
else
|
||||
"$DART" "$SNAPSHOT_PATH" "$@"
|
||||
fi
|
||||
@ -65,5 +65,5 @@ fi
|
||||
|
||||
set -e
|
||||
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --package-root="$FLUTTER_TOOLS_DIR/packages" "$SCRIPT_PATH"
|
||||
"$DART" --snapshot="$SNAPSHOT_PATH" --package="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH"
|
||||
"$DART" "$SNAPSHOT_PATH" "$@"
|
||||
|
@ -38,7 +38,7 @@ CD "%flutter_dir"
|
||||
REM Allows us to check if sky_engine's REVISION is correct
|
||||
CALL pub.bat get
|
||||
CD "%flutter_root%"
|
||||
CALL %dart% --snapshot="%snapshot_path%" --package-root="%flutter_tools_dir%\packages" "%script_path%"
|
||||
CALL %dart% --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
<nul SET /p=%revision%> "%stamp_path%"
|
||||
|
||||
:after_snapshot
|
||||
@ -48,6 +48,6 @@ POPD
|
||||
CALL %dart% "%snapshot_path%" %*
|
||||
|
||||
IF /I "%ERRORLEVEL%" EQU "253" (
|
||||
CALL %dart% --snapshot="%snapshot_path%" --package-root="%flutter_tools_dir%\packages" "%script_path%"
|
||||
CALL %dart% --snapshot="%snapshot_path%" --packages="%flutter_tools_dir%\.packages" "%script_path%"
|
||||
CALL %dart% "%snapshot_path%" %*
|
||||
)
|
||||
|
@ -9,6 +9,9 @@ dependencies:
|
||||
intl: '>=0.12.4+2 <0.13.0'
|
||||
vector_math: '>=1.4.5 <2.0.0'
|
||||
|
||||
# We need to pin crypto because archive can't handle larger numbers.
|
||||
crypto: 0.9.2
|
||||
|
||||
sky_engine:
|
||||
path: ../../bin/cache/pkg/sky_engine
|
||||
sky_services:
|
||||
|
@ -165,27 +165,8 @@ class ArtifactStore {
|
||||
return null;
|
||||
}
|
||||
|
||||
// These values are initialized by FlutterCommandRunner on startup.
|
||||
// Initialized by FlutterCommandRunner on startup.
|
||||
static String flutterRoot;
|
||||
static String packageRoot = 'packages';
|
||||
|
||||
static bool get isPackageRootValid {
|
||||
return FileSystemEntity.isDirectorySync(packageRoot);
|
||||
}
|
||||
|
||||
static void ensurePackageRootIsValid() {
|
||||
if (!isPackageRootValid) {
|
||||
String message = '$packageRoot is not a valid directory.';
|
||||
if (packageRoot == 'packages') {
|
||||
if (FileSystemEntity.isFileSync('pubspec.yaml'))
|
||||
message += '\nDid you run `pub get` in this directory?';
|
||||
else
|
||||
message += '\nDid you run this command from the same directory as your pubspec.yaml file?';
|
||||
}
|
||||
printError(message);
|
||||
throw new ProcessExit(2);
|
||||
}
|
||||
}
|
||||
|
||||
static String _engineRevision;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import 'package:test/src/executable.dart' as executable; // ignore: implementati
|
||||
import '../artifacts.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../globals.dart';
|
||||
import '../package_map.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../test/flutter_platform.dart' as loader;
|
||||
|
||||
@ -99,8 +100,8 @@ class TestCommand extends FlutterCommand {
|
||||
|
||||
// If we're running the flutter tests, we want to use the packages directory
|
||||
// from the flutter package in order to find the proper shell binary.
|
||||
if (runFlutterTests && ArtifactStore.packageRoot == 'packages')
|
||||
ArtifactStore.packageRoot = path.join(ArtifactStore.flutterRoot, 'packages', 'flutter', 'packages');
|
||||
if (runFlutterTests)
|
||||
PackageMap.instance = new PackageMap(path.join(ArtifactStore.flutterRoot, 'packages', 'flutter', '.packages'));
|
||||
|
||||
Directory testDir = runFlutterTests ? _flutterUnitTestDir : _currentPackageTestDir;
|
||||
|
||||
|
@ -467,7 +467,7 @@ class IOSSimulator extends Device {
|
||||
List<String> args = <String>[
|
||||
"--flx=${path.absolute(path.join('build', 'app.flx'))}",
|
||||
"--dart-main=${path.absolute(mainPath)}",
|
||||
"--package-root=${path.absolute('packages')}",
|
||||
"--packages=${path.absolute('.packages')}",
|
||||
];
|
||||
|
||||
if (checked)
|
||||
|
42
packages/flutter_tools/lib/src/package_map.dart
Normal file
42
packages/flutter_tools/lib/src/package_map.dart
Normal file
@ -0,0 +1,42 @@
|
||||
// Copyright 2016 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:io';
|
||||
|
||||
import 'package:package_config/packages_file.dart' as packages_file;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
const String _kPackages = '.packages';
|
||||
|
||||
Map<String, Uri> _parse(String packagesPath) {
|
||||
List<int> source = new File(packagesPath).readAsBytesSync();
|
||||
return packages_file.parse(source, new Uri.file(packagesPath));
|
||||
}
|
||||
|
||||
class PackageMap {
|
||||
PackageMap(this.packagesPath);
|
||||
|
||||
final String packagesPath;
|
||||
|
||||
Map<String, Uri> get map {
|
||||
if (_map == null)
|
||||
_map = _parse(packagesPath);
|
||||
return _map;
|
||||
}
|
||||
Map<String, Uri> _map;
|
||||
|
||||
static PackageMap instance;
|
||||
|
||||
String checkValid() {
|
||||
if (FileSystemEntity.isFileSync(packagesPath))
|
||||
return null;
|
||||
String message = '$packagesPath does not exist.';
|
||||
String pubspecPath = path.absolute(path.dirname(packagesPath), 'pubspec.yaml');
|
||||
if (FileSystemEntity.isFileSync(pubspecPath))
|
||||
message += '\nDid you run `pub get` in this directory?';
|
||||
else
|
||||
message += '\nDid you run this command from the same directory as your pubspec.yaml file?';
|
||||
return message;
|
||||
}
|
||||
}
|
@ -7,12 +7,13 @@ import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
|
||||
import '../dart/pub.dart';
|
||||
import '../application_package.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../dart/pub.dart';
|
||||
import '../device.dart';
|
||||
import '../flx.dart' as flx;
|
||||
import '../globals.dart';
|
||||
import '../package_map.dart';
|
||||
import '../toolchain.dart';
|
||||
import 'flutter_command_runner.dart';
|
||||
|
||||
@ -147,6 +148,12 @@ abstract class FlutterCommand extends Command {
|
||||
}
|
||||
}
|
||||
|
||||
String error = PackageMap.instance.checkValid();
|
||||
if (error != null) {
|
||||
printError(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -9,13 +9,14 @@ import 'package:args/args.dart';
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../android/android_sdk.dart';
|
||||
import '../artifacts.dart';
|
||||
import '../android/android_sdk.dart';
|
||||
import '../base/context.dart';
|
||||
import '../base/logger.dart';
|
||||
import '../base/process.dart';
|
||||
import '../build_configuration.dart';
|
||||
import '../globals.dart';
|
||||
import '../package_map.dart';
|
||||
import 'version.dart';
|
||||
|
||||
const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo)
|
||||
@ -41,13 +42,13 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
help: 'Reports the version of this tool.');
|
||||
|
||||
String packagesHelp;
|
||||
if (ArtifactStore.isPackageRootValid)
|
||||
packagesHelp = '\n(defaults to "${ArtifactStore.packageRoot}")';
|
||||
if (FileSystemEntity.isFileSync('.packages'))
|
||||
packagesHelp = '\n(defaults to ".packages")';
|
||||
else
|
||||
packagesHelp = '\n(required, since the current directory does not contain a "packages" subdirectory)';
|
||||
argParser.addOption('package-root',
|
||||
packagesHelp = '\n(required, since the current directory does not contain a ".packages" file)';
|
||||
argParser.addOption('packages',
|
||||
hide: !verboseHelp,
|
||||
help: 'Path to your packages directory.$packagesHelp');
|
||||
help: 'Path to your ".packages" file.$packagesHelp');
|
||||
argParser.addOption('flutter-root',
|
||||
help: 'The root directory of the Flutter repository (uses \$$kFlutterRootEnvironmentVariableName if set).',
|
||||
defaultsTo: _defaultFlutterRoot);
|
||||
@ -184,8 +185,9 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
// we must set ArtifactStore.flutterRoot early because other features use it
|
||||
// (e.g. enginePath's initialiser uses it)
|
||||
ArtifactStore.flutterRoot = path.normalize(path.absolute(globalResults['flutter-root']));
|
||||
if (globalResults.wasParsed('package-root'))
|
||||
ArtifactStore.packageRoot = path.normalize(path.absolute(globalResults['package-root']));
|
||||
PackageMap.instance = new PackageMap(path.normalize(path.absolute(
|
||||
globalResults.wasParsed('packages') ? globalResults['packages'] : '.packages'
|
||||
)));
|
||||
|
||||
// See if the user specified a specific device.
|
||||
deviceManager.specifiedDeviceId = globalResults['device-id'];
|
||||
@ -219,16 +221,13 @@ class FlutterCommandRunner extends CommandRunner {
|
||||
bool isRelease = globalResults['release'];
|
||||
|
||||
if (engineSourcePath == null && (isDebug || isRelease)) {
|
||||
if (ArtifactStore.isPackageRootValid) {
|
||||
Directory engineDir = new Directory(path.join(ArtifactStore.packageRoot, kFlutterEnginePackageName));
|
||||
try {
|
||||
String realEnginePath = engineDir.resolveSymbolicLinksSync();
|
||||
engineSourcePath = path.dirname(path.dirname(path.dirname(path.dirname(realEnginePath))));
|
||||
bool dirExists = FileSystemEntity.isDirectorySync(path.join(engineSourcePath, 'out'));
|
||||
if (engineSourcePath == '/' || engineSourcePath.isEmpty || !dirExists)
|
||||
engineSourcePath = null;
|
||||
} on FileSystemException { }
|
||||
}
|
||||
try {
|
||||
Uri engineUri = PackageMap.instance.map[kFlutterEnginePackageName];
|
||||
engineSourcePath = path.dirname(path.dirname(path.dirname(path.dirname(engineUri.path))));
|
||||
bool dirExists = FileSystemEntity.isDirectorySync(path.join(engineSourcePath, 'out'));
|
||||
if (engineSourcePath == '/' || engineSourcePath.isEmpty || !dirExists)
|
||||
engineSourcePath = null;
|
||||
} on FileSystemException { } on FormatException { }
|
||||
|
||||
if (engineSourcePath == null)
|
||||
engineSourcePath = _tryEnginePath(path.join(ArtifactStore.flutterRoot, '../engine/src'));
|
||||
|
@ -11,6 +11,7 @@ import 'package:yaml/yaml.dart';
|
||||
|
||||
import 'artifacts.dart';
|
||||
import 'globals.dart';
|
||||
import 'package_map.dart';
|
||||
|
||||
const String _kFlutterManifestPath = 'flutter.yaml';
|
||||
const String _kFlutterServicesManifestPath = 'flutter_services.yaml';
|
||||
@ -28,22 +29,25 @@ dynamic _loadYamlFile(String path) {
|
||||
Future<Null> parseServiceConfigs(
|
||||
List<Map<String, String>> services, { List<File> jars }
|
||||
) async {
|
||||
if (!ArtifactStore.isPackageRootValid) {
|
||||
printTrace("Artifact store invalid while parsing service configs");
|
||||
Map<String, Uri> packageMap;
|
||||
try {
|
||||
packageMap = PackageMap.instance.map;
|
||||
} on FormatException catch(e) {
|
||||
printTrace('Invalid ".packages" file while parsing service configs:\n$e');
|
||||
return;
|
||||
}
|
||||
|
||||
dynamic manifest = _loadYamlFile(_kFlutterManifestPath);
|
||||
if (manifest == null || manifest['services'] == null) {
|
||||
printTrace("No services specified in the manifest");
|
||||
printTrace('No services specified in the manifest');
|
||||
return;
|
||||
}
|
||||
|
||||
for (String service in manifest['services']) {
|
||||
String serviceRoot = '${ArtifactStore.packageRoot}/$service';
|
||||
String serviceRoot = packageMap[service].path;
|
||||
dynamic serviceConfig = _loadYamlFile('$serviceRoot/$_kFlutterServicesManifestPath');
|
||||
if (serviceConfig == null) {
|
||||
printStatus("No $_kFlutterServicesManifestPath found for service '$serviceRoot'. Skipping.");
|
||||
printStatus('No $_kFlutterServicesManifestPath found for service "$serviceRoot". Skipping.');
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,7 @@ import 'package:test/src/backend/test_platform.dart'; // ignore: implementation_
|
||||
import 'package:test/src/runner/plugin/platform.dart'; // ignore: implementation_imports
|
||||
import 'package:test/src/runner/plugin/hack_register_platform.dart' as hack; // ignore: implementation_imports
|
||||
|
||||
import '../artifacts.dart';
|
||||
import '../package_map.dart';
|
||||
|
||||
final String _kSkyShell = Platform.environment['SKY_SHELL'];
|
||||
const String _kHost = '127.0.0.1';
|
||||
@ -44,12 +44,12 @@ Future<_ServerInfo> _startServer() async {
|
||||
return new _ServerInfo(server, 'ws://$_kHost:${server.port}$_kPath', socket.future);
|
||||
}
|
||||
|
||||
Future<Process> _startProcess(String mainPath, { String packageRoot }) {
|
||||
Future<Process> _startProcess(String mainPath, { String packages }) {
|
||||
assert(shellPath != null || _kSkyShell != null); // Please provide the path to the shell in the SKY_SHELL environment variable.
|
||||
return Process.start(shellPath ?? _kSkyShell, [
|
||||
'--enable-checked-mode',
|
||||
'--non-interactive',
|
||||
'--package-root=$packageRoot',
|
||||
'--packages=$packages',
|
||||
mainPath,
|
||||
]);
|
||||
}
|
||||
@ -90,8 +90,7 @@ void main() {
|
||||
''');
|
||||
|
||||
Process process = await _startProcess(
|
||||
listenerFile.path,
|
||||
packageRoot: path.absolute(ArtifactStore.packageRoot)
|
||||
listenerFile.path, packages: PackageMap.instance.packagesPath
|
||||
);
|
||||
|
||||
void finalize() {
|
||||
|
@ -10,6 +10,7 @@ import 'package:path/path.dart' as path;
|
||||
import 'artifacts.dart';
|
||||
import 'base/process.dart';
|
||||
import 'build_configuration.dart';
|
||||
import 'package_map.dart';
|
||||
|
||||
class SnapshotCompiler {
|
||||
SnapshotCompiler(this._path);
|
||||
@ -25,7 +26,7 @@ class SnapshotCompiler {
|
||||
final List<String> args = [
|
||||
_path,
|
||||
mainPath,
|
||||
'--package-root=${ArtifactStore.packageRoot}',
|
||||
'--packages=${PackageMap.instance.packagesPath}',
|
||||
'--snapshot=$snapshotPath'
|
||||
];
|
||||
if (depfilePath != null)
|
||||
|
@ -11,11 +11,12 @@ dependencies:
|
||||
analyzer: '>=0.26.1+17' # see note below
|
||||
archive: ^1.0.20
|
||||
args: ^0.13.4
|
||||
crypto: ^0.9.2
|
||||
crypto: 0.9.2
|
||||
den_api: ^0.1.0
|
||||
file: ^0.1.0
|
||||
json_schema: ^1.0.3
|
||||
mustache4dart: ^1.0.0
|
||||
package_config: ^0.1.3
|
||||
path: ^1.3.0
|
||||
pub_semver: ^1.0.0
|
||||
stack_trace: ^1.4.0
|
||||
|
@ -7,7 +7,7 @@ dependencies:
|
||||
bignum: ^0.1.0
|
||||
asn1lib: ^0.4.1
|
||||
pointycastle: 0.10.0
|
||||
crypto: ^0.9.2
|
||||
crypto: 0.9.2
|
||||
|
||||
environment:
|
||||
sdk: '>=1.12.0 <2.0.0'
|
||||
|
Loading…
Reference in New Issue
Block a user