Skip to content
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

Allow runnable_binary to work on non-external targets #1100

Merged
merged 1 commit into from Oct 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -22,6 +22,9 @@ The following flags are required in Bazel 4.x but not Bazel 5.x or newer:
Note that the rules may be compatible with older versions of Bazel but support may break
in future changes as these older versions are not tested.

Note also that the `runnable_binary` macro requires bazel 5.4.0, for the `rlocationpath` [path
variable](https://bazel.build/reference/be/make-variables)

## News

For more generalized updates, please see [NEWS.md](./NEWS.md) or checkout the
Expand Down
4 changes: 2 additions & 2 deletions foreign_cc/utils.bzl
Expand Up @@ -9,7 +9,7 @@ def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False,

The wrapper script also facilitates the running of binaries that are dynamically linked to shared libraries also built by rules_foreign_cc. The runnable bin could be used as a tool in a dependent bazel target

Note that this macro only works on foreign_cc_targets in external repositories, not in the main repository. This is due to the issue described here: https://github.com/bazelbuild/bazel/issues/10923
Note that this macro requires bazel 5.4.0 due to the use of the rlocationpath variable (see https://github.com/bazelbuild/bazel/issues/10923 for context)
Also note that the macro requires the `--enable_runfiles` option to be set on Windows.

Args:
Expand Down Expand Up @@ -43,7 +43,7 @@ def runnable_binary(name, binary, foreign_cc_target, match_binary_name = False,
)

wrapper_cmd = """
sed s@EXECUTABLE@$(rootpath {name})@g $(location @rules_foreign_cc//foreign_cc/private:runnable_binary_wrapper.sh) > tmp
sed s@EXECUTABLE@$(rlocationpath {name})@g $(location @rules_foreign_cc//foreign_cc/private:runnable_binary_wrapper.sh) > tmp
sed s@SH_BINARY_FILENAME@{sh_binary_filename}@g tmp > $@
"""

Expand Down