Add "build" stage to many Go packages (#36795)

This commit is contained in:
Alec Scott 2023-04-17 06:03:09 -07:00 committed by GitHub
parent abb236e98a
commit f82b4a68b8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 6 deletions

View File

@ -24,5 +24,14 @@ class Direnv(Package):
depends_on("go@1.16:", type="build", when="@2.28:")
depends_on("go", type="build")
phases = ["build", "install"]
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def build(self, spec, prefix):
make()
def install(self, spec, prefix):
make("install", "PREFIX=%s" % prefix)

View File

@ -30,6 +30,14 @@ class Gh(Package):
depends_on("go@1.16:", type="build")
def install(self, spec, prefix):
phases = ["build", "install"]
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def build(self, spec, prefix):
make()
def install(self, spec, prefix):
make("install", "prefix=" + prefix)

View File

@ -22,6 +22,15 @@ class Glab(Package):
depends_on("go@1.13:", type="build")
def install(self, spec, prefix):
phases = ["build", "install"]
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def build(self, spec, prefix):
make()
make("install", "prefix=" + prefix)
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("bin/glab", prefix.bin)

View File

@ -51,6 +51,8 @@ class Hugo(Package):
variant("extended", default=False, description="Enable extended features")
phases = ["build", "install"]
@classmethod
def determine_version(cls, exe):
output = Executable(exe)("version", output=str, error=str)
@ -58,13 +60,16 @@ def determine_version(cls, exe):
return match.group(1) if match else None
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def install(self, spec, prefix):
def build(self, spec, prefix):
go_args = ["build"]
if self.spec.satisfies("+extended"):
go_args.extend(["--tags", "extended"])
go(*go_args)
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("hugo", prefix.bin)

View File

@ -66,11 +66,15 @@ class Rclone(Package):
depends_on("go@1.15:", type="build")
phases = ["build", "install"]
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def install(self, spec, prefix):
def build(self, spec, prefix):
go("build")
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("rclone", prefix.bin)

View File

@ -23,11 +23,15 @@ class Restic(Package):
depends_on("go@1.15:", type="build", when="@0.14.0:")
depends_on("go", type="build")
phases = ["build", "install"]
def setup_build_environment(self, env):
# Point GOPATH at the top of the staging dir for the build step.
env.prepend_path("GOPATH", self.stage.path)
def install(self, spec, prefix):
def build(self, spec, prefix):
go("run", "build.go")
def install(self, spec, prefix):
mkdirp(prefix.bin)
install("restic", prefix.bin)