diff --git a/engine/src/flutter/examples/BUILD.gn b/engine/src/flutter/examples/BUILD.gn deleted file mode 100644 index 01a2d5f84f..0000000000 --- a/engine/src/flutter/examples/BUILD.gn +++ /dev/null @@ -1,14 +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. - -group("examples") { - testonly = true - - deps = [ - "//examples/fitness", - "//examples/game", - "//examples/mine_digger", - "//examples/stocks", - ] -} diff --git a/engine/src/flutter/examples/README.md b/engine/src/flutter/examples/README.md deleted file mode 100644 index 2078c3ab9c..0000000000 --- a/engine/src/flutter/examples/README.md +++ /dev/null @@ -1,23 +0,0 @@ -Flutter Examples -================ - -This directory contains several examples of using Flutter. Each of these is an -individual Dart application package. - -To run a sample with the `flutter` tool, run `pub get` inside its directory, -then run `flutter start`. (See the -[getting started guide](https://flutter.github.io/getting-started/) to install -the `flutter` tool.) - -Available examples include: - -- *Hello, world.* The [hello world app](hello_world) is a basic app that shows - the text "hello, world." - -- *Stocks.* The [stocks app](stocks) is an example of a typical mobile app - built using Flutter. The app shows a list of all the stocks in the NASDAQ. - -- *Widgets.* The [widget apps](widgets) demonstrate a number of Flutter widgets - so you can experiment with them in a simple container. There is no main.dart - in this directory because each file is a standalone sample. To run a - particular file, use `flutter start -t filename.dart`. diff --git a/engine/src/flutter/examples/address_book/lib/main.dart b/engine/src/flutter/examples/address_book/lib/main.dart deleted file mode 100644 index e1066a1142..0000000000 --- a/engine/src/flutter/examples/address_book/lib/main.dart +++ /dev/null @@ -1,98 +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 'package:flutter/material.dart'; - -class Field extends StatelessComponent { - Field({ - Key key, - this.inputKey, - this.icon, - this.placeholder - }) : super(key: key); - - final GlobalKey inputKey; - final String icon; - final String placeholder; - - Widget build(BuildContext context) { - return new Row([ - new Padding( - padding: const EdgeDims.symmetric(horizontal: 16.0), - child: new Icon(icon: icon) - ), - new Flexible( - child: new Input( - key: inputKey, - placeholder: placeholder - ) - ) - ] - ); - } -} - -class AddressBookHome extends StatelessComponent { - Widget buildToolBar(BuildContext context) { - return new ToolBar( - left: new IconButton(icon: "navigation/arrow_back"), - right: [new IconButton(icon: "navigation/check")] - ); - } - - Widget buildFloatingActionButton(BuildContext context) { - return new FloatingActionButton( - child: new Icon(icon: 'image/photo_camera'), - backgroundColor: Theme.of(context).accentColor - ); - } - - static final GlobalKey nameKey = new GlobalKey(label: 'name field'); - static final GlobalKey phoneKey = new GlobalKey(label: 'phone field'); - static final GlobalKey emailKey = new GlobalKey(label: 'email field'); - static final GlobalKey addressKey = new GlobalKey(label: 'address field'); - static final GlobalKey ringtoneKey = new GlobalKey(label: 'ringtone field'); - static final GlobalKey noteKey = new GlobalKey(label: 'note field'); - - Widget buildBody(BuildContext context) { - return new Block([ - new AspectRatio( - aspectRatio: 16.0 / 9.0, - child: new Container( - decoration: new BoxDecoration(backgroundColor: Colors.purple[300]) - ) - ), - new Field(inputKey: nameKey, icon: "social/person", placeholder: "Name"), - new Field(inputKey: phoneKey, icon: "communication/phone", placeholder: "Phone"), - new Field(inputKey: emailKey, icon: "communication/email", placeholder: "Email"), - new Field(inputKey: addressKey, icon: "maps/place", placeholder: "Address"), - new Field(inputKey: ringtoneKey, icon: "av/volume_up", placeholder: "Ringtone"), - new Field(inputKey: noteKey, icon: "content/add", placeholder: "Add note"), - ]); - } - - Widget build(BuildContext context) { - return new Scaffold( - toolBar: buildToolBar(context), - body: buildBody(context), - floatingActionButton: buildFloatingActionButton(context) - ); - } -} - -final ThemeData theme = new ThemeData( - brightness: ThemeBrightness.light, - primarySwatch: Colors.teal, - accentColor: Colors.pinkAccent[100] -); - -void main() { - runApp(new MaterialApp( - title: 'Address Book', - theme: theme, - routes: { - '/': (RouteArguments args) => new AddressBookHome() - } - )); -} diff --git a/engine/src/flutter/examples/address_book/pubspec.yaml b/engine/src/flutter/examples/address_book/pubspec.yaml deleted file mode 100644 index 46f0b6d3c1..0000000000 --- a/engine/src/flutter/examples/address_book/pubspec.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: address_book -dependencies: - flutter: - '0.0.16' - sky_tools: any -dependency_overrides: - material_design_icons: - path: ../../sky/packages/material_design_icons - flutter: - path: ../../sky/packages/sky diff --git a/engine/src/flutter/examples/hello_world/lib/main.dart b/engine/src/flutter/examples/hello_world/lib/main.dart deleted file mode 100644 index fc37338118..0000000000 --- a/engine/src/flutter/examples/hello_world/lib/main.dart +++ /dev/null @@ -1,7 +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 'package:flutter/widgets.dart'; - -void main() => runApp(new Center(child: new Text('Hello, world!'))); diff --git a/engine/src/flutter/examples/hello_world/pubspec.yaml b/engine/src/flutter/examples/hello_world/pubspec.yaml deleted file mode 100644 index f823464c00..0000000000 --- a/engine/src/flutter/examples/hello_world/pubspec.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: hello_world -dependencies: - flutter: - '0.0.16' - sky_tools: any -dependency_overrides: - material_design_icons: - path: ../../sky/packages/material_design_icons - flutter: - path: ../../sky/packages/sky diff --git a/engine/src/flutter/examples/mine_digger/BUILD.gn b/engine/src/flutter/examples/mine_digger/BUILD.gn deleted file mode 100644 index ec5218b15a..0000000000 --- a/engine/src/flutter/examples/mine_digger/BUILD.gn +++ /dev/null @@ -1,13 +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("//sky/build/sky_app.gni") - -sky_app("mine_digger") { - main_dart = "lib/main.dart" - - if (is_android) { - apk_name = "MineDigger" - } -} diff --git a/engine/src/flutter/examples/mine_digger/apk/AndroidManifest.xml b/engine/src/flutter/examples/mine_digger/apk/AndroidManifest.xml deleted file mode 100644 index dbd3bc2c76..0000000000 --- a/engine/src/flutter/examples/mine_digger/apk/AndroidManifest.xml +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/engine/src/flutter/examples/mine_digger/lib/main.dart b/engine/src/flutter/examples/mine_digger/lib/main.dart deleted file mode 100644 index 6e04a8d8e2..0000000000 --- a/engine/src/flutter/examples/mine_digger/lib/main.dart +++ /dev/null @@ -1,337 +0,0 @@ -// Use of this source code is governed by a BSD-style license that can be -// found in the LICENSE file. - -import 'dart:math'; - -import 'package:flutter/gestures.dart'; -import 'package:flutter/material.dart'; -import 'package:flutter/painting.dart'; -import 'package:flutter/rendering.dart'; -import 'package:flutter/services.dart'; - -// Classic minesweeper-inspired game. The mouse controls are standard -// except for left + right combo which is not implemented. For touch, -// the duration of the pointer determines probing versus flagging. -// -// There are only 3 classes to understand. MineDiggerApp, which is -// contains all the logic and two classes that describe the mines: -// CoveredMineNode and ExposedMineNode, none of them holding state. - -// Colors for each mine count (0-8): -const List textColors = const [ - const Color(0xFF555555), - const Color(0xFF0094FF), // blue - const Color(0xFF13A023), // green - const Color(0xFFDA1414), // red - const Color(0xFF1E2347), // black - const Color(0xFF7F0037), // dark red - const Color(0xFF000000), - const Color(0xFF000000), - const Color(0xFF000000), -]; - -final List textStyles = textColors.map((Color color) { - return new TextStyle(color: color, fontWeight: bold, textAlign: TextAlign.center); -}).toList(); - -enum CellState { covered, exploded, cleared, flagged, shown } - -class MineDigger extends StatefulComponent { - MineDiggerState createState() => new MineDiggerState(); -} - -class MineDiggerState extends State { - static const int rows = 9; - static const int cols = 9; - static const int totalMineCount = 11; - - bool alive; - bool hasWon; - int detectedCount; - - // |cells| keeps track of the positions of the mines. - List> cells; - // |uiState| keeps track of the visible player progess. - List> uiState; - - void initState() { - super.initState(); - resetGame(); - } - - void resetGame() { - alive = true; - hasWon = false; - detectedCount = 0; - // Initialize matrices. - cells = new List>.generate(rows, (int row) { - return new List.filled(cols, false); - }); - uiState = new List>.generate(rows, (int row) { - return new List.filled(cols, CellState.covered); - }); - // Place the mines. - Random random = new Random(); - int minesRemaining = totalMineCount; - while (minesRemaining > 0) { - int pos = random.nextInt(rows * cols); - int row = pos ~/ rows; - int col = pos % cols; - if (!cells[row][col]) { - cells[row][col] = true; - minesRemaining--; - } - } - } - - PointerEventListener _pointerDownHandlerFor(int posX, int posY) { - return (PointerInputEvent event) { - if (event.buttons == 1) { - probe(posX, posY); - } else if (event.buttons == 2) { - flag(posX, posY); - } - }; - } - - Widget buildBoard() { - bool hasCoveredCell = false; - List flexRows = []; - for (int iy = 0; iy < rows; iy++) { - List row = []; - for (int ix = 0; ix < cols; ix++) { - CellState state = uiState[iy][ix]; - int count = mineCount(ix, iy); - if (!alive) { - if (state != CellState.exploded) - state = cells[iy][ix] ? CellState.shown : state; - } - if (state == CellState.covered || state == CellState.flagged) { - row.add(new GestureDetector( - onTap: () { - if (state == CellState.covered) - probe(ix, iy); - }, - onLongPress: () { - userFeedback.performHapticFeedback(HapticFeedbackType.LONG_PRESS); - flag(ix, iy); - }, - child: new Listener( - onPointerDown: _pointerDownHandlerFor(ix, iy), - child: new CoveredMineNode( - flagged: state == CellState.flagged, - posX: ix, - posY: iy - ) - ) - )); - if (state == CellState.covered) { - // Mutating |hasCoveredCell| here is hacky, but convenient, same - // goes for mutating |hasWon| below. - hasCoveredCell = true; - } - } else { - row.add(new ExposedMineNode( - state: state, - count: count - )); - } - } - flexRows.add( - new Row( - row, - justifyContent: FlexJustifyContent.center, - key: new ValueKey(iy) - ) - ); - } - - if (!hasCoveredCell) { - // all cells uncovered. Are all mines flagged? - if ((detectedCount == totalMineCount) && alive) { - hasWon = true; - } - } - - return new Container( - padding: new EdgeDims.all(10.0), - margin: new EdgeDims.all(10.0), - decoration: new BoxDecoration(backgroundColor: const Color(0xFF6B6B6B)), - child: new Column(flexRows) - ); - } - - Widget buildToolBar(BuildContext context) { - String toolbarCaption = hasWon ? - 'Awesome!!' : alive ? - 'Mine Digger [$detectedCount-$totalMineCount]': 'Kaboom! [press here]'; - - return new ToolBar( - // FIXME: Strange to have the toolbar be tapable. - center: new Listener( - onPointerDown: handleToolbarPointerDown, - child: new Text(toolbarCaption, style: Theme.of(context).text.title) - ) - ); - } - - Widget build(BuildContext context) { - // We build the board before we build the toolbar because we compute the win state during build step. - Widget board = buildBoard(); - return new Title( - title: 'Mine Digger', - child: new Scaffold( - toolBar: buildToolBar(context), - body: new Container( - child: new Center(child: board), - decoration: new BoxDecoration(backgroundColor: Colors.grey[50]) - ) - ) - ); - } - - void handleToolbarPointerDown(PointerInputEvent event) { - setState(() { - resetGame(); - }); - } - - // User action. The user uncovers the cell which can cause losing the game. - void probe(int x, int y) { - if (!alive) - return; - if (uiState[y][x] == CellState.flagged) - return; - setState(() { - // Allowed to probe. - if (cells[y][x]) { - // Probed on a mine --> dead!! - uiState[y][x] = CellState.exploded; - alive = false; - } else { - // No mine, uncover nearby if possible. - cull(x, y); - } - }); - } - - // User action. The user is sure a mine is at this location. - void flag(int x, int y) { - setState(() { - if (uiState[y][x] == CellState.flagged) { - uiState[y][x] = CellState.covered; - --detectedCount; - } else { - uiState[y][x] = CellState.flagged; - ++detectedCount; - } - }); - } - - // Recursively uncovers cells whose totalMineCount is zero. - void cull(int x, int y) { - if (!inBoard(x, y)) - return; - if (uiState[y][x] == CellState.cleared) - return; - uiState[y][x] = CellState.cleared; - - if (mineCount(x, y) > 0) - return; - - cull(x - 1, y); - cull(x + 1, y); - cull(x, y - 1); - cull(x, y + 1 ); - cull(x - 1, y - 1); - cull(x + 1, y + 1); - cull(x + 1, y - 1); - cull(x - 1, y + 1); - } - - int mineCount(int x, int y) { - int count = 0; - count += bombs(x - 1, y); - count += bombs(x + 1, y); - count += bombs(x, y - 1); - count += bombs(x, y + 1 ); - count += bombs(x - 1, y - 1); - count += bombs(x + 1, y + 1); - count += bombs(x + 1, y - 1); - count += bombs(x - 1, y + 1); - return count; - } - - int bombs(int x, int y) => inBoard(x, y) && cells[y][x] ? 1 : 0; - - bool inBoard(int x, int y) => x >= 0 && x < cols && y >= 0 && y < rows; -} - -Widget buildCell(Widget child) { - return new Container( - padding: new EdgeDims.all(1.0), - height: 27.0, width: 27.0, - decoration: new BoxDecoration(backgroundColor: const Color(0xFFC0C0C0)), - margin: new EdgeDims.all(2.0), - child: child - ); -} - -Widget buildInnerCell(Widget child) { - return new Container( - padding: new EdgeDims.all(1.0), - margin: new EdgeDims.all(3.0), - height: 17.0, width: 17.0, - child: child - ); -} - -class CoveredMineNode extends StatelessComponent { - - CoveredMineNode({ this.flagged, this.posX, this.posY }); - - final bool flagged; - final int posX; - final int posY; - - Widget build(BuildContext context) { - Widget text; - if (flagged) - text = buildInnerCell(new StyledText(elements : [textStyles[5], '\u2691'])); - - Container inner = new Container( - margin: new EdgeDims.all(2.0), - height: 17.0, width: 17.0, - decoration: new BoxDecoration(backgroundColor: const Color(0xFFD9D9D9)), - child: text - ); - - return buildCell(inner); - } -} - -class ExposedMineNode extends StatelessComponent { - - ExposedMineNode({ this.state, this.count }); - - final CellState state; - final int count; - - Widget build(BuildContext context) { - StyledText text; - if (state == CellState.cleared) { - // Uncovered cell with nearby mine count. - if (count != 0) - text = new StyledText(elements : [textStyles[count], '$count']); - } else { - // Exploded mine or shown mine for 'game over'. - int color = state == CellState.exploded ? 3 : 0; - text = new StyledText(elements : [textStyles[color], '\u2600']); - } - return buildCell(buildInnerCell(text)); - } -} - -void main() { - runApp(new MineDigger()); -} diff --git a/engine/src/flutter/examples/mine_digger/pubspec.yaml b/engine/src/flutter/examples/mine_digger/pubspec.yaml deleted file mode 100644 index 6f5d79a19b..0000000000 --- a/engine/src/flutter/examples/mine_digger/pubspec.yaml +++ /dev/null @@ -1,10 +0,0 @@ -name: mine_digger -dependencies: - flutter: - '0.0.16' - sky_tools: any -dependency_overrides: - material_design_icons: - path: ../../sky/packages/material_design_icons - flutter: - path: ../../sky/packages/sky diff --git a/engine/src/flutter/sky/BUILD.gn b/engine/src/flutter/sky/BUILD.gn index 1bb0930b69..23320f7f69 100644 --- a/engine/src/flutter/sky/BUILD.gn +++ b/engine/src/flutter/sky/BUILD.gn @@ -8,19 +8,6 @@ group("sky") { deps = [ "//sky/engine/platform:platform_unittests($host_toolchain)", "//sky/engine/wtf:unittests($host_toolchain)", - "//examples", - ":sky_dev", - ] - - if (!is_android) { - deps += [ "//third_party/mesa:osmesa" ] - } -} - -group("sky_dev") { - testonly = true - - deps = [ "//sky/packages", "//sky/shell", ] @@ -28,4 +15,8 @@ group("sky_dev") { if (is_android) { deps += [ "//sky/services/activity" ] } + + if (!is_android) { + deps += [ "//third_party/mesa:osmesa" ] + } } diff --git a/engine/src/flutter/sky/packages/flx/.gitignore b/engine/src/flutter/sky/packages/flx/.gitignore deleted file mode 100644 index b9a62f7523..0000000000 --- a/engine/src/flutter/sky/packages/flx/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea -.pub/ -pubspec.lock diff --git a/engine/src/flutter/sky/packages/flx/LICENSE b/engine/src/flutter/sky/packages/flx/LICENSE deleted file mode 100644 index a32e00ce6b..0000000000 --- a/engine/src/flutter/sky/packages/flx/LICENSE +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2015 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. diff --git a/engine/src/flutter/sky/packages/flx/lib/bundle.dart b/engine/src/flutter/sky/packages/flx/lib/bundle.dart deleted file mode 100644 index f5afe4492d..0000000000 --- a/engine/src/flutter/sky/packages/flx/lib/bundle.dart +++ /dev/null @@ -1,144 +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:async'; -import 'dart:convert'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:bignum/bignum.dart'; - -import 'signing.dart'; - -// Magic string we put at the top of all bundle files. -const String kBundleMagic = '#!mojo mojo:sky_viewer\n'; - -// Prefix of the above, used when reading bundle files. This allows us to be -// more flexbile about what we accept. -const String kBundleMagicPrefix = '#!mojo '; - -typedef Stream> StreamOpener(); - -Future> _readBytesWithLength(RandomAccessFile file) async { - ByteData buffer = new ByteData(4); - await file.readInto(buffer.buffer.asUint8List()); - int length = buffer.getUint32(0, Endianness.LITTLE_ENDIAN); - return await file.read(length); -} - -const int kMaxLineLen = 10*1024; -const int kNewline = 0x0A; -Future _readLine(RandomAccessFile file) async { - String line = ''; - while (line.length < kMaxLineLen) { - int byte = await file.readByte(); - if (byte == -1 || byte == kNewline) - break; - line += new String.fromCharCode(byte); - } - return line; -} - -// Writes a 32-bit length followed by the content of [bytes]. -void _writeBytesWithLengthSync(RandomAccessFile outputFile, List bytes) { - if (bytes == null) - bytes = new Uint8List(0); - assert(bytes.length < 0xffffffff); - ByteData length = new ByteData(4)..setUint32(0, bytes.length, Endianness.LITTLE_ENDIAN); - outputFile.writeFromSync(length.buffer.asUint8List()); - outputFile.writeFromSync(bytes); -} - -// Represents a parsed .flx Bundle. Contains information from the bundle's -// header, as well as an open File handle positioned where the zip content -// begins. -// The bundle format is: -// #!mojo \n -// <32-bit length> -// <32-bit length> -// -// -// The manifest is a JSON string containing the following keys: -// (optional) name: the name of the package. -// version: the package version. -// update-url: the base URL to download a new manifest and bundle. -// key: a BASE-64 encoded DER-encoded ASN.1 representation of the Q point of the -// ECDSA public key that was used to sign this manifest. -// content-hash: an integer SHA-256 hash value of the . -class Bundle { - Bundle._fromFile(this.path); - Bundle.fromContent({ - this.path, - this.manifest, - contentBytes, - AsymmetricKeyPair keyPair: null - }) : _contentBytes = contentBytes { - assert(path != null); - assert(manifest != null); - assert(_contentBytes != null); - manifestBytes = serializeManifest(manifest, keyPair?.publicKey, _contentBytes); - signatureBytes = signManifest(manifestBytes, keyPair?.privateKey); - _openContentStream = () => new Stream.fromIterable(>[_contentBytes]); - } - - final String path; - List signatureBytes; - List manifestBytes; - Map manifest; - - // Callback to open a Stream containing the bundle content data. - StreamOpener _openContentStream; - - // Zip content bytes. Only valid when created in memory. - List _contentBytes; - - Future _readHeader() async { - RandomAccessFile file = await new File(path).open(); - String magic = await _readLine(file); - if (!magic.startsWith(kBundleMagicPrefix)) { - file.close(); - return false; - } - signatureBytes = await _readBytesWithLength(file); - manifestBytes = await _readBytesWithLength(file); - int contentOffset = await file.position(); - _openContentStream = () => new File(path).openRead(contentOffset); - file.close(); - - String manifestString = UTF8.decode(manifestBytes); - manifest = JSON.decode(manifestString); - return true; - } - - static Future readHeader(String path) async { - Bundle bundle = new Bundle._fromFile(path); - if (!await bundle._readHeader()) - return null; - return bundle; - } - - // Verifies that the package has a valid signature and content. - Future verifyContent() async { - if (!verifyManifestSignature(manifest, manifestBytes, signatureBytes)) - return false; - - Stream> content = _openContentStream(); - BigInteger expectedHash = new BigInteger(manifest['content-hash'], 10); - if (!await verifyContentHash(expectedHash, content)) - return false; - - return true; - } - - // Writes the in-memory representation to disk. - void writeSync() { - assert(_contentBytes != null); - RandomAccessFile outputFile = new File(path).openSync(mode: FileMode.WRITE); - outputFile.writeStringSync('#!mojo mojo:sky_viewer\n'); - _writeBytesWithLengthSync(outputFile, signatureBytes); - _writeBytesWithLengthSync(outputFile, manifestBytes); - outputFile.writeFromSync(_contentBytes); - outputFile.close(); - } -} diff --git a/engine/src/flutter/sky/packages/flx/lib/signing.dart b/engine/src/flutter/sky/packages/flx/lib/signing.dart deleted file mode 100644 index 36bbc7f63b..0000000000 --- a/engine/src/flutter/sky/packages/flx/lib/signing.dart +++ /dev/null @@ -1,183 +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:async'; -import 'dart:convert' hide BASE64; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:asn1lib/asn1lib.dart'; -import 'package:bignum/bignum.dart'; -import 'package:cipher/cipher.dart'; -import 'package:cipher/impl/client.dart'; -import 'package:crypto/crypto.dart'; - -export 'package:cipher/cipher.dart' show AsymmetricKeyPair; - -// The ECDSA algorithm parameters we're using. These match the parameters used -// by the Flutter updater package. -class CipherParameters { - final String signerAlgorithm = 'SHA-256/ECDSA'; - final String hashAlgorithm = 'SHA-256'; - final ECDomainParameters domain = new ECDomainParameters('prime256v1'); - SecureRandom get random { - if (_random == null) - _initRandom(new Uint8List(16), new Uint8List(16)); - return _random; - } - - // Seeds our secure random number generator using data from /dev/urandom. - // Disclaimer: I don't really understand why we need 2 parameters for - // cipher's API. - Future seedRandom() async { - try { - RandomAccessFile file = await new File("/dev/urandom").open(); - Uint8List key = new Uint8List.fromList(await file.read(16)); - Uint8List iv = new Uint8List.fromList(await file.read(16)); - _initRandom(key, iv); - } on FileSystemException { - // TODO(mpcomplete): need an entropy source on Windows. We might get this - // for free from Dart itself soon. - print("Warning: Failed to seed random number generator. No /dev/urandom."); - } - } - - SecureRandom _random; - void _initRandom(Uint8List key, Uint8List iv) { - KeyParameter keyParam = new KeyParameter(key); - ParametersWithIV params = new ParametersWithIV(keyParam, iv); - _random = new SecureRandom('AES/CTR/AUTO-SEED-PRNG') - ..seed(params); - } - - static CipherParameters get() => _params; - static CipherParameters _init() { - initCipher(); - return new CipherParameters(); - } -} - -final CipherParameters _params = CipherParameters._init(); - -// Returns a serialized manifest, with the public key and hash of the content -// included. -Uint8List serializeManifest(Map manifestDescriptor, ECPublicKey publicKey, Uint8List zipBytes) { - if (manifestDescriptor == null) - return null; - final List kSavedKeys = [ - 'name', - 'version', - 'update-url' - ]; - Map outputManifest = new Map(); - manifestDescriptor.forEach((key, value) { - if (kSavedKeys.contains(key)) - outputManifest[key] = value; - }); - - if (publicKey != null) - outputManifest['key'] = BASE64.encode(publicKey.Q.getEncoded()); - - Uint8List zipHash = new Digest(_params.hashAlgorithm).process(zipBytes); - BigInteger zipHashInt = new BigInteger.fromBytes(1, zipHash); - outputManifest['content-hash'] = zipHashInt.intValue(); - - return new Uint8List.fromList(UTF8.encode(JSON.encode(outputManifest))); -} - -// Returns the ASN.1 encoded signature of the input manifestBytes. -Uint8List signManifest(Uint8List manifestBytes, ECPrivateKey privateKey) { - if (manifestBytes == null || privateKey == null) - return new Uint8List(0); - Signer signer = new Signer(_params.signerAlgorithm); - PrivateKeyParameter params = new PrivateKeyParameter(privateKey); - signer.init(true, new ParametersWithRandom(params, _params.random)); - ECSignature signature = signer.generateSignature(manifestBytes); - ASN1Sequence asn1 = new ASN1Sequence() - ..add(new ASN1Integer(signature.r)) - ..add(new ASN1Integer(signature.s)); - return asn1.encodedBytes; -} - -bool verifyManifestSignature(Map manifest, - Uint8List manifestBytes, - Uint8List signatureBytes) { - ECSignature signature = _asn1ParseSignature(signatureBytes); - if (signature == null) - return false; - - List keyBytes = BASE64.decode(manifest['key']); - ECPoint q = _params.domain.curve.decodePoint(keyBytes); - ECPublicKey publicKey = new ECPublicKey(q, _params.domain); - - Signer signer = new Signer(_params.signerAlgorithm); - signer.init(false, new PublicKeyParameter(publicKey)); - return signer.verifySignature(manifestBytes, signature); -} - -Future verifyContentHash(BigInteger expectedHash, Stream> content) async { - // Hash the file incrementally. - Digest hasher = new Digest(_params.hashAlgorithm); - await content.forEach((List chunk) { - hasher.update(chunk, 0, chunk.length); - }); - Uint8List hashBytes = new Uint8List(hasher.digestSize); - int len = hasher.doFinal(hashBytes, 0); - hashBytes = hashBytes.sublist(0, len); - BigInteger actualHash = new BigInteger.fromBytes(1, hashBytes); - - return expectedHash == actualHash; -} - -// Parses a DER-encoded ASN.1 ECDSA private key block. -ECPrivateKey _asn1ParsePrivateKey(ECDomainParameters ecDomain, Uint8List privateKey) { - ASN1Parser parser = new ASN1Parser(privateKey); - ASN1Sequence seq = parser.nextObject(); - assert(seq.elements.length >= 2); - ASN1OctetString keyOct = seq.elements[1]; - BigInteger d = new BigInteger.fromBytes(1, keyOct.octets); - return new ECPrivateKey(d, ecDomain); -} - -// Parses a DER-encoded ASN.1 ECDSA signature block. -ECSignature _asn1ParseSignature(Uint8List signature) { - try { - ASN1Parser parser = new ASN1Parser(signature); - ASN1Object object = parser.nextObject(); - if (object is! ASN1Sequence) - return null; - ASN1Sequence sequence = object; - if (!(sequence.elements.length == 2 && - sequence.elements[0] is ASN1Integer && - sequence.elements[1] is ASN1Integer)) - return null; - ASN1Integer r = sequence.elements[0]; - ASN1Integer s = sequence.elements[1]; - return new ECSignature(r.valueAsPositiveBigInteger, s.valueAsPositiveBigInteger); - } on ASN1Exception { - return null; - } -} - -ECPublicKey _publicKeyFromPrivateKey(ECPrivateKey privateKey) { - ECPoint Q = privateKey.parameters.G * privateKey.d; - return new ECPublicKey(Q, privateKey.parameters); -} - -AsymmetricKeyPair keyPairFromPrivateKeyFileSync(String privateKeyPath) { - File file = new File(privateKeyPath); - if (!file.existsSync()) - return null; - return keyPairFromPrivateKeyBytes(file.readAsBytesSync()); -} - -AsymmetricKeyPair keyPairFromPrivateKeyBytes(List privateKeyBytes) { - ECPrivateKey privateKey = _asn1ParsePrivateKey( - _params.domain, new Uint8List.fromList(privateKeyBytes)); - if (privateKey == null) - return null; - - ECPublicKey publicKey = _publicKeyFromPrivateKey(privateKey); - return new AsymmetricKeyPair(publicKey, privateKey); -} diff --git a/engine/src/flutter/sky/packages/flx/pubspec.yaml b/engine/src/flutter/sky/packages/flx/pubspec.yaml deleted file mode 100644 index 56e9fc0950..0000000000 --- a/engine/src/flutter/sky/packages/flx/pubspec.yaml +++ /dev/null @@ -1,15 +0,0 @@ -name: flx -version: 0.0.10 -author: Flutter Authors -description: Library for dealing with Flutter bundle (.flx) files -homepage: http://flutter.io -dependencies: - sky_services: - '0.0.50' - yaml: ^2.1.3 - asn1lib: ^0.4.1 - cipher: ^0.7.1 - crypto: ^0.9.1 - path: ^1.3.0 -environment: - sdk: '>=1.12.0 <2.0.0' diff --git a/engine/src/flutter/sky/packages/updater/.gitignore b/engine/src/flutter/sky/packages/updater/.gitignore deleted file mode 100644 index b9a62f7523..0000000000 --- a/engine/src/flutter/sky/packages/updater/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.idea -.pub/ -pubspec.lock diff --git a/engine/src/flutter/sky/packages/updater/BUILD.gn b/engine/src/flutter/sky/packages/updater/BUILD.gn deleted file mode 100644 index 65185a67b6..0000000000 --- a/engine/src/flutter/sky/packages/updater/BUILD.gn +++ /dev/null @@ -1,32 +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. - -action("updater") { - snapshot = "$target_gen_dir/updater_snapshot.bin" - main_dart = "lib/main.dart" - - inputs = [ - main_dart, - ] - outputs = [ - snapshot, - ] - - sky_snapshot_dir = - get_label_info("//sky/tools/sky_snapshot($host_toolchain)", "root_out_dir") - script = "//sky/tools/run_sky_snapshot.py" - - args = [ - "--compiler", rebase_path("$sky_snapshot_dir/sky_snapshot", root_build_dir), - "--package-root", rebase_path("packages", root_build_dir), - "--snapshot", rebase_path(snapshot, root_build_dir), - "--main", rebase_path(main_dart, root_build_dir), - ] - - deps = [ - "//sky/services/activity:interfaces", - "//sky/services/updater:interfaces", - "//sky/tools/sky_snapshot($host_toolchain)", - ] -} diff --git a/engine/src/flutter/sky/packages/updater/lib/main.dart b/engine/src/flutter/sky/packages/updater/lib/main.dart deleted file mode 100644 index c363badf1a..0000000000 --- a/engine/src/flutter/sky/packages/updater/lib/main.dart +++ /dev/null @@ -1,128 +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:async'; -import 'dart:convert'; -import 'dart:math'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:mojo/core.dart'; -import 'package:flutter/services.dart'; -import 'package:flx/bundle.dart'; -import 'package:sky_services/updater/update_service.mojom.dart'; -import 'package:path/path.dart' as path; -import 'package:yaml/yaml.dart' as yaml; - -import 'pipe_to_file.dart'; -import 'version.dart'; - -const String kManifestFile = 'flutter.yaml'; -const String kBundleFile = 'app.flx'; - -UpdateServiceProxy _initUpdateService() { - UpdateServiceProxy updateService = new UpdateServiceProxy.unbound(); - shell.connectToService(null, updateService); - return updateService; -} - -final UpdateServiceProxy _updateService = _initUpdateService(); - -String cachedDataDir = null; -Future getDataDir() async { - if (cachedDataDir == null) - cachedDataDir = await getAppDataDir(); - return cachedDataDir; -} - -class UpdateFailure extends Error { - UpdateFailure(this._message); - String _message; - String toString() => _message; -} - -class UpdateTask { - UpdateTask(); - - Future run() async { - try { - await _runImpl(); - } on UpdateFailure catch (e) { - print('Update failed: $e'); - } catch (e, stackTrace) { - print('Update failed: $e'); - print('Stack: $stackTrace'); - } finally { - _updateService.ptr.notifyUpdateCheckComplete(); - } - } - - Future _runImpl() async { - _dataDir = await getDataDir(); - - await _readLocalManifest(); - yaml.YamlMap remoteManifest = await _fetchManifest(); - if (!_shouldUpdate(remoteManifest)) { - print('Update skipped. No new version.'); - return; - } - await _fetchBundle(); - await _validateBundle(); - await _replaceBundle(); - print('Update success.'); - } - - Map _currentManifest; - String _dataDir; - String _tempPath; - - Future _readLocalManifest() async { - String bundlePath = path.join(_dataDir, kBundleFile); - Bundle bundle = await Bundle.readHeader(bundlePath); - _currentManifest = bundle.manifest; - } - - Future _fetchManifest() async { - String manifestUrl = _currentManifest['update-url'] + '/' + kManifestFile; - String manifestData = await fetchString(manifestUrl); - return yaml.loadYaml(manifestData, sourceUrl: manifestUrl); - } - - bool _shouldUpdate(yaml.YamlMap remoteManifest) { - Version currentVersion = new Version(_currentManifest['version']); - Version remoteVersion = new Version(remoteManifest['version']); - return (currentVersion < remoteVersion); - } - - Future _fetchBundle() async { - // TODO(mpcomplete): Use the cache dir. We need an equivalent of mkstemp(). - _tempPath = path.join(_dataDir, 'tmp.skyx'); - String bundleUrl = _currentManifest['update-url'] + '/' + kBundleFile; - UrlResponse response = await fetchUrl(bundleUrl); - MojoResult result = await PipeToFile.copyToFile(response.body, _tempPath); - if (!result.isOk) - throw new UpdateFailure('Failure fetching new package: ${response.statusLine}'); - } - - Future _validateBundle() async { - Bundle bundle = await Bundle.readHeader(_tempPath); - - if (bundle == null) - throw new UpdateFailure('Remote package not a valid FLX file.'); - if (bundle.manifest['key'] != _currentManifest['key']) - throw new UpdateFailure('Remote package key does not match.'); - if (!await bundle.verifyContent()) - throw new UpdateFailure('Invalid package signature or hash. This package has been tampered with.'); - } - - Future _replaceBundle() async { - String bundlePath = path.join(_dataDir, kBundleFile); - await new File(_tempPath).rename(bundlePath); - } -} - -void main() { - UpdateTask task = new UpdateTask(); - task.run(); -} diff --git a/engine/src/flutter/sky/packages/updater/lib/pipe_to_file.dart b/engine/src/flutter/sky/packages/updater/lib/pipe_to_file.dart deleted file mode 100644 index 511a7a369e..0000000000 --- a/engine/src/flutter/sky/packages/updater/lib/pipe_to_file.dart +++ /dev/null @@ -1,64 +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:async'; -import 'dart:io'; -import 'dart:typed_data'; - -import 'package:mojo/core.dart'; - -// Helper class to drain the contents of a mojo data pipe to a file. -class PipeToFile { - MojoDataPipeConsumer _consumer; - MojoEventStream _eventStream; - IOSink _outputStream; - - PipeToFile(this._consumer, String outputPath) { - _eventStream = new MojoEventStream(_consumer.handle); - _outputStream = new File(outputPath).openWrite(); - } - - Future _doRead() async { - ByteData thisRead = _consumer.beginRead(); - if (thisRead == null) { - throw 'Data pipe beginRead failed: ${_consumer.status}'; - } - // TODO(mpcomplete): Should I worry about the _eventStream listen callback - // being invoked again before this completes? - await _outputStream.add(thisRead.buffer.asUint8List()); - return _consumer.endRead(thisRead.lengthInBytes); - } - - Future drain() async { - Completer completer = new Completer(); - // TODO(mpcomplete): Is it legit to pass an async callback to listen? - _eventStream.listen((List event) async { - MojoHandleSignals mojoSignals = new MojoHandleSignals(event[1]); - if (mojoSignals.isReadable) { - MojoResult result = await _doRead(); - if (!result.isOk) { - _eventStream.close(); - _eventStream = null; - _outputStream.close(); - completer.complete(result); - } else { - _eventStream.enableReadEvents(); - } - } else if (mojoSignals.isPeerClosed) { - _eventStream.close(); - _eventStream = null; - _outputStream.close(); - completer.complete(MojoResult.OK); - } else { - throw 'Unexpected handle event: $mojoSignals'; - } - }); - return completer.future; - } - - static Future copyToFile(MojoDataPipeConsumer consumer, String outputPath) { - PipeToFile drainer = new PipeToFile(consumer, outputPath); - return drainer.drain(); - } -} diff --git a/engine/src/flutter/sky/packages/updater/lib/version.dart b/engine/src/flutter/sky/packages/updater/lib/version.dart deleted file mode 100644 index 15c1ab7d5c..0000000000 --- a/engine/src/flutter/sky/packages/updater/lib/version.dart +++ /dev/null @@ -1,32 +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:math'; - -// This class represents a dot-separated version string. Used for comparing -// versions. -// Usage: assert(new Version('1.1.0') < new Version('1.2.1')); -class Version { - Version(String versionStr) : - _parts = versionStr.split('.').map((String val) => int.parse(val)).toList(); - - List _parts; - - bool operator<(Version other) => _compare(other) < 0; - bool operator==(dynamic other) => other is Version && _compare(other) == 0; - bool operator>(Version other) => _compare(other) > 0; - - int _compare(Version other) { - int length = min(_parts.length, other._parts.length); - for (int i = 0; i < length; ++i) { - if (_parts[i] < other._parts[i]) - return -1; - if (_parts[i] > other._parts[i]) - return 1; - } - return _parts.length - other._parts.length; // results in 1.0 < 1.0.0 - } - - int get hashCode => _parts.fold(373, (int acc, int part) => 37*acc + part); -} diff --git a/engine/src/flutter/sky/packages/updater/pubspec.yaml b/engine/src/flutter/sky/packages/updater/pubspec.yaml deleted file mode 100644 index b8a3bd6919..0000000000 --- a/engine/src/flutter/sky/packages/updater/pubspec.yaml +++ /dev/null @@ -1,16 +0,0 @@ -name: updater -author: Flutter Authors -description: The autoupdater for flutter -homepage: http://flutter.io -dependencies: - flutter: '0.0.18' - yaml: ^2.1.3 - path: ^1.3.0 - flx: 0.0.1 -dependency_overrides: - flutter: - path: ../sky - flx: - path: ../flx -environment: - sdk: '>=1.12.0 <2.0.0' diff --git a/engine/src/flutter/sky/packages/workbench/.gitignore b/engine/src/flutter/sky/packages/workbench/.gitignore deleted file mode 100644 index 47c1956b86..0000000000 --- a/engine/src/flutter/sky/packages/workbench/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -.pub -packages -pubspec.lock diff --git a/engine/src/flutter/sky/packages/workbench/README.md b/engine/src/flutter/sky/packages/workbench/README.md deleted file mode 100644 index 4c3f7e3308..0000000000 --- a/engine/src/flutter/sky/packages/workbench/README.md +++ /dev/null @@ -1,7 +0,0 @@ -Workbench -========= - -The workbench package is a synthetic package that lets us use `pub` to pull in -some packages from `pub.dartlang.org` and some packages from within the source -tree. The workbench package is intended to reflect a typical environment for -developing a Sky application. diff --git a/engine/src/flutter/sky/packages/workbench/pubspec.yaml b/engine/src/flutter/sky/packages/workbench/pubspec.yaml deleted file mode 100644 index 8e113ce082..0000000000 --- a/engine/src/flutter/sky/packages/workbench/pubspec.yaml +++ /dev/null @@ -1,30 +0,0 @@ -name: workbench -version: 0.0.1 -author: Flutter Authors -description: A workspace to host pub packages -homepage: https://github.com/flutter/engine/tree/master/sky/packages/workbench -dependencies: - flutter: - '0.0.16' - sky_tools: any - cipher: any - asn1lib: any - flutter_rendering_examples: any - flutter_sprites: - '0.0.13' - playfair: any - flx: - '0.0.5' -dependency_overrides: - material_design_icons: - path: ../material_design_icons - flutter: - path: ../sky - flutter_rendering_examples: - path: ../../../examples/rendering - flutter_sprites: - path: ../../../skysprites - flx: - path: ../flx -environment: - sdk: '>=1.8.0 <2.0.0' diff --git a/engine/src/flutter/sky/tools/download_sky_shell.py b/engine/src/flutter/sky/tools/download_sky_shell.py deleted file mode 100755 index 328ae0d4fc..0000000000 --- a/engine/src/flutter/sky/tools/download_sky_shell.py +++ /dev/null @@ -1,40 +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 - -def download(base_url, out_dir, name): - url = '%s/%s' % (base_url, name) - dst = os.path.join(out_dir, name) - print 'Downloading', url - subprocess.call([ 'curl', '-o', dst, url ]) - -def main(): - parser = argparse.ArgumentParser(description='Downloads sky_shell from Google storage') - parser.add_argument('revision_file') - parser.add_argument('out_dir') - args = parser.parse_args() - - out_dir = args.out_dir - if not os.path.exists(out_dir): - os.makedirs(out_dir) - - revision = None - with open(args.revision_file, 'r') as f: - revision = f.read() - - base_url = 'https://storage.googleapis.com/mojo/sky/shell/linux-x64/%s' % revision - download(base_url, out_dir, 'sky_shell') - download(base_url, out_dir, 'icudtl.dat') - download(base_url, out_dir, 'sky_snapshot') - - subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_shell' )]) - subprocess.call([ 'chmod', 'a+x', os.path.join(out_dir, 'sky_snapshot' )]) - -if __name__ == '__main__': - sys.exit(main()) diff --git a/engine/src/flutter/sky/tools/release_packages.py b/engine/src/flutter/sky/tools/release_packages.py deleted file mode 100755 index 32a5eb8de7..0000000000 --- a/engine/src/flutter/sky/tools/release_packages.py +++ /dev/null @@ -1,27 +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. - -# See https://github.com/domokit/sky_engine/wiki/Release-process - -import os -import subprocess -import sys - - -def main(): - engine_root = os.path.abspath('.') - if not os.path.exists(os.path.join(engine_root, 'sky')): - print "Cannot find //sky. Is %s the Flutter engine repository?" % engine_root - return 1 - - pub_path = os.path.join(engine_root, 'third_party/dart-sdk/dart-sdk/bin/pub') - - subprocess.check_call([pub_path, 'publish', '--force'], cwd=os.path.join(engine_root, 'sky/packages/sky')) - subprocess.check_call([pub_path, 'publish', '--force'], cwd=os.path.join(engine_root, 'sky/packages/flx')) - subprocess.check_call([pub_path, 'publish', '--force'], cwd=os.path.join(engine_root, 'skysprites')) - - -if __name__ == '__main__': - sys.exit(main()) diff --git a/engine/src/flutter/sky/tools/run_tests b/engine/src/flutter/sky/tools/run_tests deleted file mode 100755 index 2a8073dd15..0000000000 --- a/engine/src/flutter/sky/tools/run_tests +++ /dev/null @@ -1,52 +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 os -import sys -import subprocess -import argparse - -SKY_TOOLS_DIR = os.path.dirname(os.path.abspath(__file__)) -SKY_ROOT = os.path.dirname(SKY_TOOLS_DIR) -SRC_ROOT = os.path.dirname(SKY_ROOT) - -DART_SDK = os.path.join(SRC_ROOT, 'third_party', 'dart-sdk', 'dart-sdk', 'bin') -PUB = os.path.join(DART_SDK, 'pub') - -UNIT_DIR = os.path.join(SRC_ROOT, 'sky', 'unit') -PACKAGES_DIR = os.path.join(UNIT_DIR, 'packages') -TESTS_DIR = os.path.join(UNIT_DIR, 'test') - -def main(): - parser = argparse.ArgumentParser(description='Runs Sky tests') - parser.add_argument('--config', default='Debug') - parser.add_argument('--debug', dest='config', action='store_const', const='Debug') - parser.add_argument('--release', dest='config', action='store_const', const='Release') - args, remaining = parser.parse_known_args() - - build_dir = os.path.join(SRC_ROOT, 'out', args.config) - - sky_shell = None - if sys.platform == 'linux2': - sky_shell = os.path.join(build_dir, 'sky_shell') - elif sys.platform == 'darwin': - sky_shell = os.path.join(build_dir, 'SkyShell.app', 'Contents', 'MacOS', 'SkyShell') - - if not remaining: - for root, dirs, files in os.walk(TESTS_DIR): - remaining.extend(os.path.join(root, f) - for f in files if f.endswith("_test.dart")) - - env = os.environ.copy() - env['SKY_SHELL'] = sky_shell - if env['TERM'] == 'dumb': - remaining = [ '--no-color' ] + remaining - - return subprocess.call([ - PUB, 'run', '--checked', 'sky_tools:sky_test', - ] + remaining, cwd=UNIT_DIR, env=env) - -if __name__ == '__main__': - sys.exit(main())