mirror of
https://github.com/encounter/engine.git
synced 2026-03-30 11:09:55 -07:00
Rationalize Dart mojo and sky package structure.
NOTE: This CL appears far larger than it actually is for two reasons: 1) Many files were moved around to use the Dart package directory structure. 2) Many .dart files had to have import paths updated. - Organize mojo/public/dart so that it uses standard Dart package layout - Organize mojo/dart/apptest so that it uses a standard Dart package layout - Organize sky/sdk so that it uses a standard Dart package layout - Create a mojo/testing package (used by unittests) - Introduce the 'dart_pkg' gn rule which populates gen/Config/dart-pkg - All internally vended Dart packages must have a corresponding dart_pkg rule - It is now possible to use dependency_overrides: in pubspec.yaml to mix internal and external package dependencies (enables analyzer, editor, webstorm usage for internal developers). - Package root for dart content handler ends with "packages/" - Imports of mojo package uris no longer need the "public/dart" - mojo/public/tools/dart_package.py is a clone of mojo/public/tools/gn/zip.py - Sky tests no longer run 'deploy_sdk' script. R=eseidel@chromium.org Review URL: https://codereview.chromium.org/1132063007
This commit is contained in:
@@ -9,6 +9,7 @@ group("sky") {
|
||||
testonly = true
|
||||
|
||||
deps = [
|
||||
"//sky/sdk",
|
||||
"//sky/engine/platform:platform_unittests",
|
||||
"//sky/engine/web:sky_unittests",
|
||||
"//sky/engine/wtf:unittests",
|
||||
|
||||
@@ -60,10 +60,10 @@ action("generate_snapshot_bin") {
|
||||
inputs = [
|
||||
"//dart/runtime/tools/create_snapshot_bin.py",
|
||||
"//sky/engine/bindings/builtin.dart",
|
||||
"//mojo/public/dart/internal.dart",
|
||||
"//mojo/public/dart/src/handle_watcher.dart",
|
||||
"//mojo/public/dart/src/natives.dart",
|
||||
"//mojo/public/dart/src/timer_queue.dart",
|
||||
"//mojo/public/dart/lib/internal.dart",
|
||||
"//mojo/public/dart/lib/src/handle_watcher.dart",
|
||||
"//mojo/public/dart/lib/src/natives.dart",
|
||||
"//mojo/public/dart/lib/src/timer_queue.dart",
|
||||
"snapshot.dart",
|
||||
]
|
||||
vm_isolate_snapshot = "$target_gen_dir/vm_isolate_snapshot.bin"
|
||||
@@ -75,7 +75,7 @@ action("generate_snapshot_bin") {
|
||||
|
||||
builtin_path = rebase_path("//sky/engine/bindings/builtin.dart")
|
||||
dart_sky_path = rebase_path("$bindings_output_dir/dart_sky.dart")
|
||||
internal_path = rebase_path("//mojo/public/dart/internal.dart")
|
||||
internal_path = rebase_path("//mojo/public/dart/lib/internal.dart")
|
||||
|
||||
gen_snapshot_dir =
|
||||
get_label_info("//dart/runtime/bin:gen_snapshot($host_toolchain)",
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# 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("//mojo/public/dart/rules.gni")
|
||||
|
||||
dart_pkg("sdk") {
|
||||
sources = [
|
||||
"CHANGELOG.md",
|
||||
"bin/init.dart",
|
||||
"lib/assets/.gitignore",
|
||||
"lib/assets/material-design-icons.sha1",
|
||||
"lib/download_material_design_icons",
|
||||
"lib/framework/README.md",
|
||||
"lib/framework/animation/animated_value.dart",
|
||||
"lib/framework/animation/curves.dart",
|
||||
"lib/framework/animation/fling_curve.dart",
|
||||
"lib/framework/animation/generators.dart",
|
||||
"lib/framework/animation/mechanics.dart",
|
||||
"lib/framework/animation/scroll_behavior.dart",
|
||||
"lib/framework/components/action_bar.dart",
|
||||
"lib/framework/components/animated_component.dart",
|
||||
"lib/framework/components/button.dart",
|
||||
"lib/framework/components/button_base.dart",
|
||||
"lib/framework/components/checkbox.dart",
|
||||
"lib/framework/components/drawer.dart",
|
||||
"lib/framework/components/drawer_header.dart",
|
||||
"lib/framework/components/fixed_height_scrollable.dart",
|
||||
"lib/framework/components/floating_action_button.dart",
|
||||
"lib/framework/components/icon.dart",
|
||||
"lib/framework/components/icon_button.dart",
|
||||
"lib/framework/components/ink_splash.dart",
|
||||
"lib/framework/components/ink_well.dart",
|
||||
"lib/framework/components/input.dart",
|
||||
"lib/framework/components/material.dart",
|
||||
"lib/framework/components/menu_divider.dart",
|
||||
"lib/framework/components/menu_item.dart",
|
||||
"lib/framework/components/modal_overlay.dart",
|
||||
"lib/framework/components/popup_menu.dart",
|
||||
"lib/framework/components/popup_menu_item.dart",
|
||||
"lib/framework/components/radio.dart",
|
||||
"lib/framework/components/scaffold.dart",
|
||||
"lib/framework/components/scrollable.dart",
|
||||
"lib/framework/debug/shake-to-reload.sky",
|
||||
"lib/framework/debug/tracing.dart",
|
||||
"lib/framework/editing/editable_string.dart",
|
||||
"lib/framework/editing/editable_text.dart",
|
||||
"lib/framework/editing/keyboard.dart",
|
||||
"lib/framework/elements/animation/controller.dart",
|
||||
"lib/framework/elements/animation/timer.dart",
|
||||
"lib/framework/elements/material-element.sky",
|
||||
"lib/framework/elements/shadow.sky",
|
||||
"lib/framework/elements/sky-box.sky",
|
||||
"lib/framework/elements/sky-button.sky",
|
||||
"lib/framework/elements/sky-checkbox.sky",
|
||||
"lib/framework/elements/sky-drawer-header.sky",
|
||||
"lib/framework/elements/sky-drawer.sky",
|
||||
"lib/framework/elements/sky-element.sky",
|
||||
"lib/framework/elements/sky-icon.sky",
|
||||
"lib/framework/elements/sky-ink-splash.sky",
|
||||
"lib/framework/elements/sky-input.sky",
|
||||
"lib/framework/elements/sky-menu-divider.sky",
|
||||
"lib/framework/elements/sky-menu-item.sky",
|
||||
"lib/framework/elements/sky-radio.sky",
|
||||
"lib/framework/elements/sky-scrollable.sky",
|
||||
"lib/framework/elements/sky-toolbar.sky",
|
||||
"lib/framework/embedder.dart",
|
||||
"lib/framework/fn.dart",
|
||||
"lib/framework/layout.dart",
|
||||
"lib/framework/layouts/block.dart",
|
||||
"lib/framework/net/fetch.dart",
|
||||
"lib/framework/node.dart",
|
||||
"lib/framework/reflect.dart",
|
||||
"lib/framework/shell.dart",
|
||||
"lib/framework/theme/colors.dart",
|
||||
"lib/framework/theme/shadows.dart",
|
||||
"lib/framework/theme/typography.dart",
|
||||
"lib/framework/theme/view_configuration.dart",
|
||||
"lib/sky_tool",
|
||||
"pubspec.yaml",
|
||||
]
|
||||
|
||||
deps = [
|
||||
"//sky/services/testing:bindings",
|
||||
]
|
||||
}
|
||||
-223
@@ -1,223 +0,0 @@
|
||||
Contributing
|
||||
============
|
||||
|
||||
[sky_sdk](https://github.com/domokit/sky_sdk) is generated from the
|
||||
[mojo repository](https://github.com/domokit/mojo) using
|
||||
[deploy_sdk.py](https://github.com/domokit/mojo/blob/master/sky/tools/deploy_sdk.py)
|
||||
Static files (including this README.md) are located under
|
||||
[sky/sdk](https://github.com/domokit/mojo/tree/master/sky/sdk). Pull
|
||||
requests and issue reports are glady accepted at the
|
||||
[mojo repository](https://github.com/domokit/mojo)!
|
||||
|
||||
Sky
|
||||
===
|
||||
|
||||
Sky is an experimental, high-performance UI framework for mobile apps. Sky helps
|
||||
you create apps with beautiful user interfaces and high-quality interactive
|
||||
design that run smoothly at 120 Hz.
|
||||
|
||||
Sky consists of two components:
|
||||
|
||||
1. *The Sky engine.* The engine is the core of the system. Written in C++, the
|
||||
engine provides the muscle of the Sky system. The engine provides
|
||||
several primitives, including a soft real-time scheduler and a hierarchical,
|
||||
retained-mode graphics system, that let you build high-quality apps.
|
||||
|
||||
2. *The Sky framework.* The [framework](packages/sky/lib/framework) makes it
|
||||
easy to build apps using Sky by providing familiar user interface widgets,
|
||||
such as buttons, infinite lists, and animations, on top of the engine using
|
||||
Dart. These extensible components follow a functional programming style
|
||||
inspired by [React](http://facebook.github.io/react/).
|
||||
|
||||
We're still iterating on Sky heavily, which means the framework and underlying
|
||||
engine are both likely to change in incompatible ways several times, but if
|
||||
you're interested in trying out the system, this document can help you get
|
||||
started.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Sky uses Dart and Sky applications are
|
||||
[Dart Packages](https://www.dartlang.org/docs/tutorials/shared-pkgs/).
|
||||
Application creation starts by creating a new directory and
|
||||
adding a [pubspec.yaml](https://www.dartlang.org/tools/pub/pubspec.html):
|
||||
|
||||
pubspec.yaml for your app:
|
||||
```yaml
|
||||
name: your_app_name
|
||||
dependencies:
|
||||
sky: any
|
||||
```
|
||||
|
||||
Once the pubspec is in place, create a `lib` directory (where your dart code
|
||||
will go), ensure that the 'dart' and 'pub' executables are on your $PATH and
|
||||
run the following:
|
||||
|
||||
`pub get && pub run sky:init`.
|
||||
|
||||
Currently the Sky Engine assumes the entry point for your application is a
|
||||
`main` function located inside a `main.sky` file at the root of the package.
|
||||
`.sky` is an html-like format:
|
||||
```
|
||||
<sky>
|
||||
<script>
|
||||
import 'package:your_app_name/main.dart';
|
||||
|
||||
void main() {
|
||||
new HelloWorldApp();
|
||||
}
|
||||
</script>
|
||||
</sky>
|
||||
```
|
||||
|
||||
The rest of the application then goes inside the `lib` directory of the package
|
||||
thus `lib/main.dart` would be:
|
||||
|
||||
```dart
|
||||
import 'package:sky/framework/fn.dart';
|
||||
|
||||
class HelloWorldApp extends App {
|
||||
UINode build() {
|
||||
return new Text('Hello, world!');
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
Execution starts in `main`, which creates the `HelloWorldApp`. The framework
|
||||
then marks `HelloWorldApp` as dirty, which schedules it to build during the next
|
||||
animation frame. Each animation frame, the framework calls `build` on all the
|
||||
dirty components and diffs the virtual `UINode` hierarchy returned this frame
|
||||
with the hierarchy returned last frame. Any differences are then applied as
|
||||
mutations to the physical hierarchy retained by the engine.
|
||||
|
||||
Skip down to "Running a Sky application" to learn how to load and run this
|
||||
example on your device.
|
||||
|
||||
For examples, please see the [examples directory](examples/).
|
||||
|
||||
Services
|
||||
--------
|
||||
|
||||
Sky apps can access services from the host operating system using Mojo IPC. For
|
||||
example, you can access the network using the `network_service.mojom` interface.
|
||||
Although you can use these low-level interfaces directly, you might prefer to
|
||||
access these services via libraries in the framework. For example, the
|
||||
`fetch.dart` library wraps the underlying `network_service.mojom` in an
|
||||
ergonomic interface:
|
||||
|
||||
```dart
|
||||
import 'package:sky/framework/net/fetch.dart';
|
||||
|
||||
main() async {
|
||||
Response response = await fetch('example.txt');
|
||||
print(response.bodyAsString());
|
||||
}
|
||||
```
|
||||
|
||||
Set up your computer
|
||||
--------------------
|
||||
|
||||
1. Install the Dart SDK:
|
||||
- https://www.dartlang.org/tools/download.html
|
||||
|
||||
2. Install the ``adb`` tool from the Android SDK:
|
||||
- https://developer.android.com/sdk/installing/index.html
|
||||
|
||||
3. Install the Sky SDK:
|
||||
- ``git clone https://github.com/domokit/sky_sdk.git``
|
||||
|
||||
4. Ensure that $DART_SDK is set to the path of your Dart SDK and 'adb'
|
||||
(inside 'platform-tools' in the android sdk) is in your $PATH.
|
||||
|
||||
Set up your device
|
||||
------------------
|
||||
|
||||
Currently Sky requires an Android device running the Lollipop (or newer) version
|
||||
of the Android operating system.
|
||||
|
||||
1. Enable developer mode on your device by visiting ``Settings > About phone``
|
||||
and tapping the ``Build number`` field five times.
|
||||
|
||||
2. Enable ``USB debugging`` in ``Settings > Developer options``.
|
||||
|
||||
3. Using a USB cable, plug your phone into your computer. If prompted on your
|
||||
device, authorize your computer to access your device.
|
||||
|
||||
Running a Sky application
|
||||
-------------------------
|
||||
|
||||
The `sky` pub package includes a `sky_tool` script to assist in running
|
||||
Sky applications inside the `SkyDemo.apk` harness. The sky_tool script expects
|
||||
to be run from the root directory of your application pub package. To run
|
||||
one of the examples in this SDK, try:
|
||||
|
||||
1. ``cd examples/stocks``
|
||||
|
||||
2. ``pub get`` to set up a copy of the sky package in the app directory.
|
||||
|
||||
3. ``./packages/sky/sky_tool start`` to start the dev server and upload your
|
||||
app to the device.
|
||||
(NOTE: add a ``--install`` flag to install SkyDemo.apk if not already
|
||||
installed on the device.)
|
||||
|
||||
4. Use ``adb logcat`` to view any errors or Dart print() output from the app.
|
||||
``adb logcat -s chromium`` can be used to filter only adb messages from
|
||||
`SkyDemo.apk` (which for
|
||||
[legacy reasons](https://github.com/domokit/mojo/issues/129) still uses the
|
||||
android log tag 'chromium').
|
||||
|
||||
Measuring Performance
|
||||
---------------------
|
||||
|
||||
Sky has support for generating trace files compatible with
|
||||
[Chrome's about:tracing](https://www.chromium.org/developers/how-tos/trace-event-profiling-tool).
|
||||
|
||||
`packages/sky/sky_tool start_tracing` and `packages/sky/sky_tool stop_tracing`
|
||||
are the commands to use.
|
||||
|
||||
Due to https://github.com/domokit/mojo/issues/127 tracing currently
|
||||
requires root access on the device.
|
||||
|
||||
Debugging
|
||||
---------
|
||||
|
||||
Dart's [Observatory](https://www.dartlang.org/tools/observatory/)
|
||||
(VM Debugger & Profiler) support in Sky is
|
||||
[in progress](https://codereview.chromium.org/1107803002) and should
|
||||
be released shortly after Dart Summit 2015.
|
||||
|
||||
Building a standalone MyApp
|
||||
---------------------------
|
||||
|
||||
Although it is possible to bundle the Sky Engine in your own app (instead of
|
||||
running your code inside SkyDemo.apk), right now doing so is difficult.
|
||||
|
||||
There is one example of doing so if you're feeling brave:
|
||||
https://github.com/domokit/mojo/tree/master/sky/apk/stocks
|
||||
|
||||
Eventually we plan to make this much easier and support platforms other than
|
||||
Android, but that work is yet in progress.
|
||||
|
||||
Adding Services to MyApp
|
||||
------------------------
|
||||
|
||||
[Mojo IPC](https://github.com/domokit/mojo) is an inter-process-communication
|
||||
system designed to provide cross-thread, cross-process, and language-agnostic
|
||||
communication between applications. Sky uses Mojo IPC to make it possible
|
||||
to write UI code in Dart and yet depend on networking code, etc. written in
|
||||
another language. Services are replicable, meaning that Dart code
|
||||
written to use the `network_service` remains portable to any platform
|
||||
(iOS, Android, etc.) by simply providing a 'natively' written `network_service`.
|
||||
|
||||
Embedders of the Sky Engine and consumers of the Sky Framework can use this
|
||||
same mechanism to expose not only existing services like the
|
||||
[Keyboard](https://github.com/domokit/mojo/blob/master/mojo/services/keyboard/public/interfaces/keyboard.mojom)
|
||||
service to allow Sky Framework Dart code to interface with the underlying
|
||||
platform's Keyboard, but also to expose any additional non-Dart business logic
|
||||
to Sky/Dart UI code.
|
||||
|
||||
As and example, [SkyApplication](https://github.com/domokit/mojo/blob/master/sky/shell/org/domokit/sky/shell/SkyApplication.java)
|
||||
exposes a mojo `network_service` (required by Sky Engine C++ code)
|
||||
[SkyDemoApplication](https://github.com/domokit/mojo/blob/master/sky/apk/demo/org/domokit/sky/demo/SkyDemoApplication.java)
|
||||
additionally exposes `keyboard_service` and `sensor_service` for use by the Sky
|
||||
Framework from Dart.
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user