Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Unified Diff: sky/tools/skyx/bin/skyx.dart

Issue 1215703010: Move home.dart into example/demo_launcher (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « sky/shell/android/org/domokit/sky/shell/TracingController.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/tools/skyx/bin/skyx.dart
diff --git a/sky/tools/skyx/bin/skyx.dart b/sky/tools/skyx/bin/skyx.dart
index 9bab5e110724e944254af87fb7df0b88659eb9fd..be5484eb815cc5617c6b646ed9e84731659be5e7 100644
--- a/sky/tools/skyx/bin/skyx.dart
+++ b/sky/tools/skyx/bin/skyx.dart
@@ -14,6 +14,21 @@ const List<String> kDensities = const ['drawable-xxhdpi'];
const List<String> kThemes = const ['white', 'black', 'grey600'];
const List<int> kSizes = const [24];
+class Asset {
+ final String base;
+ final String key;
+
+ Asset({ this.base, this.key });
+}
+
+Iterable<Asset> parseAssets(Map manifestDescriptor, String manifestPath) sync* {
+ if (manifestDescriptor == null || !manifestDescriptor.containsKey('assets'))
+ return;
+ String basePath = new File(manifestPath).parent.path;
+ for (String asset in manifestDescriptor['assets'])
+ yield new Asset(base: basePath, key: asset);
+}
+
class MaterialAsset {
final String name;
final String density;
@@ -71,10 +86,10 @@ Future loadManifest(String manifestPath) async {
return loadYaml(manifestDescriptor);
}
-Future<ArchiveFile> createFile(MaterialAsset asset, String assetBase) async {
- File file = new File('${assetBase}/${asset.key}');
+Future<ArchiveFile> createFile(String key, String assetBase) async {
+ File file = new File('${assetBase}/${key}');
List<int> content = await file.readAsBytes();
- return new ArchiveFile.noCompress(asset.key, content.length, content);
+ return new ArchiveFile.noCompress(key, content.length, content);
}
Future<ArchiveFile> createSnapshotFile(String snapshotPath) async {
@@ -99,6 +114,7 @@ main(List<String> argv) async {
String manifestPath = args['manifest'];
Map manifestDescriptor = await loadManifest(manifestPath);
+ Iterable<Asset> assets = parseAssets(manifestDescriptor, manifestPath);
Iterable<MaterialAsset> materialAssets = parseMaterialAssets(manifestDescriptor);
Archive archive = new Archive();
@@ -107,8 +123,11 @@ main(List<String> argv) async {
if (snapshot != null)
archive.addFile(await createSnapshotFile(snapshot));
+ for (Asset asset in assets)
+ archive.addFile(await createFile(asset.key, asset.base));
+
for (MaterialAsset asset in materialAssets)
- archive.addFile(await createFile(asset, args['asset-base']));
+ archive.addFile(await createFile(asset.key, args['asset-base']));
File outputFile = new File(args['output-file']);
await outputFile.writeAsBytes(new ZipEncoder().encode(archive));
« no previous file with comments | « sky/shell/android/org/domokit/sky/shell/TracingController.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698