build-system/go: Allow providing additional build flags

* guix/build-system/go.scm (build-flags): New argument.
* guix/build/go-build-system.scm (build): Use apply to pass the
  additional arguments to invoke.
This commit is contained in:
Jakub Kądziołka 2020-01-05 17:13:20 +01:00
parent 18705a507d
commit 3f3c9fdcd8
No known key found for this signature in database
GPG Key ID: E315A75846131564
2 changed files with 7 additions and 3 deletions

View File

@ -1,6 +1,7 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Petter <petter@mykolab.ch>
;;; Copyright © 2017 Leo Famulari <leo@famulari.name>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;;
;;; This file is part of GNU Guix.
;;;
@ -82,6 +83,7 @@
(install-source? #t)
(import-path "")
(unpack-path "")
(build-flags ''())
(tests? #t)
(allow-go-reference? #f)
(system (%current-system))
@ -109,6 +111,7 @@
#:install-source? ,install-source?
#:import-path ,import-path
#:unpack-path ,unpack-path
#:build-flags ,build-flags
#:tests? ,tests?
#:allow-go-reference? ,allow-go-reference?
#:inputs %build-inputs)))

View File

@ -3,6 +3,7 @@
;;; Copyright © 2017, 2019 Leo Famulari <leo@famulari.name>
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
;;;
;;; This file is part of GNU Guix.
;;;
@ -214,18 +215,18 @@ unpacking."
(_ #f))
inputs))))
(define* (build #:key import-path #:allow-other-keys)
(define* (build #:key import-path build-flags #:allow-other-keys)
"Build the package named by IMPORT-PATH."
(with-throw-handler
#t
(lambda _
(invoke "go" "install"
(apply invoke "go" "install"
"-v" ; print the name of packages as they are compiled
"-x" ; print each command as it is invoked
;; Respectively, strip the symbol table and debug
;; information, and the DWARF symbol table.
"-ldflags=-s -w"
import-path))
`(,@build-flags ,import-path)))
(lambda (key . args)
(display (string-append "Building '" import-path "' failed.\n"
"Here are the results of `go env`:\n"))