Skip to content
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
6 changes: 5 additions & 1 deletion build_defs/go.build_defs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,6 +1352,10 @@ def go_repo(module: str, version:str='', download:str=None, name:str=None, insta
pkg_name = package_name()
requirements = " ".join(requirements)

licence_args = ""
if licences:
licence_args = " ".join([f"--licence '{licence}'" for licence in licences])

build_tag_args = " ".join([f"--build_tag {build_tag}" for build_tag in build_tags])
label_args = " ".join([f"--label '{label}'" for label in labels])
large_package_args = " ".join([f"--large_package '{pkg}'" for pkg in large_packages])
Expand All @@ -1363,7 +1367,7 @@ def go_repo(module: str, version:str='', download:str=None, name:str=None, insta
"find $SRCS_DOWNLOAD -name BUILD -delete",
f"mkdir -p $(dirname {pkgRoot})",
f"mv $SRCS_DOWNLOAD {pkgRoot}",
f"$TOOL generate {modFileArg} --module {module} --version '{version}' {build_tag_args} {label_args} {large_package_args} --src_root={pkgRoot} --third_part_folder='{third_party_path}' --subrepo '{pkg_name}/{subrepo_name}' {install_args} {requirements}",
f"$TOOL generate {modFileArg} --module {module} --version '{version}' {build_tag_args} {label_args} {large_package_args} --src_root={pkgRoot} --third_part_folder='{third_party_path}' --subrepo '{pkg_name}/{subrepo_name}' {install_args} {requirements} {licence_args}",
f"mv {pkgRoot} $OUT",
]
cmd = " && ".join(cmds)
Expand Down
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.24.0
--------------
* Propagate licences down to the go_library, go_binary and cgo_library go_repo generates.

Version 1.23.0
--------------
* Be able to specify whether to add tests (#346)
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.23.0
1.24.0
5 changes: 4 additions & 1 deletion tools/please_go/generate/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ type Generate struct {
install []string
labels []string
largePackages []string
licences []string
}

func New(srcRoot, thirdPartyFolder, hostModFile, module, version, subrepo string, buildFileNames, moduleDeps, install []string, buildTags []string, labels []string, largePackages []string) *Generate {
func New(srcRoot, thirdPartyFolder, hostModFile, module, version, subrepo string, buildFileNames, moduleDeps, install, buildTags, labels, largePackages, licences []string) *Generate {
moduleArg := module
if version != "" {
moduleArg += "@" + version
Expand All @@ -58,6 +59,7 @@ func New(srcRoot, thirdPartyFolder, hostModFile, module, version, subrepo string
subrepo: subrepo,
labels: labels,
largePackages: largePackages,
licences: licences,
}
}

Expand Down Expand Up @@ -320,6 +322,7 @@ func (g *Generate) matchesInstall(dir string) bool {
func (g *Generate) rule(rule *Rule) *bazelbuild.Rule {
r := NewRule(rule.kind, rule.name)
populateRule(r, rule)
r.SetAttr("licences", NewStringList(g.licences))
r.SetAttr("visibility", NewStringList([]string{"PUBLIC"}))
r.SetAttr("labels", NewStringList(g.labels))
if rule.kind == "go_library" {
Expand Down
3 changes: 2 additions & 1 deletion tools/please_go/please_go.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ var opts = struct {
Install []string `long:"install" description:"The packages to add to the :install alias"`
BuildTags []string `long:"build_tag" description:"Any build tags to apply to the build"`
Subrepo string `long:"subrepo" description:"The subrepo root to output into"`
Licences []string `long:"licence" description:"The licences under which the module is released"`
Labels []string `long:"label" description:"Additional labels to attach to subrepo targets"`
LargePackages []string `long:"large_package" description:"Relative names of packages which have lots of input files (meaning the go_library target should be marked as large)"`
Args struct {
Expand Down Expand Up @@ -170,7 +171,7 @@ var subCommands = map[string]func() int{
},
"generate": func() int {
gen := opts.Generate
g := generate.New(gen.SrcRoot, gen.ThirdPartyFolder, gen.ModFile, gen.Module, gen.Version, gen.Subrepo, []string{"BUILD", "BUILD.plz"}, gen.Args.Requirements, gen.Install, gen.BuildTags, gen.Labels, gen.LargePackages)
g := generate.New(gen.SrcRoot, gen.ThirdPartyFolder, gen.ModFile, gen.Module, gen.Version, gen.Subrepo, []string{"BUILD", "BUILD.plz"}, gen.Args.Requirements, gen.Install, gen.BuildTags, gen.Labels, gen.LargePackages, gen.Licences)
if err := g.Generate(); err != nil {
log.Fatalf("failed to generate go rules: %v", err)
}
Expand Down
Loading