Commit 8a2ee2c0 authored by Adam Barth's avatar Adam Barth

Merge pull request #2960 from abarth/use_packages

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