CONTRIBUTING.md 8.1 KB
Newer Older
1 2
Contributing to the Flutter engine
==================================
A
Adam Barth 已提交
3

4
[![Build Status](https://travis-ci.org/flutter/engine.svg)](https://travis-ci.org/flutter/engine)
A
Adam Barth 已提交
5

I
Ian Hickson 已提交
6 7 8
Things you will need
--------------------

C
Collin Jackson 已提交
9
 * Linux or Mac OS X. (Windows is not yet supported.)
I
Ian Hickson 已提交
10
 * git (used for source version control).
I
Ian Hickson 已提交
11
 * An IDE. We recommend [Atom](https://github.com/flutter/engine/wiki/Using-Atom-with-Flutter).
I
Ian Hickson 已提交
12
 * An ssh client (used to authenticate with GitHub).
A
Adam Barth 已提交
13
 * Chromium's [depot_tools](http://www.chromium.org/developers/how-tos/install-depot-tools) (make sure it's in your path). We use the `gclient` tool from depot_tools.
I
Ian Hickson 已提交
14 15
 * Python (used by many of our tools, including 'gclient').
 * curl (used by `gclient sync`).
I
Ian Hickson 已提交
16

I
Ian Hickson 已提交
17
You do not need [Dart](https://www.dartlang.org/downloads/linux.html) installed, as a Dart tool chain is automatically downloaded as part of the "getting the code" step. Similarly for the Android SDK, it's downloaded by the build step below where you run `download_android_tools.py`.
I
Ian Hickson 已提交
18

I
Ian Hickson 已提交
19 20
Getting the code and configuring your environment
-------------------------------------------------
A
Adam Barth 已提交
21

I
Ian Hickson 已提交
22
 * Ensure all the dependencies described in the previous section, in particular git, ssh, depot_tools, python, and curl, are installed.
I
Ian Hickson 已提交
23
 * Fork `https://github.com/flutter/engine` into your own GitHub account. If you already have a fork, and are now installing a development environment on a new machine, make sure you've updated your fork so that you don't use stale configuration options from long ago.
I
Ian Hickson 已提交
24
 * If you haven't configured your machine with an SSH key that's known to github then
H
updated  
Hans Muller 已提交
25
   follow the directions here: https://help.github.com/articles/generating-ssh-keys/.
I
Ian Hickson 已提交
26
 * Create an empty directory for your copy of the repository. For best results, call it `engine`: some of the tools assume this name when working across repositories. (They can be configured to use other names too, so this isn't a strict requirement.)
27
 * Create a `.gclient` file in the `engine` directory with the following contents, replacing
A
Adam Barth 已提交
28
   `<your_name_here>` with your GitHub account name:
A
Adam Barth 已提交
29 30 31 32 33 34

```
solutions = [
  {
    "managed": False,
    "name": "src",
35
    "url": "git@github.com:<your_name_here>/engine.git",
A
Adam Barth 已提交
36 37 38 39 40 41 42
    "custom_deps": {},
    "deps_file": "DEPS",
    "safesync_url": "",
  },
]
target_os = ["android"]
```
43 44

 * `cd engine` (Change to the directory in which you put the `.gclient` file.)
I
Ian Hickson 已提交
45
 * `gclient sync` This will fetch all the source code that Flutter depends on. Avoid interrupting this script, it can leave your repository in an inconsistent state that is tedious to clean up.
46
 * `cd src` (Change to the directory that `gclient sync` created in your `engine` directory.)
I
Ian Hickson 已提交
47
 * `git remote add upstream git@github.com:flutter/engine.git` (So that you fetch from the master repository, not your clone, when running `git fetch` et al.)
I
Ian Hickson 已提交
48
 * Run `./tools/android/download_android_tools.py` to add Android dependencies to your tree. You will need to run this command again if you ever run `git clean -xdf`, since that deletes these dependencies. (`git clean -df` is fine since it skips these `.gitignore`d files.)
49 50 51
 * Add `.../engine/src/third_party/dart-sdk/dart-sdk/bin/` to your path so that you can run the `pub` tool more easily.
 * Add `.../engine/src/third_party/android_tools/sdk/platform-tools` to your path so that you can run the `adb` tool more easily. This is also required by the `flutter` tool, which is used to run Flutter apps.
 * Make sure you are still in the `src` directory that the `gclient sync` step created earlier.
52 53
 * If you're on Linux, run `sudo ./build/install-build-deps-android.sh`
 * If you're on Linux, run `sudo ./build/install-build-deps.sh`
I
Ian Hickson 已提交
54
 * If you're on Mac, install Oracle's Java JDK, version 1.7 or later.
55
 * If you're on Mac, install `ant`: `brew install ant`
A
Adam Barth 已提交
56

57 58
Building and running the code
-----------------------------
A
Adam Barth 已提交
59

60 61
### Android (cross-compiling from Mac or Linux)

62
Run the following steps, from the `src` directory created in the steps above:
63

64 65 66
 * `gclient sync` to update your dependencies.
 * `./sky/tools/gn --android` to prepare your build files.
 * `ninja -C out/android_Debug` to build an Android Debug binary.
67

68 69
To run an example with your locally built binary, you'll also need to clone
[the main Flutter repository](https://github.com/flutter/flutter). See
A
Adam Barth 已提交
70
[the instructions for contributing](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md)
71
to the main Flutter repository for detailed instructions.
A
Adam Barth 已提交
72

73 74
Once you've got everything set up, you can run an example using your locally
built engine by switching to that example's directory, running `pub get` to make
75
sure its dependencies have been downloaded, and using `flutter run` with an
76 77
explicit `--engine-src-path` pointing at the `src` directory. Make sure you have
a device connected over USB and debugging enabled on that device:
A
Adam Barth 已提交
78

79 80
 * `cd /path/to/flutter/examples/hello_world`
 * `pub get`
81
 * `../../bin/flutter run --engine-src-path /path/to/engine/src`
A
Adam Barth 已提交
82

83 84 85 86
You can also specify a particular Dart file to run if you want to run an example
that doesn't have a `lib/main.dart` file using the `-t` command-line option. For
example, to run the `tabs.dart` example in the `examples/widgets` directory on a
connected Android device, from that directory you would run:
87

88
 * `flutter run --engine-src-path /path/to/engine/src -t tabs.dart`
89

90 91 92 93 94
If you're going to be debugging crashes in the engine, make sure you add
`android:debuggable="true"` to the `<application>` element in the
`android/AndroidManifest.xml` file for the Flutter app you are using
to test the engine.

95 96 97 98
### iOS

See [this wiki page](https://github.com/flutter/engine/wiki/Flutter-Apps-on-iOS).

99 100 101 102
### Desktop (Mac and Linux), for tests

 * `gclient sync` to update your dependencies.
 * `./sky/tools/gn` to prepare your build files.
103
 * `ninja -C out/Debug` to build a desktop Debug binary.
104

105
To run the tests, you'll also need to clone [the main Flutter repository](https://github.com/flutter/flutter).
S
Seth Ladd 已提交
106
See [the instructions for contributing](https://github.com/flutter/flutter/blob/master/CONTRIBUTING.md)
107
to the main Flutter repository for detailed instructions.
108

A
Adam Barth 已提交
109 110 111
Contributing code
-----------------

112
We gladly accept contributions via GitHub pull requests.
113 114

To start working on a patch:
115 116 117

 * `git fetch upstream`
 * `git checkout upstream/master -b name_of_your_branch`
H
Hixie 已提交
118 119 120 121 122
 * Hack away. Please peruse our
   [style guides](https://flutter.io/style-guide/) and
   [design principles](https://flutter.io/design-principles/) before
   working on anything non-trivial. These guidelines are intended to
   keep the code consistent and avoid common pitfalls.
123
 * `git commit -a -m "<your brief but informative commit message>"`
124
 * `git push origin name_of_your_branch`
125 126 127

To send us a pull request:

128 129
 * `git pull-request` (if you are using [Hub](http://github.com/github/hub/)) or
   go to `https://github.com/flutter/engine` and click the
130
   "Compare & pull request" button
C
Collin Jackson 已提交
131

Y
yjbanov 已提交
132 133
Once you've gotten an LGTM from a project maintainer, submit your changes to the
`master` branch using one of the following methods:
134 135 136 137 138 139

* Wait for one of the project maintainers to submit it for you
* Click the green "Merge pull request" button on the GitHub UI of your pull
  request (requires commit access)
* `git push upstream name_of_your_branch:master` (requires commit access)

I
Ian Hickson 已提交
140 141 142 143 144
Then, make sure it doesn't make our tree catch fire by watching [the waterfall](https://build.chromium.org/p/client.flutter/waterfall). The waterfall runs
slightly different tests than Travis, so it's possible for the tree to go red even if
Travis did not. If that happens, please immediately revert your change. Do not check
anything in while the tree is red unless you are trying to resolve the problem.

I
Ian Hickson 已提交
145 146 147 148 149
Please make sure all your checkins have detailed commit messages explaining the patch.
If you made multiple commits for a single pull request, either make sure each one has a detailed
message explaining that specific commit, or squash your commits into one single checkin with a
detailed message before sending the pull request.

C
Collin Jackson 已提交
150 151 152 153
You must complete the
[Contributor License Agreement](https://cla.developers.google.com/clas).
You can do this online, and it only takes a minute.
If you've never submitted code before, you must add your (or your
C
Collin Jackson 已提交
154
organization's) name and contact info to the [AUTHORS](AUTHORS) file.