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

A way to get an execpath to a directory rather than a file #23139

Open
illicitonion opened this issue Jul 29, 2024 · 1 comment
Open

A way to get an execpath to a directory rather than a file #23139

illicitonion opened this issue Jul 29, 2024 · 1 comment
Labels
team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request untriaged

Comments

@illicitonion
Copy link
Contributor

illicitonion commented Jul 29, 2024

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

@github-actions github-actions bot added the team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts label Jul 29, 2024
@fmeum
Copy link
Collaborator

fmeum commented Jul 29, 2024

A scheme that I think would be very easy to fit into the current model (exact syntax TBD):

$(execpath-1 @openssl//include:openssl/some_header.h) --> external/openssl/include/openssl
$(execpath-2 @openssl//include:openssl/some_header.h) --> external/openssl/include
$(execpath-0 @openssl//include:openssl/some_header.h) --> external/openssl/include/openssl/some_header.h
$(execpath-3 @openssl//include:openssl/some_header.h) --> external/openssl
$(execpath-4 @openssl//include:openssl/some_header.h) --> <fails>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

5 participants