From: Marius Bakke <marius@gnu.org>
To: 50227@debbugs.gnu.org
Subject: [bug#50227] [PATCH 1/3] build-system/go: Use a native-search-path for GOPATH.
Date: Fri, 27 Aug 2021 17:13:28 +0200 [thread overview]
Message-ID: <20210827151330.13112-1-marius@gnu.org> (raw)
In-Reply-To: <20210827151052.12611-1-marius@gnu.org>
* gnu/packages/golang.scm (go-1.14)[native-search-paths]: New field.
* guix/build/go-build-system.scm (setup-go-environment): Make the working
directory the first entry on GOPATH instead of creating a union.
(unpack, install): Adjust accordingly.
(go-package?, go-inputs): Remove variables.
---
gnu/packages/golang.scm | 4 ++++
guix/build/go-build-system.scm | 37 ++++------------------------------
2 files changed, 8 insertions(+), 33 deletions(-)
diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index 72579d6bd2..3a5c6ddc3f 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -257,6 +257,10 @@ in the style of communicating sequential processes (@dfn{CSP}).")
(sha256
(base32
"1crh90qkvhlx23hwsi4wxy3l3h8973lr18135y6h1nnzzwr3n3ps"))))
+ (native-search-paths
+ (list (search-path-specification
+ (variable "GOPATH")
+ (files '("src/.." "pkg/..")))))
(arguments
(substitute-keyword-arguments (package-arguments go-1.4)
((#:system system)
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 227df820db..01dd8cd249 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -5,6 +5,7 @@
;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;; Copyright © 2020 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2021 Marius Bakke <marius@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -88,7 +89,6 @@
;; a tmpdir when creating the inputs union.
;; * Use Go modules [4]
;; * Re-use compiled packages [5]
-;; * Avoid the go-inputs hack
;; * Stop needing remove-go-references (-trimpath ? )
;; * Remove module packages, only offering the full Git repos? This is
;; more idiomatic, I think, because Go downloads Git repos, not modules.
@@ -143,23 +143,12 @@ dependencies, so it should be self-contained."
(setenv "GOCACHE" "/tmp/go-cache")
;; Using the current working directory as GOPATH makes it easier for packagers
;; who need to manipulate the unpacked source code.
- (setenv "GOPATH" (getcwd))
+ (setenv "GOPATH" (string-append (getcwd) ":" (getenv "GOPATH")))
;; Go 1.13 uses go modules by default. The go build system does not
;; currently support modules, so turn modules off to continue using the old
;; GOPATH behavior.
(setenv "GO111MODULE" "off")
(setenv "GOBIN" (string-append (assoc-ref outputs "out") "/bin"))
- (let ((tmpdir (tmpnam)))
- (match (go-inputs inputs)
- (((names . directories) ...)
- (union-build tmpdir (filter directory-exists? directories)
- #:create-all-directories? #t
- #:log-port (%make-void-port "w"))))
- ;; XXX A little dance because (guix build union) doesn't use mkdir-p.
- (copy-recursively tmpdir
- (string-append (getenv "GOPATH"))
- #:keep-mtime? #t)
- (delete-file-recursively tmpdir))
#t)
(define* (unpack #:key source import-path unpack-path #:allow-other-keys)
@@ -191,31 +180,13 @@ unpacking."
(display "WARNING: The Go import path is unset.\n"))
(when (string-null? unpack-path)
(set! unpack-path import-path))
- (let ((dest (string-append (getenv "GOPATH") "/src/" unpack-path)))
+ (let ((dest (string-append (getcwd) "/src/" unpack-path)))
(mkdir-p dest)
(if (file-is-directory? source)
(copy-recursively source dest #:keep-mtime? #t)
(unpack-maybe-strip source dest)))
#t)
-(define (go-package? name)
- (string-prefix? "go-" name))
-
-(define (go-inputs inputs)
- "Return the alist of INPUTS that are Go software."
- ;; XXX This should not check the file name of the store item. Instead we
- ;; should pass, from the host side, the list of inputs that are packages using
- ;; the go-build-system.
- (alist-delete "go" ; Exclude the Go compiler
- (alist-delete "source" ; Exclude the source code of the package being built
- (filter (match-lambda
- ((label . directory)
- (go-package? ((compose package-name->name+version
- strip-store-file-name)
- directory)))
- (_ #f))
- inputs))))
-
(define* (build #:key import-path build-flags #:allow-other-keys)
"Build the package named by IMPORT-PATH."
(with-throw-handler
@@ -249,7 +220,7 @@ XXX We can't make use of compiled libraries (Go \"packages\")."
(if (string-null? import-path)
((display "WARNING: The Go import path is unset.\n")))
(let* ((out (assoc-ref outputs "out"))
- (source (string-append (getenv "GOPATH") "/src/" import-path))
+ (source (string-append "src/" import-path))
(dest (string-append out "/src/" import-path)))
(mkdir-p dest)
(copy-recursively source dest #:keep-mtime? #t)))
--
2.31.1
next prev parent reply other threads:[~2021-08-27 15:16 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-27 15:10 [bug#50227] [PATCH 0/3] go-build-system and GOPATH improvements Marius Bakke
2021-08-27 15:13 ` Marius Bakke [this message]
2021-08-27 15:13 ` [bug#50227] [PATCH 2/3] gnu: hyperledger-fabric: Do not assume GOPATH contains a single entry Marius Bakke
2021-08-27 15:13 ` [bug#50227] [PATCH 3/3] gnu: go-gotest-tools-assert: Provide internal inputs with the source Marius Bakke
2021-08-27 16:44 ` [bug#50227] [PATCH] build-system/go: Trim store references using the native compiler option Marius Bakke
2021-08-27 17:47 ` Marius Bakke
2021-08-27 19:38 ` Marius Bakke
2021-08-28 2:16 ` [bug#50227] [PATCH 0/3] go-build-system and GOPATH improvements Sarah Morgensen
2021-08-28 14:52 ` Marius Bakke
2022-01-14 3:13 ` Maxim Cournoyer
2021-08-29 6:17 ` [bug#50227] [PATCH 3/3] gnu: go-gotest-tools-assert: Provide internal inputs with the source Sarah Morgensen
2021-09-03 22:55 ` [bug#50227] [PATCH 0/3] go-build-system and GOPATH improvements Sarah Morgensen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210827151330.13112-1-marius@gnu.org \
--to=marius@gnu.org \
--cc=50227@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.