Bazel is a correct, reproducible, and fast build tool used internally at Google, and now open source, that provides a powerful and extensible framework for building software and maintaining code.
WARNING: This package is highly experimental. While the underlying framework (such as BUILD rules and extensions) are stable, we're still iterating on a good stable solution for end users that are used to primarily working with pub and
Have a suggestion to make this better? File an issue.
Our Bazel package publishes a
bazelify command that takes an existing pub
package and automatically generates a Bazel worskpace: full of extensions,
macros, rules, and more.
NOTE: bazelify requires an existing installation of bazel
If you're familiar with
pub run, then
bazelify is easy:
$ pub global activate bazel
You can run
bazelify on a typical
my_new_package/ bin/ lib/ web/ pubspec.yaml
$ cd my_new_package $ pub global run bazel:bazelify init
If you don't have a project, you can use our
workspace folder of examples.
tool/presubmit.dart for some examples.
bazel run files in
# Assume you have bin/hello.dart # We automatically generate a "hello_bin" target in your BUILD file. $ bazel run :hello_bin
You can also
bazel run a development sever for your web application:
# Assume you have web/main.dart, and web/index.html. $ bazel run :main_dartium_serve
Oh, and did we mention support for the Dart dev compiler?
$ bazel run :main_ddc_serve
We automatically generate a bunch of file for you - don't worry about checking
them in for now - you can safely ignore them when commiting. Here is an example
snippet you can include in a
/bazel-* .bazelify packages.bzl BUILD WORKSPACE
You may also want to exclude the
bazel-* folders from the Dart analyzer
.analysis_options file. This prevents the Dart analyzer from
accidentally "seeing" generated and copied code and needlessly analyzing it.
analyzer: exclude: - 'bazel-*/**'