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

Avoid module on binary #164

Merged
merged 3 commits into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions tools/please_go/ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 1.4.4
-------------
* Don't set `_module` on go_binary commands in `go_repo`

Version 1.4.3
-------------
* Don't try and pipe test output as it doesn't flush when the TestMain calls os.Exit
Expand Down
2 changes: 1 addition & 1 deletion tools/please_go/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.4.3
1.4.4
5 changes: 3 additions & 2 deletions tools/please_go/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func (g *Generate) generate(dir string) error {
return err
}

lib := g.libRule(pkg, dir)
lib := g.ruleForPackage(pkg, dir)
if lib == nil {
return nil
}
Expand Down Expand Up @@ -336,7 +336,7 @@ func (g *Generate) depTargets(imports []string) []string {
return deps
}

func (g *Generate) libRule(pkg *build.Package, dir string) *Rule {
func (g *Generate) ruleForPackage(pkg *build.Package, dir string) *Rule {
if len(pkg.GoFiles) == 0 && len(pkg.CgoFiles) == 0 {
return nil
}
Expand All @@ -356,6 +356,7 @@ func (g *Generate) libRule(pkg *build.Package, dir string) *Rule {
hdrs: pkg.HFiles,
deps: g.depTargets(pkg.Imports),
embedPatterns: pkg.EmbedPatterns,
isCMD: pkg.IsCommand(),
}
}

Expand Down
6 changes: 4 additions & 2 deletions tools/please_go/generate/rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Rule struct {
deps []string
embedPatterns []string
// TODO(jpoole): handle external test
external bool
external, isCMD bool
}

func populateRule(r *build.Rule, targetState *Rule) {
Expand Down Expand Up @@ -55,5 +55,7 @@ func populateRule(r *build.Rule, targetState *Rule) {
},
})
}
r.SetAttr("_module", NewStringExpr(targetState.module))
if !targetState.isCMD {
r.SetAttr("_module", NewStringExpr(targetState.module))
}
}
Loading