Commit f34d3171 authored by Devon Carew's avatar Devon Carew

complain on missing entries in flutter.yaml (#3731)

* complain on missing entries in flutter.yaml

* change to a hard failure
parent 04e892a4
...@@ -48,7 +48,7 @@ export PATH="$DART_SDK_PATH/bin:$PATH" ...@@ -48,7 +48,7 @@ export PATH="$DART_SDK_PATH/bin:$PATH"
set +e set +e
if [ $FLUTTER_DEV ]; then if [ $FLUTTER_DEV ]; then
"$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" "$SCRIPT_PATH" "$@" "$DART" --packages="$FLUTTER_TOOLS_DIR/.packages" -c "$SCRIPT_PATH" "$@"
else else
"$DART" "$SNAPSHOT_PATH" "$@" "$DART" "$SNAPSHOT_PATH" "$@"
fi fi
......
...@@ -313,6 +313,9 @@ class AndroidDevice extends Device { ...@@ -313,6 +313,9 @@ class AndroidDevice extends Device {
includeRobotoFonts: false includeRobotoFonts: false
); );
if (localBundlePath == null)
return new LaunchResult.failed();
printTrace('Starting bundle for $this.'); printTrace('Starting bundle for $this.');
return startBundle( return startBundle(
......
...@@ -504,6 +504,9 @@ Future<int> buildAndroid( ...@@ -504,6 +504,9 @@ Future<int> buildAndroid(
mainPath: findMainDartFile(target), mainPath: findMainDartFile(target),
precompiledSnapshot: isAotBuildMode(buildMode), precompiledSnapshot: isAotBuildMode(buildMode),
includeRobotoFonts: false); includeRobotoFonts: false);
if (flxPath == null)
return 1;
} }
// Build an AOT snapshot if needed. // Build an AOT snapshot if needed.
......
...@@ -50,6 +50,12 @@ class _Asset { ...@@ -50,6 +50,12 @@ class _Asset {
final String source; final String source;
File get assetFile {
return new File(source != null ? '$base/$source' : '$base/$relativePath');
}
bool get assetFileExists => assetFile.existsSync();
/// The delta between what the assetEntry is and the relativePath (e.g., /// The delta between what the assetEntry is and the relativePath (e.g.,
/// packages/material_gallery). /// packages/material_gallery).
String get symbolicPrefix { String get symbolicPrefix {
...@@ -95,6 +101,8 @@ List<_Asset> _getMaterialAssets(String fontSet) { ...@@ -95,6 +101,8 @@ List<_Asset> _getMaterialAssets(String fontSet) {
/// Given an assetBase location and a flutter.yaml manifest, return a map of /// Given an assetBase location and a flutter.yaml manifest, return a map of
/// assets to asset variants. /// assets to asset variants.
///
/// Returns `null` on missing assets.
Map<_Asset, List<_Asset>> _parseAssets( Map<_Asset, List<_Asset>> _parseAssets(
PackageMap packageMap, PackageMap packageMap,
Map<String, dynamic> manifestDescriptor, Map<String, dynamic> manifestDescriptor,
...@@ -113,6 +121,11 @@ Map<_Asset, List<_Asset>> _parseAssets( ...@@ -113,6 +121,11 @@ Map<_Asset, List<_Asset>> _parseAssets(
for (String asset in manifestDescriptor['assets']) { for (String asset in manifestDescriptor['assets']) {
_Asset baseAsset = _resolveAsset(packageMap, assetBase, asset); _Asset baseAsset = _resolveAsset(packageMap, assetBase, asset);
if (!baseAsset.assetFileExists) {
printError('Error: unable to locate asset entry in flutter.yaml: "$asset".');
return null;
}
List<_Asset> variants = <_Asset>[]; List<_Asset> variants = <_Asset>[];
result[baseAsset] = variants; result[baseAsset] = variants;
...@@ -196,22 +209,24 @@ Future<int> _validateManifest(Object manifest) async { ...@@ -196,22 +209,24 @@ Future<int> _validateManifest(Object manifest) async {
Schema schema = await Schema.createSchemaFromUrl('file://$schemaPath'); Schema schema = await Schema.createSchemaFromUrl('file://$schemaPath');
Validator validator = new Validator(schema); Validator validator = new Validator(schema);
if (validator.validate(manifest)) if (validator.validate(manifest)) {
return 0; return 0;
} else {
if (validator.errors.length == 1) {
printError('Error in flutter.yaml: ${validator.errors.first}');
} else {
printError('Error in flutter.yaml:'); printError('Error in flutter.yaml:');
printError(validator.errors.join('\n')); printError(' ' + validator.errors.join('\n '));
}
return 1; return 1;
}
} }
/// Create a [ZipEntry] from the given [_Asset]; the asset must exist.
ZipEntry _createAssetEntry(_Asset asset) { ZipEntry _createAssetEntry(_Asset asset) {
String source = asset.source ?? asset.relativePath; assert(asset.assetFileExists);
File file = new File('${asset.base}/$source'); return new ZipEntry.fromFile(asset.assetEntry, asset.assetFile);
if (!file.existsSync()) {
printError('Cannot find asset "$source" in directory "${path.absolute(asset.base)}".');
return null;
}
return new ZipEntry.fromFile(asset.assetEntry, file);
} }
ZipEntry _createAssetManifest(Map<_Asset, List<_Asset>> assetVariants) { ZipEntry _createAssetManifest(Map<_Asset, List<_Asset>> assetVariants) {
...@@ -242,6 +257,8 @@ ZipEntry _createFontManifest(Map<String, dynamic> manifestDescriptor, ...@@ -242,6 +257,8 @@ ZipEntry _createFontManifest(Map<String, dynamic> manifestDescriptor,
} }
/// Build the flx in the build/ directory and return `localBundlePath` on success. /// Build the flx in the build/ directory and return `localBundlePath` on success.
///
/// Return `null` on failure.
Future<String> buildFlx( Future<String> buildFlx(
Toolchain toolchain, { Toolchain toolchain, {
String mainPath: defaultMainPath, String mainPath: defaultMainPath,
...@@ -259,10 +276,7 @@ Future<String> buildFlx( ...@@ -259,10 +276,7 @@ Future<String> buildFlx(
precompiledSnapshot: precompiledSnapshot, precompiledSnapshot: precompiledSnapshot,
includeRobotoFonts: includeRobotoFonts includeRobotoFonts: includeRobotoFonts
); );
if (result == 0) return result == 0 ? localBundlePath : null;
return localBundlePath;
else
throw result;
} }
/// The result from [buildInTempDir]. Note that this object should be disposed after use. /// The result from [buildInTempDir]. Note that this object should be disposed after use.
...@@ -349,6 +363,9 @@ Future<int> assemble({ ...@@ -349,6 +363,9 @@ Future<int> assemble({
excludeDirs: <String>[workingDirPath, path.join(assetBasePath, 'build')] excludeDirs: <String>[workingDirPath, path.join(assetBasePath, 'build')]
); );
if (assetVariants == null)
return 1;
final bool usesMaterialDesign = manifestDescriptor != null && final bool usesMaterialDesign = manifestDescriptor != null &&
manifestDescriptor['uses-material-design'] == true; manifestDescriptor['uses-material-design'] == true;
......
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