Merge pull request #1222 from abarth/rm_skyx

Remove the skyx package
This commit is contained in:
Adam Barth 2015-09-17 16:00:39 -07:00
commit e650fd58da
8 changed files with 18 additions and 296 deletions

View File

@ -7,14 +7,15 @@ template("skyx") {
bundle = "$target_gen_dir/${bundle_prefix}.skyx"
snapshot = "$target_gen_dir/${bundle_prefix}_snapshot.bin"
action("gen_${bundle_prefix}_snapshot") {
action("gen_${bundle_prefix}_bundle") {
main_dart = invoker.main_dart
asset_base = "//sky/packages/material_design_icons/lib/icons"
inputs = [
main_dart,
]
outputs = [
snapshot,
bundle,
]
if (defined(invoker.sources)) {
@ -24,21 +25,24 @@ template("skyx") {
sky_snapshot_dir =
get_label_info("//sky/tools/sky_snapshot($host_toolchain)", "root_out_dir")
script = "//sky/tools/sky_snapshot.py"
src_dir = "//"
cwd = rebase_path(src_dir, root_build_dir)
script = "//sky/tools/sky_build.py"
args = [
rebase_path("$sky_snapshot_dir/sky_snapshot", src_dir),
rebase_path(main_dart, src_dir),
"--package-root", rebase_path("packages"),
"--snapshot",
rebase_path(snapshot, src_dir),
"-C",
cwd,
"--asset-base", rebase_path(asset_base, root_build_dir),
"--compiler", rebase_path("$sky_snapshot_dir/sky_snapshot", root_build_dir),
"--main", rebase_path(main_dart, root_build_dir),
"--package-root", rebase_path("packages", root_build_dir),
"--snapshot", rebase_path(snapshot, root_build_dir),
"--output-file", rebase_path(bundle, root_build_dir),
]
if (defined(invoker.manifest)) {
inputs += [ invoker.manifest ]
args += [
"--manifest", rebase_path(invoker.manifest, root_build_dir),
]
}
deps = [
"//sky/tools/sky_snapshot($host_toolchain)",
]
@ -48,43 +52,6 @@ template("skyx") {
}
}
action("gen_${bundle_prefix}_bundle") {
asset_base = "//sky/packages/material_design_icons/lib/icons"
sources = [
"//sky/tools/skyx/bin/skyx.dart",
snapshot,
]
outputs = [
bundle,
]
script = "//sky/tools/skyx.py"
args = [
"--package-root",
rebase_path("//sky/tools/skyx/packages", root_build_dir),
"--asset-base",
rebase_path(asset_base, root_build_dir),
"--snapshot",
rebase_path(snapshot, root_build_dir),
"-o",
rebase_path(bundle, root_build_dir),
]
if (defined(invoker.manifest)) {
sources += [ invoker.manifest ]
args += [
"--manifest",
rebase_path(invoker.manifest, root_build_dir),
]
}
deps = [
":gen_${bundle_prefix}_snapshot",
]
}
group(target_name) {
deps = [
":gen_${bundle_prefix}_bundle",

View File

@ -11,7 +11,7 @@ dependencies:
newton: ^0.1.2
sky_engine: ^0.0.22
sky_services: ^0.0.22
sky_tools: ^0.0.11
sky_tools: ^0.0.12
vector_math: ^1.4.3
intl: ^0.12.4+2
environment:

View File

@ -1,28 +0,0 @@
#!/usr/bin/env python
# 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 argparse
import subprocess
import sys
import os
def main():
parser = argparse.ArgumentParser(description='Snapshots Sky applications')
parser.add_argument('executable', type=str)
parser.add_argument('main', type=str)
parser.add_argument('--package-root', type=str)
parser.add_argument('--snapshot', type=str)
parser.add_argument('-C', type=str,
help='Switch to this directory before running executable')
args = parser.parse_args()
return subprocess.check_call([
args.executable,
args.main,
'--package-root=%s' % args.package_root,
'--snapshot=%s' % args.snapshot,
], cwd=args.C)
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,39 +0,0 @@
#!/usr/bin/env python
# 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 argparse
import os
import subprocess
import sys
SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__))
SRC_ROOT = os.path.dirname(os.path.dirname(SKY_TOOLS_DIR))
DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin')
def main():
parser = argparse.ArgumentParser(description='Packaging tool for Sky apps')
parser.add_argument('--package-root', type=str)
parser.add_argument('--manifest', type=str)
parser.add_argument('--asset-base', type=str)
parser.add_argument('--snapshot', type=str)
parser.add_argument('-o', '--output-file', type=str)
args = parser.parse_args()
command = [
os.path.join(DART_SDK, 'dart'),
'--package-root=%s' % args.package_root,
os.path.join(SKY_TOOLS_DIR, 'skyx', 'bin', 'skyx.dart'),
'--asset-base', args.asset_base,
'--snapshot', args.snapshot,
'--output-file', args.output_file,
]
if args.manifest:
command += ['--manifest', args.manifest]
subprocess.check_call(command)
if __name__ == '__main__':
sys.exit(main())

View File

@ -1,3 +0,0 @@
.pub
packages
pubspec.lock

View File

@ -1,27 +0,0 @@
// Copyright 2014 The Chromium Authors. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Google Inc. nor the names of its
// contributors may be used to endorse or promote products derived from
// this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,139 +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:io';
import 'dart:async';
import 'package:archive/archive.dart';
import 'package:args/args.dart';
import 'package:yaml/yaml.dart';
const String kSnapshotKey = 'snapshot_blob.bin';
const List<String> kDensities = const ['drawable-xxhdpi'];
const List<String> kThemes = const ['white', 'black'];
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;
final String theme;
final int size;
MaterialAsset(Map descriptor)
: name = descriptor['name'],
density = descriptor['density'],
theme = descriptor['theme'],
size = descriptor['size'];
String get key {
List<String> parts = name.split('/');
String category = parts[0];
String subtype = parts[1];
return '$category/$density/ic_${subtype}_${theme}_${size}dp.png';
}
}
List generateValues(Map assetDescriptor, String key, List defaults) {
if (assetDescriptor.containsKey(key))
return [assetDescriptor[key]];
return defaults;
}
Iterable<MaterialAsset> generateMaterialAssets(Map assetDescriptor) sync* {
Map currentAssetDescriptor = new Map.from(assetDescriptor);
for (String density in generateValues(assetDescriptor, 'density', kDensities)) {
currentAssetDescriptor['density'] = density;
for (String theme in generateValues(assetDescriptor, 'theme', kThemes)) {
currentAssetDescriptor['theme'] = theme;
for (int size in generateValues(assetDescriptor, 'size', kSizes)) {
currentAssetDescriptor['size'] = size;
yield new MaterialAsset(currentAssetDescriptor);
}
}
}
}
Iterable<MaterialAsset> parseMaterialAssets(Map manifestDescriptor) sync* {
if (manifestDescriptor == null || !manifestDescriptor.containsKey('material-design-icons'))
return;
for (Map assetDescriptor in manifestDescriptor['material-design-icons']) {
for (MaterialAsset asset in generateMaterialAssets(assetDescriptor)) {
yield asset;
}
}
}
Future loadManifest(String manifestPath) async {
if (manifestPath == null)
return null;
String manifestDescriptor = await new File(manifestPath).readAsString();
return loadYaml(manifestDescriptor);
}
Future<ArchiveFile> createFile(String key, String assetBase) async {
File file = new File('${assetBase}/${key}');
if (!await file.exists())
return null;
List<int> content = await file.readAsBytes();
return new ArchiveFile.noCompress(key, content.length, content);
}
Future<ArchiveFile> createSnapshotFile(String snapshotPath) async {
File file = new File(snapshotPath);
List<int> content = await file.readAsBytes();
return new ArchiveFile(kSnapshotKey, content.length, content);
}
main(List<String> argv) async {
ArgParser parser = new ArgParser();
parser.addFlag('help', abbr: 'h', negatable: false);
parser.addOption('asset-base');
parser.addOption('manifest');
parser.addOption('output-file', abbr: 'o');
parser.addOption('snapshot');
ArgResults args = parser.parse(argv);
if (args['help']) {
print(parser.usage);
return;
}
String manifestPath = args['manifest'];
Map manifestDescriptor = await loadManifest(manifestPath);
Iterable<Asset> assets = parseAssets(manifestDescriptor, manifestPath);
Iterable<MaterialAsset> materialAssets = parseMaterialAssets(manifestDescriptor);
Archive archive = new Archive();
String snapshot = args['snapshot'];
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) {
ArchiveFile file = await createFile(asset.key, args['asset-base']);
if (file != null)
archive.addFile(file);
}
File outputFile = new File(args['output-file']);
await outputFile.writeAsBytes(new ZipEncoder().encode(archive));
}

View File

@ -1,9 +0,0 @@
author: Chromium Authors <sky-dev@googlegroups.com>
dependencies:
archive: '>=1.0.20 <2.0.0'
args: '>=0.13.0 <1.0.0'
yaml: '>=2.1.3 <3.0.0'
description: Developer tool for packaging Sky applications
homepage: https://github.com/domokit/sky_engine/tree/master/sky/tools/skyx
name: skyx
version: 0.0.3