Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
# build "verbosely", outputting all commands as they are run
./dev build short -- -s

You can (unless you’re on an M1!) cross-compile with the --cross option, as in:

...

--cross takes an optional argument which is the platform to cross-compile to: --cross=linux, --cross=windows, --cross=macos. dev will symlink the built binaries into the artifacts directory in this case. Note that cross-building requires Docker. Cross-compiling should work on M1 Macs, but this support is experimental, so report issues if you should observe any.

For more debugging tips on building with Bazel, see “How to ensure your code builds with Bazel

...

dev/bazel command

equivalent non-bazel command

./dev build

make build

./dev build short

make buildshort

./dev build pkg/sql/...

make build PKG=./pkg/sql/...

./dev test

make test

./dev test pkg/sql/parser --filter TestParse

make test PKG=./pkg/sql/parser TESTS=TestParse

./dev bench pkg/sql/parser --filter BenchmarkParse

make bench PKG=./pkg/sql/parser BENCHES=BenchmarkParse

./dev build --cross

build/builder.sh mkrelease

./dev builder

build/builder.sh

./dev testlogic base --files=fk --subtests=20042 --config=local

make testbaselogic FILES=fk SUBTESTS=20042 TESTCONFIG=local

Add build --define gotags=bazel,gss,X,Y to .bazelrc.user, then running dev

make ... TAGS=X,Y

...

  • You should still ask dev doctor if your machine is up-to-snuff before you try to bazel build. The checks it performs aren’t dev-specific.

  • dev prints out the (relevant) calls to bazel it makes before it does so. You can therefore run dev once just to learn how to ask Bazel to perform your build/test and then just directly call into bazel on subsequent iterations.

  • If you want to build with the UI, you must include the --config with_ui argument to bazel build. dev checks whether your executable should include the UI bits and passes it in for you.(dev takes care of this for you if you are using it.)

  • In general, test targets are named after the package under test plus the suffix _test. For example: bazel test pkg/sql/parser:parser_test. Note that there are exceptions: pkg/roachpb:string_test is one, and more may be added later.

  • If you want to build a test without running it, you must include the the --config test argument to bazel build. (dev takes care of this for you if you are using it.)

  • When running tests under stress, race, --rewritedev does the legwork to invoke with the necessary flags with bazel. This involves running under another binary (stress), running with certain gotags (race), or allowing certain paths outside the bazel sandbox to be written to (testdata). Feel free to see the actual bazel command invoked and tweak as necessary.

...