Open sean- opened 2 months ago
I would advise you use go_repo which is the latest way to add third party go deps but if you want to use go_module first I think maybe you want
go_module(
name = "mage_module",
module = "github.com/magefile/mage",
version = "v1.15.0",
binary = True,
)
To explain in more detail the module
argument defines the go module you want so you don't need to repeat that in your install list and binary = True
says you want compile it as an executable. you don't need an install list because you are installing the root package of the module aka main.go
in github.com/magefile/mage
.
If you had wanted to install other packages within that module eg. there was a src/submodulex
within it then you would do install = [".", "src/submodulex"],
aka the root and the submodule you want.
if you wanted to use go_repo you would do
go_repo(
name = "mage_module",
module = "github.com/magefile/mage",
version = "v1.15.0",
)
filegroup(
name = "mage",
srcs = ["///third_party/go/github.com_magefile_mage//:mage"],
binary = True,
)
Drat. I was hoping to avoid that because I wanted to pass in commitHash
and the like to properly stamp the mage
util. filegroup()
doesn't support definitions
like go_binary
does. e.g.:
filegroup(
name = "mage",
srcs = ["///third_party/go/github.com_magefile_mage//:mage"],
binary = True,
definitions = {
"commitHash": git_commit(),
"timestamp": git_show("%ct"),
"gitTag": git_branch(),
},
)
As I said, it seems like this should be easily doable within go-rules.
Ideally, the library would be separate from the binary because there are moments when I do want to use mage
as a library. Thank you for your help.
I'm struggling mightily with getting the
mage
tool built using the new regime. I'm coming from:And trying to upgrade to:
Results in:
Or:
Which results in:
or the other commented-out variant:
This feels like it should be dead simple, but I'm struggling because I also can't easily investigate the build environment because the
--shell
is failing to build.