bazel 0.2.2 bazel: ^0.2.2 copied to clipboard
Bazel support for Dart
Bazel extension support for Dart.
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.
Why Bazel #
Large applications in Google like AdWords Next and AdSense have used Dart and Angular Dart in production with Bazel for a while, and now we want to share Bazel with the rest of the community.
Getting Started #
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
pubspec.yaml
files.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.
Installation #
NOTE: bazelify requires an existing installation of bazel
If you're familiar with pub run
, then bazelify
is easy:
$ pub global activate bazel
Generation #
You can run bazelify
on a typical pub
package:
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.
See tool/presubmit.dart
for some examples.
Usage #
You can bazel run
files in bin/
:
# 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
Cleaning up #
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 .gitignore
:
/bazel-*
.bazelify
packages.bzl
BUILD
WORKSPACE
You may also want to exclude the bazel-*
folders from the Dart analyzer
using an .analysis_options
file. This prevents the Dart analyzer from
accidentally "seeing" generated and copied code and needlessly analyzing it.
analyzer:
exclude:
- 'bazel-*/**'