bazelbuild / bazelbuild/rules_rust

`rust_bindgen` doesn't work with external repository

Open
#1,980 1 comment 0 reactions 0 assignees View on GitHub
bindgen bug needs-triage
Dominant language
Starlark
Stars
843
Forks
651
Avg merge
2d 18h
Merged PRs (30d)
15

Description

Let's say I use the following directory structure

```sh
myproject
├── BUILD.bazel
├── WORKSPACE
...
├── libs
└── foo
├── BUILD.bazel
└── src
└── libs.rs
```

And that the `myproject/libs/foo/BUILD.bazel`:

```bazel
rust_bindgen_library(
name = "external_lib_binding",
cc_lib = "@external_lib:lib",
header = "lib_api.h",
)
```

Then I get the following error, even though `lib_api.h` is a transitive header.

```sh
Error in fail: Header is not in 's transitive headers. header
```

This happens because `header` variable takes relative path of the current project `libs/foo/external_lib.h` which doesn't exist in `external_lib`. Hence [the comparison](https://github.com/bazelbuild/rules_rust/blob/main/bindgen/bindgen.bzl#L94) fails.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.