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

embedsrcs ignores directories with BUILD files #1133

Closed
uhthomas opened this issue Nov 15, 2021 · 3 comments
Closed

embedsrcs ignores directories with BUILD files #1133

uhthomas opened this issue Nov 15, 2021 · 3 comments

Comments

@uhthomas
Copy link
Contributor

What version of gazelle are you using?

v0.24.0

What version of rules_go are you using?

v0.29.0

What version of Bazel are you using?

4.2.1

Does this issue reproduce with the latest releases of all the above?

Yes.

What operating system and processor architecture are you using?

Tested on MacOS and Linux.

What did you do?

Assuming the directory structure

cmd/something
├── BUILD.bazel
├── data
│   ├── BUILD.bazel
│   ├── something.txt
│   ├── some_other_thing
│   │   ├── some_other_thing.txt
└── main.go

and with main.go

package main

import "embed"

//go:embed data
var content = embed.FS

func main() {}

Gazelle won't generate an embedsrcs for the "data" directory.

❯ bazel run //:gazelle
gazelle: cmd/something/main.go:5:2: pattern data: matched no files

What did you expect to see?

embedsrcs should be generated.

What did you see instead?

Gazelle doesn't generate embedsrcs for directories with BUILD files.

@andyliuliming
Copy link

we need this too.

@achew22
Copy link
Member

achew22 commented Dec 9, 2021

I don't think this can actually be done automatically. By making the directory that you want to include have a BUILD file, bazel wouldn't be able to reach into the directory using something like glob. It would require synchronizing a filegroup or something in the inner directory which is not going to be something that's completely standardized between projects (some will want direct file enumeration vs exports_files vs filegroup vs custom type'd target, etc.). If you have a need for this, move the targets that you defined in data up a level into the cmd/something/BUILD file and then refer to the files in the inner directory as data/something.txt.

If you feel really strongly about this and would like to pick one of those implementations and contribute it as a patch, let's open another issue and discuss the way it would be done.

@achew22 achew22 closed this as completed Dec 9, 2021
@uhthomas
Copy link
Contributor Author

uhthomas commented Mar 8, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants