bazel-contrib / bazel-contrib/rules_foreign_cc

Generate granular Bazel targets using module extension

Open
#1,178 2 comments 0 reactions 0 assignees View on GitHub
help wanted
Dominant language
Starlark
Stars
737
Forks
270
PR merge metrics
No merged PRs in 30d

Description

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](https://bazel.build/rules/lib/builtins/repository_ctx#download_and_extract) and [run CMake](https://bazel.build/rules/lib/builtins/repository_ctx#execute).

CMake would need an [additional Bazel generator](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html) (in addition to Make/Ninja).

Contributor guide

Open the contributing guide

Research direction

Start with the proposed MODULE.bazel and BUILD usage, then review the referenced extension.bzl interface and Bazel repository_ctx download_and_extract and execute APIs. Investigate the CMake generator requirements described in the issue. Done means the proposed module extension can generate granular targets and use Bazel toolchains for the actual build instead of make or ninja.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake
Domain
build-system
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.