-
Notifications
You must be signed in to change notification settings - Fork 442
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
Build fail when depending on a library in a different repo that mixes generated and non-generated sources #1780
Comments
A similar issue was mentioned in #1530 (comment) |
I believe the two are unrelated issues and this issue is a bug specifically with the way we deal with generated source files.
Would you mind sharing the values of |
Added |
…#2138) Fixes #1780 In Bazel 3.7.0, the path returned by `build_file_path` changed (bazelbuild/bazel#12344), it no longer contains the `external/<repo>` prefix for external files. This breaks the expectations of this rule in the [`paths.relativize` function](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/paths_doc.md#pathsrelativize) call. In this PR I prepend the `workspace_root` (`external/<repo>`) to `build_file_path` (`<path/in/the/repo>`), and use `path` (`external/<repo>/path/in/the/repo`) instead of `short_path` (`../<repo>/path/in/the/repo`). For files that are generated in different configurations I need to strip the `root` which contains the `bazel-out/darwin-fastbuild-ST-a1a0f4088294/bin/` that will never appear in the `package_root` path. ~Note.- I will probably need some help to add tests for this change~ I've tried to add one test --------- Co-authored-by: UebelAndre <github@uebelandre.com>
…bazelbuild#2138) Fixes bazelbuild#1780 In Bazel 3.7.0, the path returned by `build_file_path` changed (bazelbuild/bazel#12344), it no longer contains the `external/<repo>` prefix for external files. This breaks the expectations of this rule in the [`paths.relativize` function](https://github.com/bazelbuild/bazel-skylib/blob/main/docs/paths_doc.md#pathsrelativize) call. In this PR I prepend the `workspace_root` (`external/<repo>`) to `build_file_path` (`<path/in/the/repo>`), and use `path` (`external/<repo>/path/in/the/repo`) instead of `short_path` (`../<repo>/path/in/the/repo`). For files that are generated in different configurations I need to strip the `root` which contains the `bazel-out/darwin-fastbuild-ST-a1a0f4088294/bin/` that will never appear in the `package_root` path. ~Note.- I will probably need some help to add tests for this change~ I've tried to add one test --------- Co-authored-by: UebelAndre <github@uebelandre.com>
rules_rust v0.16.1, Bazel v5.1.1 & v6.0.0.
Scenario: a common library has bindings for a number of different languages, one of which is Rust.
rust/BUILD
in the library defines a rule to generate the bindings as well as therust_library
rule that includes some helpful wrapper functions.Another repository wants to use the bindings as a library dependency. We import the
git_repository
aslib
and attempt to use@lib//rust:lib-with-gen
as a dependency.However, the build fails:
The build does not fail if both targets are in the same repository, nor does it fail if the library is at the root of its repo (i.e.
@lib//:lib-with-gen
). The build also does not fail if all sources are generated, or if none of them are.MRE:
lib: https://github.com/dmitrii-ubskii/rules-rust-mre-external
bin: https://github.com/dmitrii-ubskii/rules-rust-mre-main
The text was updated successfully, but these errors were encountered: