bazel-contrib / bazel-contrib/rules_foreign_cc

Meson hardcodes `compile` for all build arguments

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

Description

Meson hard-codes the `compile` argument in `_create_meson_script`, which isn't flexible for some Meson use-cases.

https://github.com/bazelbuild/rules_foreign_cc/blob/816905a078773405803e86635def78b61d2f782d/foreign_cc/meson.bzl#L95-L99

[`VMAF`, for example, uses Meson to setup the build directory and Ninja to compile. ](https://github.com/Netflix/vmaf/blob/master/libvmaf/README.md#compile)

```
meson build --buildtype release
ninja -vC build
```

My attempt to replicate the first step of their build instructions looks like:

```
meson (
name = "vmaf_meson",
build_args = [
"build", "--buildtype", "release",
],
install = False,
lib_source = "@vmaf//:libvmaf_src",
build_data = ["@vmaf//:all_src"],
visibility = ["//visibility:public"],
)
```

With the hard coded `compile` argument in the generated instruction, the build script errors.

```
$EXT_BUILD_ROOT/.../meson_tool --prefix=$INSTALLDIR $EXT_BUILD_ROOT/external/vmaf/libvmaf
$EXT_BUILD_ROOT/.../meson_tool compile build --buildtype release
```

Output:
```
usage: meson [-h]
{setup,configure,dist,install,introspect,init,test,wrap,subprojects,rewrite,compile,devenv,env2mfile,help}
...
meson: error: unrecognized arguments: --buildtype release
```

Would we be open to a PR removing `compile` and relying on users to choose their argument as `build_args`?

Contributor guide

Open the contributing guide

Research direction

Read foreign_cc/meson.bzl at lines 95-99 and inspect _create_meson_script; reproduce the VMAF-style invocation to see how build_args form the generated command. Done means the Meson setup arguments are accepted without an incompatible hard-coded compile subcommand, while the existing Meson rule remains usable.

Written by the indexing model from the issue text.

Assessment

Domain
build-system
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.