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

build_tags does not generate conditional build files #1262

Open
vrongmeal opened this issue May 31, 2022 · 0 comments · May be fixed by #1938
Open

build_tags does not generate conditional build files #1262

vrongmeal opened this issue May 31, 2022 · 0 comments · May be fixed by #1938

Comments

@vrongmeal
Copy link

vrongmeal commented May 31, 2022

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?

5.1.1

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

Yes

What operating system and processor architecture are you using?

macOS 12.3.1
Apple M1 Pro

What did you do?

I have a project where a few things are compiled conditionally (based on the tag). There are different files for when the tag is there and not, eg:

file.go        # Compiled when +build !mytag
file_mytag.go  # Compiled when +build mytag

Gazelle generates the BUILD files at the time of running:

bazel run //:gazelle

It's required that I pass the -build_tags=mytag to generate the build file so I can later on compile with --define gotags=mytag. I there a way I can get build files with conditional where I don't have to generate a different build file for different tags.

What did you expect to see?

Something that conditionally builds based on the tag provided later on by --define gotags=... like here.

What did you see instead?

No conditionals in build files, instead just static files based on the tag specified while generating them.

patrickmscott pushed a commit to patrickmscott/bazel-gazelle that referenced this issue Sep 27, 2024
Gazelle already iterates over all supported os/arch combos to include go
files. This is similar but expanded to custom tags. When adding a new
build tag, we create a copy with the tag set to true and append to the
original. This means that build tag evaluation will grow exponentially.

Fixes bazel-contrib#1262
@patrickmscott patrickmscott linked a pull request Sep 27, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant