Skip to content

Also build when included in source.#1212

Merged
gennadiycivil merged 5 commits intogoogle:masterfrom
qzmfranklin:bazel
Dec 19, 2017
Merged

Also build when included in source.#1212
gennadiycivil merged 5 commits intogoogle:masterfrom
qzmfranklin:bazel

Conversation

@qzmfranklin
Copy link
Copy Markdown
Contributor

This PR enables googletest to be correctly built when it is included in other Bazel projects in source, e.g., third_party/googletest.

@gennadiycivil
Copy link
Copy Markdown
Contributor

Thank you for your contribution.
Please provide a test run before/after that tests the problem this PR is fixing and shows positive outcome

@qzmfranklin
Copy link
Copy Markdown
Contributor Author

Hi @gennadiycivil ,

Sorry for the late reply. Somehow I did not have the notifications setup. But now they are done correctly.

Well, speaking of tests, there is really not a way for me to supply a test to be checked into this repo. It can only really be tested when this entire repository is included in source into some other repositories.

That said, I do have some projects that validates this PR.

As a reference, the master branch of https://github.com/qzmfranklin/torrent, after a git submodule update --init --recursive, includes my fork of googletest that had exactly the patch of this PR. The googletest repo is a submodule under third_party/gtest in that repo. You can build googletest, i.e., the gtest_main target like this:

bazel build third_party/gtest:gtest_main

Hope that helps clarify the testing situation. Also, if there is anything I can do to actually check in the test that would be awesome. It could be that I just do not know how to.

Thanks!

@gennadiycivil
Copy link
Copy Markdown
Contributor

@qzmfranklin Could you please provide output what happens if we dont make this change. Following the example you provided, the master branch of https://github.com/qzmfranklin/torrent, after a git submodule update --init --recursive, includes my fork of googletest that had exactly the patch of this PR.

The googletest repo is a submodule under third_party/gtest in that repo. You can build googletest, i.e., the gtest_main target like this:
bazel build third_party/gtest:gtest_main

What happens if we dont make the change and you issue
bazel build third_party/gtest:gtest_main
?

Thanks

@qzmfranklin
Copy link
Copy Markdown
Contributor Author

Hi @gennadiycivil ,

Thanks for your great patience and the willingness to help!
My bad, I should have provided that information in a clearer format in the first place.

So, If I revert this change, and issue bazel build third_party/gtest:gtest_main from the torrent repo I mentioned (and you have pulled), I will get the following errors:

20:14 $ bazel build third_party/gtest:gtest_main 
.........
ERROR: /home/zhongming/git/torrent/third_party/gtest/BUILD.bazel:86:1: no such package '': BUILD file not found on package path and referenced by '//third_party/gtest:gtest_main'
ERROR: Analysis of target '//third_party/gtest:gtest_main' failed; build aborted: no such package '': BUILD file not found on package path
INFO: Elapsed time: 2.651s
FAILED: Build did NOT complete successfully (10 packages loaded)

This error message is, after some debugging work locally on my machines, that the //:gtest is actually referring to a BUILD file defined at the root directory of the torrent repo. But there is no BUILD file under that directory. The gtest repo is included in source format as a subdirectory under third_party/gtest.

This PR solves the above problem by changing //:gtest to :gtest. This makes the dependency on :gtest relative to the containing directory of the gtest's BUILD file. Thus making the gtest's BUILD file always work regardless of where the top-level directory is.

Hope that helps and thanks really a lot for your time!

qzmfranklin added a commit to qzmfranklin/benchmark that referenced this pull request Dec 19, 2017
By using a different fork, for now, with the understanding that we should switch
to the google official googletest repo as soon as the issue below is resolved:

        google/googletest#1212
@gennadiycivil gennadiycivil merged commit 782384d into google:master Dec 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants