A way to get an execpath to a directory rather than a file
Author: illicitonionCreated Jul 29, 2024Updated Sep 18, 2026
Labelstype: feature requestP3staleteam-Rules-API
Description of the feature request:
Several times, I've wanted to be able to reference an execpath to a directory, for the purposes of adding a directory containing several files to an include search path. Something along the lines of:
cc_library(
name = "lib",
srcs = [...],
copts = ["-I$(execpath @openssl//include:__pkg__)"],
)If you're lucky, some tools support /.. so you can write something like:
cc_library(
name = "lib",
srcs = [...],
copts = ["-I$(execpath @openssl//include:openssl/some_header.h)/../.."],
)but many do not.
Note that we want to be able to be very precise about which directory is returned. In a world where you have:
@openssl//include:BUILD.bazel:
filegroup(
name = "headers",
srcs = [
"openssl/header1.h",
"openssl/header2.h",
],
)it may be important to specifically reference the execpath of @openssl//include not openssl//include/headers because of how the headers are #included.
Which category does this issue belong to?
Rules API
Have you found anything relevant by searching the web?
See discussion in https://bazelbuild.slack.com/archives/C014RARENH0/p1722250875317499?thread_ts=1721325151.660949&cid=C014RARENH0
Source: bazelbuild/bazel