Skip to content
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

Generate granular Bazel targets using module extension #1178

Open
mering opened this issue Mar 2, 2024 · 2 comments
Open

Generate granular Bazel targets using module extension #1178

mering opened this issue Mar 2, 2024 · 2 comments
Labels
help wanted Extra attention is needed

Comments

@mering
Copy link

mering commented Mar 2, 2024

It would be great if Bazel toolchains could be used to run the actual build instead of building via make/ninja.

It could work the following way:

# CMakeLists.txt
add_library(example_lib example.cc)

# MODULE.bazel
foreign = load("@rules_foreign_cc//extension.bzl")
foreign.cmake(
    url = "https://example.com/lib.tgz",
)
use(foreign, "com_example_lib")

# BUILD
cc_library(
    deps = ["@com_example_lib//example_library"]
)

The extension would create and execute a repository rule to download the project and run CMake.

CMake would need an additional Bazel generator (in addition to Make/Ninja).

@mering mering changed the title More granular Bazel targets using module extension Generate granular Bazel targets using module extension Mar 2, 2024
@jsharpe
Copy link
Member

jsharpe commented Mar 2, 2024

I'm not sure how feasible a Bazel generator in CMake actually is; as far as I know CMake doesn't have strict dependencies and so can't tell you for a given file what all the inputs should be and so I'm not sure you can reliably generate bazel files from a CMake project.

Even if it is feasible, who would be the maintainer / owner of this code? It would have to live in the CMake codebase. I believe Conan used to have a bazel generator but I think its become unmaintained / removed from the latest version of Conan which suggests that there is a lack of appetite from the CMake side to maintain something like this.

@jsharpe jsharpe added the help wanted Extra attention is needed label Mar 2, 2024
@mering
Copy link
Author

mering commented Mar 2, 2024

CMake does have strict dependencies (at least for source files) on a library target level. I would suggest to use the same granularity in the generated output.

The CMake Bazel generator would also be suitable standalone. Of course all code has to be maintained by someone but this is independent from the repository it lives in.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants