David Chen | 3e8bcae | 2016-07-26 20:54:03 +0000 | [diff] [blame] | 1 | --- |
| 2 | layout: documentation |
| 3 | title: Tutorial - Set Up a Workspace |
| 4 | --- |
| 5 | |
| 6 | # Tutorial - Set Up a Workspace |
| 7 | |
| 8 | A [workspace](/docs/build-ref.html#workspaces) is a directory that contains the |
| 9 | source files for one or more software projects, as well as a `WORKSPACE` file |
| 10 | and `BUILD` files that contain the instructions that Bazel uses to build |
| 11 | the software. It also contains symbolic links to output directories in the |
| 12 | Bazel home directory. |
| 13 | |
| 14 | A workspace directory can be located anywhere on your filesystem. In this |
| 15 | tutorial, your workspace directory is `$HOME/examples/tutorial/`, which |
| 16 | contains the sample project files you cloned from the GitHub repo in the |
| 17 | previous step. |
| 18 | |
| 19 | Note that Bazel itself doesn't make any requirements about how you organize |
| 20 | source files in your workspace. The sample source files in this tutorial are |
| 21 | organized according to common conventions for Android apps, iOS apps and App |
| 22 | Engine applications. |
| 23 | |
| 24 | For your convenience, set the `$WORKSPACE` environment variable now to refer to |
| 25 | your workspace directory. At the command line, enter: |
| 26 | |
| 27 | ```bash |
| 28 | $ export WORKSPACE=$HOME/examples/tutorial |
| 29 | ``` |
| 30 | |
| 31 | ## Create a WORKSPACE file |
| 32 | |
| 33 | Every workspace must have a text file named `WORKSPACE` located in the top-level |
| 34 | workspace directory. This file may be empty or it may contain references |
| 35 | to [external dependencies](/docs/external.html) required to build the |
| 36 | software. |
| 37 | |
| 38 | For now, you'll create an empty `WORKSPACE` file, which simply serves to |
| 39 | identify the workspace directory. In later steps, you'll update the file to add |
| 40 | external dependency information. |
| 41 | |
| 42 | Enter the following at the command line: |
| 43 | |
| 44 | ```bash |
| 45 | $ touch $WORKSPACE/WORKSPACE |
| 46 | ``` |
| 47 | |
| 48 | This creates the empty `WORKSPACE` file. |
| 49 | |
| 50 | ## What's next |
| 51 | |
| 52 | Now that you've set up your workspace, you can |
| 53 | [build the Android app](android-app.md). |