diff options
author | 2017-10-24 21:06:01 +0200 | |
---|---|---|
committer | 2017-10-25 16:46:09 +0200 | |
commit | a6ee57af0f43c407b4089cb4f5075498eee29f7b (patch) | |
tree | df27a59db77dfde37e63f773e7c7eae8638e5938 /site | |
parent | 97a5141ab049bd2ea9cc7315e2c4981513d0ed62 (diff) |
Create a new "Getting Started with Bazel" page.
PiperOrigin-RevId: 173291756
Diffstat (limited to 'site')
-rw-r--r-- | site/docs/getting-started.md | 145 |
1 files changed, 55 insertions, 90 deletions
diff --git a/site/docs/getting-started.md b/site/docs/getting-started.md index 92d98ca006..53396672e6 100644 --- a/site/docs/getting-started.md +++ b/site/docs/getting-started.md @@ -5,93 +5,58 @@ title: Getting Started # Getting Started with Bazel -## Setup - -Use the [installation instructions](install.html) to install a copy of -Bazel on your machine. - -## Using a Workspace - -All Bazel builds take place in a [_workspace_](build-ref.html#workspaces), -a directory on your filesystem that contains source code for the software you -want to build, as well as symbolic links to directories that contain the build -outputs (for example, `bazel-bin` and `bazel-out`). The location of the -workspace directory is not significant, but it must contain a file called -`WORKSPACE` in the top-level directory; an empty file is a valid workspace. -The `WORKSPACE` file can be used to reference -[external dependencies](external.html) required to build the outputs. -One workspace can be shared among multiple projects if desired. - -```bash -touch WORKSPACE -``` - -## Creating a Build File - -To know which targets can be built in your project, Bazel inspects `BUILD` -files. They are written in Bazel's build language which is syntactically -similar to Python. Usually they are just a sequence of declarations of rules. -Each rule specifies its inputs, outputs, and a way to compute the outputs from -the inputs. - -The rule probably most familiar to people who have used `Makefile`s before (as -it is the only rule available there) is the -[genrule](be/general.html#genrule), which specifies how the output can -be generated by invoking a shell command. - -``` -genrule( - name = "hello", - outs = ["hello_world.txt"], - cmd = "echo Hello World > $@", -) -``` - -The shell command may contain [Make variables](be/make-variables.html). - -Using the above `BUILD` file, you can ask Bazel to generate the target. - -``` -$ bazel build :hello -. -INFO: Found 1 target... -Target //:hello up-to-date: - bazel-genfiles/hello_world.txt -INFO: Elapsed time: 2.255s, Critical Path: 0.07s -``` - -We note two things. First, targets are normally referred to by their -[label](build-ref.html#labels), which is specified by the -[name](be/general.html#genrule.name) attribute of the rule. (Referencing -them by the output file name is also possible, but this is not the preferred -way.) Second, Bazel puts the generated files into a separate directory (the -`bazel-genfiles` directory is actually a symbolic link) so as not to pollute -your source tree. - -Rules may use the output of other rules as input, as in the following -example. Again, the generated sources are referred to by their label. - -``` -genrule( - name = "hello", - outs = ["hello_world.txt"], - cmd = "echo Hello World > $@", -) - -genrule( - name = "double", - srcs = [":hello"], - outs = ["double_hello.txt"], - cmd = "cat $< $< > $@", -) -``` - -Finally, note that, while the [genrule](be/general.html#genrule) might -seem familiar, it usually is _not_ the best rule to use. It is preferrable to -use one of the specialized [rules](be/overview.html#rules) for various -languages. - -# Next Steps - -Next, check out the tutorial on building [Java](tutorial/java.html) -or [C++](tutorial/cpp.html) programs. +This page lists material that will help you get started with Bazel. If you have +not already done so, first read the [Bazel Overview](bazel-overview.html). + +## Installation + +To install Bazel, see [Installing Bazel](install.html). + + +## Tutorials + +To get hands-on with Bazel and understand its core concepts, complete a +tutorial: + +* [Tutorial: Build a C++ Project](tutorial/cpp.html) + +* [Tutorial: Build a Java Project](tutorial/java.html) + +* [Tutorial: Build an Android Application](tutorial/android-app.html) + +* [Tutorial: Build an iOS Application](tutorial/ios-app.html) + + +## Migration + +To learn how to migrate your project to Bazel, see the appropriate migration +guide: + +* [Migrating from Maven to Bazel](migrate-maven.html) + +* [Migrating from Xcode to Bazel](migrate-xcode.html) + + +## Language-specific resources + +Once you are familiar with Bazel, take a look at the language-specific +resources, such as functions and build rules: + +* [C++ and Bazel](bazel-and-cpp.html) + +* [Java and Bazel](bazel-and-java.html) + +* [Android and Bazel](bazel-and-android.html) + +* [Apple apps and Bazel](bazel-and-apple.html) + + +## Reference + +To further explore Bazel, refer to the following resources: + +* [Bazel Concepts and Terminology](build-ref.html) + +* [Bazel User Manual](user-manual.html) + +* [Build Encyclopedia](https://docs.bazel.build/versions/master/be/overview.html) |