Skip to content

Get the name of current repository from macro #10923

@or-shachar

Description

@or-shachar

Description of the problem / feature request:

I am trying to get the name of the current repository from a macro.

.
├── a
│   ├── BUILD.bazel
│   ├── WORKSPACE
│   ├── empty.txt
│   └── txt_files.bzl
└── b
    ├── BUILD.bazel
    ├── WORKSPACE
    └── empty2.txt

(see full example here )

I want that if repo b will call the macro in @a//:txt_files.bzl then somehow I'd be able to retrieve that it was called from repo b.

Right now (not sure if it's a bug or work as intended) - calling native.repository_name() will return @ and not the name of repo as declared in its WORKSPACE file.

Feature requests: what underlying problem are you trying to solve with this feature?

I want to change the behavior of a macro based on the callee repository.

Can we allow native.repository_name() to return the explicit name of the repository and not @? To maintain backward compatibility - I assume it would be better if we add a flag to this method that will be turned off by default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3We're not considering working on this, but happy to review a PR. (No assignee)team-ExternalDepsExternal dependency handling, remote repositiories, WORKSPACE file.type: feature request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions