-
-
Notifications
You must be signed in to change notification settings - Fork 107
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
Possibly support bazel build? #79
Comments
If I understand correctly |
Namaste! Bazel can leverage cmake and autotools as well. The fastest builds are when the library supports Bazel directly, however, because then it knows the entire build DAG. The most barebones build that wouldn't require much maintainance would be something like: load("@rules_cc//cc:defs.bzl", "cc_library")
licenses(["notice"]) # BSD
exports_files(["LICENSE.md"])
cc_library(
name = "replxx",
srcs = glob([
"src/**/*.cpp",
"src/**/*.cxx",
]),
hdrs = glob([
"include/**/*.h",
"include/**/*.hxx",
"src/**/*.h",
"src/**/*.hxx",
]),
includes = [
"include",
],
linkstatic = True,
visibility = ["//visibility:public"],
) C++ would do great with clean and easy dependency management. Bazel just makes it easy to pull remote libraries into the workspace dynamically and have repeatable, fast and hermetic builds. Here's an example of how I'm using it currently: cc_binary(
name = "foo",
srcs = [
"foo.cc",
],
visibility = ["//visibility:public"],
deps = [
":repl_lib",
"@com_google_absl//absl/container:flat_hash_map",
"@com_google_absl//absl/flags:flag",
"@com_google_absl//absl/flags:parse",
"@fmt",
"@replxx", # <-- This is all I need to do to include, link, and compile replxx.
],
) As a user of a C++ library, I no longer have to deal with conflicts with different installations (system or otherwise) of the library. When I run `bazel build :foo" Bazel fetches a very specific commit from github, so I get a reproducible build. For future builds it caches the download. Referring to and rolling back references to remote C++ libraries becomes easy. However, I'll leave it up to you. Anybody who needs to refer to a specific commit in their workspace for a hermetic build can certainly come back to this thread and use the build files shown here by using them as remote build files. :) |
The barebones version looks much more appealing to me. Thank you. |
Any update on this? |
Hi, sorry for the delay on this. I'll send a PR in a few. |
Hi!
Thank you for this amazing library.
Bazel makes it easy to integrate the library by simply specifying the target dependency as
"@replxx"
. The users of the library don't need to know how to build the library as a result. Do you think the library could support building with Bazel directly so people wouldn't have to maintain their ownBUILD.bazel
files? Here's example usage:I include it in my workspace using:
BUILD.bazel
file:To build and run the example, I just type
bazel run "@replx//:example_cc"
:Bazel fetches the correct version and enables reproducible builds. The only changes the user needs are the 1st and the 2nd code snippets. That allows the user to have hermetic, reproducible, and fast builds.
What do you think?
The text was updated successfully, but these errors were encountered: