From f82b4a68b8107e5b2706b0f1587fdc2370f2bb3a Mon Sep 17 00:00:00 2001 From: Alec Scott Date: Mon, 17 Apr 2023 06:03:09 -0700 Subject: Add "build" stage to many Go packages (#36795) --- var/spack/repos/builtin/packages/direnv/package.py | 9 +++++++++ var/spack/repos/builtin/packages/gh/package.py | 10 +++++++++- var/spack/repos/builtin/packages/glab/package.py | 13 +++++++++++-- var/spack/repos/builtin/packages/hugo/package.py | 7 ++++++- var/spack/repos/builtin/packages/rclone/package.py | 6 +++++- var/spack/repos/builtin/packages/restic/package.py | 6 +++++- 6 files changed, 45 insertions(+), 6 deletions(-) diff --git a/var/spack/repos/builtin/packages/direnv/package.py b/var/spack/repos/builtin/packages/direnv/package.py index 52b5ae0ff7..726ac554fb 100644 --- a/var/spack/repos/builtin/packages/direnv/package.py +++ b/var/spack/repos/builtin/packages/direnv/package.py @@ -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) diff --git a/var/spack/repos/builtin/packages/gh/package.py b/var/spack/repos/builtin/packages/gh/package.py index 4817ceabe4..96070fe6e9 100644 --- a/var/spack/repos/builtin/packages/gh/package.py +++ b/var/spack/repos/builtin/packages/gh/package.py @@ -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) diff --git a/var/spack/repos/builtin/packages/glab/package.py b/var/spack/repos/builtin/packages/glab/package.py index 86cc93e6d2..a827e7d7ab 100644 --- a/var/spack/repos/builtin/packages/glab/package.py +++ b/var/spack/repos/builtin/packages/glab/package.py @@ -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) diff --git a/var/spack/repos/builtin/packages/hugo/package.py b/var/spack/repos/builtin/packages/hugo/package.py index d4dc96f8ff..eabd10754b 100644 --- a/var/spack/repos/builtin/packages/hugo/package.py +++ b/var/spack/repos/builtin/packages/hugo/package.py @@ -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 @@ class Hugo(Package): 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) diff --git a/var/spack/repos/builtin/packages/rclone/package.py b/var/spack/repos/builtin/packages/rclone/package.py index 0dfe46530d..01341dbd00 100644 --- a/var/spack/repos/builtin/packages/rclone/package.py +++ b/var/spack/repos/builtin/packages/rclone/package.py @@ -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) diff --git a/var/spack/repos/builtin/packages/restic/package.py b/var/spack/repos/builtin/packages/restic/package.py index c9c85e6ad5..83ac62f824 100644 --- a/var/spack/repos/builtin/packages/restic/package.py +++ b/var/spack/repos/builtin/packages/restic/package.py @@ -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) -- cgit v1.2.3-70-g09d2