Skip to content

bazel build support#496

Closed
monkeynova wants to merge 1 commit intogoogle:masterfrom
monkeynova:master
Closed

bazel build support#496
monkeynova wants to merge 1 commit intogoogle:masterfrom
monkeynova:master

Conversation

@monkeynova
Copy link
Copy Markdown

basic bazel workspace and buildfile -- to accomplish this tests now add an include path of "../src"

@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage remained the same at 86.926% when pulling 1dad394 on monkeynova:master into 0bbaeea on google:master.

@AppVeyorBot
Copy link
Copy Markdown

Build benchmark 886 completed (commit 3eceac86fe by @monkeynova)

strip_include_prefix = "src",
deps = [
],
defines = ["HAVE_POSIX_REGEX"],
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.

note, this won't work for everyone. this is one of the reasons i held off; no way to do this kind of dynamic configuration.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's not perfect agreed, but it's also not unprecedented. gflags has a similar hardcoding (https://github.com/gflags/gflags/blob/master/bazel/gflags.bzl). I started a patch for moving some of the defines there to run off of a config but haven't gotten to a PR for that yet (googletest does something similar for linkopts: https://github.com/google/googletest/blob/master/BUILD.bazel).

But I know I don't have complete access to all the build modes I might need. Is there an automated build tool I can use to ensure coverage?

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.

the travis and appveyor builds are probably the closest we have for covering the various platforms/compilers. there are other platforms that people run on, but we don't have a way to cover every combination.

find_package(Threads REQUIRED)
include(CheckCXXCompilerFlag)

include_directories("../src")
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.

this should not be necessary. We don't want the tests to have blanket access to the private parts of src.

for the same reason, you should be using visibility = ["//visibility:private"] on most of the cc_library targets above.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

A fair number of the tests #include "../src/" so the encapsulation is actually pretty bad. Since this was tests as part of the package I wasn't particularly concerned with the model here, but it's a reasonable concern.

As far as the visibility:private, isn't that the default in the build file? When I was trying to make use of this from an external dependency, I had to add the explicit visibility:public to the one rule I wanted to make visible.

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.

ah, you're right. i wasn't sure how they'd set the default.

they include some things from ../src, but don't have full access. i don't know enough about bazel, but would it be better to add a BUILD in src, a BUILD in test, and manage the visibility of certain src/ libraries to test/ that way?

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Dec 7, 2017

(i just pushed 7f2d2cd which should help the travis xcode builds)

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Dec 13, 2017

Can you also add a travis entry to test the config? Example here: https://github.com/korfuri/bazel-travis/blob/master/.travis.yml

@dmah42
Copy link
Copy Markdown
Member

dmah42 commented Mar 8, 2018

Made obsolete by #533

@dmah42 dmah42 closed this Mar 8, 2018
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.

5 participants