From 91ca218cac82d54d7a16cf07cdacf102b3dced60 Mon Sep 17 00:00:00 2001 From: Fabian Meumertzheim Date: Wed, 10 Aug 2022 09:28:54 +0200 Subject: [PATCH] Add RunfilesLibraryInfo provider The new Starlark-defined RunfilesLibraryInfo provider may be used in the future to decide whether additional information has to be emitted by a rule for a target to find its runfiles at runtime. This may include serializing repository mapping information to a runfile and/or generating code that provides the canonical name of the current repository. The provider is added now rather than later so that third-party runfiles libraries can rely on it being present earlier - they have to wait for their minimum supported Bazel version to offer it. If it should turn out not to be needed, it can safely be removed before any ruleset would have a reason to depend on it. Work towards https://github.com/bazelbuild/proposals/pull/269 --- tools/BUILD | 1 + tools/runfiles/BUILD | 10 +++++++++- tools/runfiles/runfiles.bzl | 9 +++++++++ 3 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 tools/runfiles/runfiles.bzl diff --git a/tools/BUILD b/tools/BUILD index 0f69e23505fc27..f8af8a9e711ecb 100644 --- a/tools/BUILD +++ b/tools/BUILD @@ -87,6 +87,7 @@ filegroup( "//tools/jdk:bzl_srcs", "//tools/osx:bzl_srcs", "//tools/python:bzl_srcs", + "//tools/runfiles:bzl_srcs", "//tools/sh:bzl_srcs", "//tools/test:bzl_srcs", "//tools/windows:bzl_srcs", diff --git a/tools/runfiles/BUILD b/tools/runfiles/BUILD index 739336793ec972..2b3433ce78401c 100644 --- a/tools/runfiles/BUILD +++ b/tools/runfiles/BUILD @@ -11,6 +11,14 @@ filegroup( filegroup( name = "embedded_tools", - srcs = ["BUILD.tools"], + srcs = [ + "BUILD.tools", + "runfiles.bzl", + ], visibility = ["//tools:__pkg__"], ) + +filegroup( + name = "bzl_srcs", + srcs = ["runfiles.bzl"], +) diff --git a/tools/runfiles/runfiles.bzl b/tools/runfiles/runfiles.bzl new file mode 100644 index 00000000000000..2d0830cbd2be86 --- /dev/null +++ b/tools/runfiles/runfiles.bzl @@ -0,0 +1,9 @@ +RunfilesLibraryInfo = provider( + doc = """ +A marker for targets providing runfiles lookup functionality. + +Rules may choose to emit additional information required to locate runfiles at runtime if this provider is present on a direct dependency. + +Note: At this point, neither Bazel nor native rules check for the presence of this provider. +""", +) \ No newline at end of file