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

Support a way to ignore (potentially user-specific) IDE files in glob expressions #23975

Open
jacky8hyf opened this issue Oct 15, 2024 · 0 comments
Labels
team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: feature request untriaged

Comments

@jacky8hyf
Copy link

jacky8hyf commented Oct 15, 2024

Description of the feature request:

Allow to specify list of patterns ignored by ALL glob() expressions in the project.

Which category does this issue belong to?

Loading API

What underlying problem are you trying to solve with this feature?

Details of the feature request

Let's say I am releasing the code of my project with the following BUILD file:

filegroup(
    srcs = glob(
        ["**"], 
        exclude = [
            "BUILD.bazel",
            "**/*.bzl",
            ".git/**",
        ],
    )
)

However, when a user of our project uses an IDE, the IDE may generate files that are captured by the IDE. Different people use different IDEs, so it is hard for us to exclude all files potentially generated by IDEs. For example, this may include .swp files generated by Vim, or ctag files generated by code indexing tools.

Hence, I am proposing to add a feature that allows a user to specify a list of files generated by their IDE as a local configuration. This may be a command line option that a user place in their $HOME/.bazelrc below , or some $HOME/.bazelglobignore for example. (The path here is just for illustration purposes. Please change it to wherever makes sense.)

As a project owner, it may also be useful for me to add a <workspace_root>/.bazelglobignore file that excludes files generated by commonly known IDEs, or add it to <workspace_root>/.bazelrc. (The path here is just for illustration purposes. Please change it to wherever makes sense.)

Alternatives

Why not just add it to glob(exclude = [])?

  • It is not future proof. If someone add a glob() somewhere else in the project in the future, and forgets to add the common exclude list, we have a regression.
  • It is not user-specific. If a user uses an exotic IDE not known by us, they have to submit a patch to us to get their IDEs fixed. With this feature, the user just needs to add their IDE-generated files to their $HOME/.bazelglobignore.

Why not use an allow list instead of a deny list?

One may argue that the glob(["**"]) is the source of evil. Indeed, the issue is resolved if a more precise list of patterns are provided, so that IDE-generated files are never globbed.

However, it is hard for us to switch to an allowlist for our project (Build Android kernel with Bazel), because the list of all files from upstream Linux kernel changes as the source code evolves.

Which operating system are you running Bazel on?

Linux

What is the output of bazel info release?

release 7.3.0

If bazel info release returns development version or (@non-git), tell us how you built Bazel.

No response

What's the output of git remote get-url origin; git rev-parse HEAD ?

No response

Have you found anything relevant by searching the web?

There is .bazelignore https://bazel.build/run/bazelrc#bazel-behavior-files that serves a similar purpose.

But it is for directories, not for individual files.

Any other information, logs, or outputs that you want to share?

We added ctag files as a temporary workaround: http://r.android.com/2911882. This issue comes up again when an internal developer using Vim gets intermittent build breakages/success builds due to .swp files generated by Vim.

@github-actions github-actions bot added the team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob label Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
team-Loading-API BUILD file and macro processing: labels, package(), visibility, glob type: feature request untriaged
Projects
None yet
Development

No branches or pull requests

4 participants