Skip to content

Add support for building with Bazel.#533

Merged
dmah42 merged 3 commits intogoogle:masterfrom
jmillikin-stripe:bazel-build
Mar 8, 2018
Merged

Add support for building with Bazel.#533
dmah42 merged 3 commits intogoogle:masterfrom
jmillikin-stripe:bazel-build

Conversation

@jmillikin-stripe
Copy link
Copy Markdown
Contributor

@jmillikin-stripe jmillikin-stripe commented Feb 21, 2018

Limitations compared to existing CMake rules:

  • Defaults to using C++11 <regex>, with an override via Bazel flag --define of google_benchmark.have_regex. The TravisCI config sets the regex implementation to posix because it uses ancient compilers.
  • Debug vs Opt mode can't be set per test. TravisCI runs all the tests in debug mode to satisfy diagnostics_test, which depends on CHECK being live.

If accepted, this would obsolete PRs #496 and #501.

I plan to use this for Envoy to replace build_recipes/benchmark.sh.

@jmillikin-stripe jmillikin-stripe force-pushed the bazel-build branch 3 times, most recently from c056c3e to 81a9620 Compare February 21, 2018 05:36
Limitations compared to existing CMake rules:
* Defaults to using C++11 `<regex>`, with an override via Bazel flag
  `--define` of `google_benchmark.have_regex`. The TravisCI config sets
  the regex implementation to `posix` because it uses ancient compilers.
* Debug vs Opt mode can't be set per test. TravisCI runs all the tests
  in debug mode to satisfy `diagnostics_test`, which depends on `CHECK`
  being live.
@AppVeyorBot
Copy link
Copy Markdown

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 21, 2018

Coverage Status

Coverage increased (+0.04%) to 87.048% when pulling fd49f8b on jmillikin-stripe:bazel-build into 6ecf8a8 on google:master.

@AppVeyorBot
Copy link
Copy Markdown

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

cc @dominichamon

Dominic, will you have time to review this PR, or should I find someone else?

@@ -0,0 +1,7 @@
load("@bazel_tools//tools/build_defs/repo:git.bzl", "git_repository")

git_repository(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as per bazel, it may be worth changing this to http_archive: https://docs.bazel.build/versions/master/be/workspace.html

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to leave this as git_repository, because the auto-generated tarballs created by GitHub don't have stable checksums. See tensorflow/tensorflow#12979 and bazelbuild/bazel#3737 for some examples of GitHub breaking builds by tweaking their tarball builder.

http_repository does work well for GitHub "release" tarballs uploaded by maintainers, such as the Protobuf releases. Googletest doesn't have any of those, though.

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Mar 7, 2018

Other than the minor thing above (which could be a followup) I'm comfortable with this PR. And thank you for including the tests and travis changes.

It seems that maintenance is relatively sane too given the use of globs.

Let me know if you want to replace the git_repository or not and then I'll merge.

This is recommended by the Bazel style guide to avoid each dependent
workspace defining its own name for the dependency.
@AppVeyorBot
Copy link
Copy Markdown

@jmillikin-stripe
Copy link
Copy Markdown
Contributor Author

That AppVeyor failure looks unrelated to this PR, since it occurred in the cmake build.

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Mar 7, 2018

I agree, it looks like the appveyor failure is due to flakiness in the regex where the tests run slower than expected.

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Mar 7, 2018

Leaving this a day for more comments... @pleroy @EricWF any thoughts?

@pleroy
Copy link
Copy Markdown
Contributor

pleroy commented Mar 7, 2018

Looks good. Thanks for doing this.

@dmah42 dmah42 merged commit a9beffd into google:master Mar 8, 2018
@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Mar 8, 2018

thank you!

@jmillikin-stripe jmillikin-stripe deleted the bazel-build branch March 8, 2018 17:04
EricWF pushed a commit to efcs/benchmark that referenced this pull request Mar 22, 2018
* Add myself to CONTRIBUTORS under the corp CLA for Stripe, Inc.

* Add support for building with Bazel.

Limitations compared to existing CMake rules:
* Defaults to using C++11 `<regex>`, with an override via Bazel flag
  `--define` of `google_benchmark.have_regex`. The TravisCI config sets
  the regex implementation to `posix` because it uses ancient compilers.
* Debug vs Opt mode can't be set per test. TravisCI runs all the tests
  in debug mode to satisfy `diagnostics_test`, which depends on `CHECK`
  being live.

* Set Bazel workspace name so other repos can refer to it by stable name.

This is recommended by the Bazel style guide to avoid each dependent
workspace defining its own name for the dependency.
JBakamovic pushed a commit to JBakamovic/benchmark that referenced this pull request Dec 6, 2018
* Add myself to CONTRIBUTORS under the corp CLA for Stripe, Inc.

* Add support for building with Bazel.

Limitations compared to existing CMake rules:
* Defaults to using C++11 `<regex>`, with an override via Bazel flag
  `--define` of `google_benchmark.have_regex`. The TravisCI config sets
  the regex implementation to `posix` because it uses ancient compilers.
* Debug vs Opt mode can't be set per test. TravisCI runs all the tests
  in debug mode to satisfy `diagnostics_test`, which depends on `CHECK`
  being live.

* Set Bazel workspace name so other repos can refer to it by stable name.

This is recommended by the Bazel style guide to avoid each dependent
workspace defining its own name for the dependency.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants