bazel-contrib / bazel-contrib/rules_foreign_cc
build_args don't seem to work for cmake
- Dominant language
- Starlark
- Stars
- 737
- Forks
- 270
- PR merge metrics
- No merged PRs in 30d
Description
When creating a cmake target the build_args don't seem to be getting passed to the `cmake build` command. For example:
### WORKSPACE
```python
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
load("@rules_foreign_cc//foreign_cc:repositories.bzl", "rules_foreign_cc_dependencies")
# This sets up some common toolchains for building targets. For more details, please see
# https://github.com/bazelbuild/rules_foreign_cc/tree/main/docs#rules_foreign_cc_dependencies
rules_foreign_cc_dependencies()
_ALL_CONTENT = """\
filegroup(
name = "all_srcs",
srcs = glob(["**"]),
visibility = ["//visibility:public"],
)
"""
http_archive(
name = "com_mongodb_wiredtiger",
urls = ["https://github.com/wiredtiger/wiredtiger/archive/refs/tags/11.0.0.tar.gz"],
strip_prefix = "wiredtiger-11.0.0",
sha256 = "1dad4afb604fa0dbebfa8024739226d6faec1ffd9f36b1ea00de86a7ac832168",
build_file_content = _ALL_CONTENT,
)
```
### BUILD
```python
load("@rules_foreign_cc//foreign_cc:defs.bzl", "cmake")
cmake(
name = "wiredtiger",
lib_source = "@com_mongodb_wiredtiger//:all_srcs",
lib_name = "libwiredtiger",
generate_args = ["-DENABLE_STATIC=1"],
build_args = ["-j10"],
)
```
This seems to build a lot slower than running `cmake build -j10` or `cmake build --parallel 10` manually myself for the library. Is there any way to have rules_foreign_cc show the output of the command used to invoke cmake? I'd love to be able to have some parallelism in my foreign_cc builds.
Also this is a pretty hacky way to get the parallelism -- it would be great if rules_foreign_cc could detect my number of processors and do this automatically to speed up builds.
Contributor guide
Research direction
Start with the `cmake` rule in `@rules_foreign_cc//foreign_cc:defs.bzl` and reproduce the `wiredtiger` example using `generate_args` and `build_args = ["-j10"]`. Check how the command is invoked and whether its output is exposed; done means build arguments reach the CMake build step and parallelism is either honored or its supported configuration is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cmake
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100