-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bazel Build #61
Comments
I spent a bit of time on this for one of my projects. The attached BUILD file might give you a starting point - it works well enough for my needs but your mileage may vary... |
Agreed. It'd be really useful. |
Why not add a blaze build options to build this library? I still don't understand the point. |
Thank you @dfr for providing such a nice BUILD file, which saves me a lot of time! It does not work out of box for me, but with some modification it works pretty well. Here is what I have:
With the above setting I was able to use the dependency However, I was not able to compile git_repository(
name = "com_github_gflags_gflags",
remote = "https://github.com/gflags/gflags.git",
tag = "v2.2.0",
)
bind(
name = "gflags",
actual = "@com_github_gflags_gflags//:gflags",
) Adding dependencies of |
According to bazelbuild/bazel#818
Instead to make it work. |
Re: failing to include There are two places where Does anyone have any idea? |
I have an external dependancy to gflags in my WORKSPACE:
git_repository(
name = "gflags_repo",
remote = "https://github.com/gflags/gflags.git",
commit = "fe57e5af4db74ab298523f06d2c43aa895ba9f98"
)
bind(
name = "gflags",
actual = "@gflags_repo//:gflags"
)
which is referenced in the deps in BUILD.glog:
cc_library(
visibility = ["//visibility:public"],
name = "glog",
deps = [
#"//third_party/libunwind:libunwind-k8",
"//external:gflags",
],
...
)
…On 13 February 2017 at 13:44, ushakov ***@***.***> wrote:
Re: failing to include gflags/gflags.h: glog includes that using #include
<gflags/gflags.h> directive, so it tries to include from system
directories. (On my system, that resulted in a havoc after it included an
older version from system-wide directories.) I tried to add -isystem
flags here and there, and also preprocess the file in question to change
<...> to "..." but did not fully succeed.
There are two places where gflags/gflags.h is included: in logging.h and
in base/commandlineflags.h. The former is present in the archive as
logging.h.in, gets preprocessed through the gen.sh script, and looks
fine. The latter however is trickier: if you process it through gen.sh, it
will still be included from its original location, not from the genfiles
directory.
Does anyone have any idea?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#61 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AALppR_aoBvaZsLFAV16PA82MGIzIRkFks5rcF5JgaJpZM4GCkld>
.
|
You also need "-DHAVE_LIB_GFLAGS" in the copts for glog.
…On 13 February 2017 at 14:11, Doug Rabson ***@***.***> wrote:
I have an external dependancy to gflags in my WORKSPACE:
git_repository(
name = "gflags_repo",
remote = "https://github.com/gflags/gflags.git",
commit = "fe57e5af4db74ab298523f06d2c43aa895ba9f98"
)
bind(
name = "gflags",
actual = ***@***.***_repo//:gflags"
)
which is referenced in the deps in BUILD.glog:
cc_library(
visibility = ["//visibility:public"],
name = "glog",
deps = [
#"//third_party/libunwind:libunwind-k8",
"//external:gflags",
],
...
)
On 13 February 2017 at 13:44, ushakov ***@***.***> wrote:
> Re: failing to include gflags/gflags.h: glog includes that using #include
> <gflags/gflags.h> directive, so it tries to include from system
> directories. (On my system, that resulted in a havoc after it included an
> older version from system-wide directories.) I tried to add -isystem
> flags here and there, and also preprocess the file in question to change
> <...> to "..." but did not fully succeed.
>
> There are two places where gflags/gflags.h is included: in logging.h and
> in base/commandlineflags.h. The former is present in the archive as
> logging.h.in, gets preprocessed through the gen.sh script, and looks
> fine. The latter however is trickier: if you process it through gen.sh, it
> will still be included from its original location, not from the genfiles
> directory.
>
> Does anyone have any idea?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <#61 (comment)>, or mute
> the thread
> <https://github.com/notifications/unsubscribe-auth/AALppR_aoBvaZsLFAV16PA82MGIzIRkFks5rcF5JgaJpZM4GCkld>
> .
>
|
I also have that. Moreover, if I go into the checked-out glog directory and change angle brackets in |
I think the difference between us is that I don't have gflags installed on
my system to it only exists in my build.
…On 13 February 2017 at 14:27, ushakov ***@***.***> wrote:
I also have that. Moreover, if I go into the checked-out glog directory
and change angle brackets in base/commandlineflags.h to quotes, it starts
compiling happily. Of course, if my system has compatible gflags installed,
it also compiles well :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#61 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AALppcwgSSZCjEyYfApHmdKSFBBL1W3aks5rcGhOgaJpZM4GCkld>
.
|
I tried it both ways actually... I probably need to investigate more. |
FYI: I found this workaround: https://github.com/twitter/heron/tree/master/third_party/glog |
Oh, this looks interesting -- but this is basically vendoring glog inside your own repo, and I think vendoring as code is better than vendoring as tar.gz :) |
Just add to copts the following line: |
Thanks, using @antonovvk solution make it work perfect! |
By adjusting @antonovvk's WORKSPACE to use gflags v2.2.1, I was able to avoid the |
Bazel can't fetch any external packages? |
Yep, this was fixed by @qzmfranklin - thanks! |
When I use it in the bazel project, I got a lot of notes and warnings:
|
Bazel builds are supported directly in glog - you can just add something
like this to your WORKSPACE:
http_archive(
name = "com_github_google_glog",
sha256 =
"6fc352c434018b11ad312cd3b56be3597b4c6b88480f7bd4e18b3a3b2cf961aa",
strip_prefix = "glog-3ba8976592274bc1f907c402ce22558011d6fc5e",
urls = [
"
https://mirror.bazel.build/github.com/google/glog/archive/3ba8976592274bc1f907c402ce22558011d6fc5e.tar.gz
",
"
https://github.com/google/glog/archive/3ba8976592274bc1f907c402ce22558011d6fc5e.tar.gz
",
],
)
Then reference it in deps with "//@com_github_google_glog//:glog"
…On Thu, 10 Dec 2020 at 01:52, zoukyle ***@***.***> wrote:
When I use it in the bazel project, I got a lot of notes and warnings:
How can I avoid them? Thanks
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h: In instantiation of 'std::__cxx11::string* google::Check_LTImpl(const T1&, const T2&, const char*) [with T1 = int; T2 = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]':
external/deepmap_base/common/geometry/g2_quadtree_key.h:257:5: required from here
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h:734:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
DEFINE_CHECK_OP_IMPL(Check_LT, < )
^
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h:734:1: note: in expansion of macro 'DEFINE_CHECK_OP_IMPL'
DEFINE_CHECK_OP_IMPL(Check_LT, < )
^~~~~~~~~~~~~~~~~~~~
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h: In instantiation of 'std::__cxx11::string* google::Check_EQImpl(const T1&, const T2&, const char*) [with T1 = int; T2 = long unsigned int; std::__cxx11::string = std::__cxx11::basic_string<char>]':
external/deepmap_base/common/geometry/plane_3d.h:34:5: required from here
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h:731:32: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(NULL, x)?
^
bazel-out/k8-fastbuild/bin/external/com_github_google_glog/_virtual_includes/default_glog_headers/glog/logging.h:731:1: note: in expansion of macro 'DEFINE_CHECK_OP_IMPL'
DEFINE_CHECK_OP_IMPL(Check_EQ, ==) // Compilation error with CHECK_EQ(NULL, x)?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#61 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABOTJKBPTIKLGQPRSIZKW3SUASXHANCNFSM4BQKJFOQ>
.
|
@dfr Thanks a lot for your reply. I'm actually using the same way as you mentioned in your thread. During the build, the glog will be compiled and it gave me a lot of warnings. I want to hide those warnings. |
You probably need to add -Wno-sign-compare flag to copts. Take a look at
bazel/glog.bzl in the glog tree.
…On Wed, 16 Dec 2020 at 03:40, zoukyle ***@***.***> wrote:
@dfr <https://github.com/dfr> Thanks a lot for your reply. I'm actually
using the same way as you mentioned in your thread. During the build, the
glog will be compiled and it gave me a lot of warnings. I want to hide
those warnings.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#61 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AABOTJIXAYANMIS6RKJ7ZWTSVAT3DANCNFSM4BQKJFOQ>
.
|
It would be really nice if you could add support for building with Bazel.
The text was updated successfully, but these errors were encountered: