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