diff options
Diffstat (limited to 'guix/build-system/go.scm')
-rw-r--r-- | guix/build-system/go.scm | 41 |
1 files changed, 36 insertions, 5 deletions
diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm index 0934fded07..97581a14c6 100644 --- a/guix/build-system/go.scm +++ b/guix/build-system/go.scm @@ -5,6 +5,9 @@ ;;; Copyright © 2021-2022 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2021, 2023 Efraim Flashner <efraim@flashner.co.il> ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev> +;;; Copyright © 2024 Christina O'Donnell <cdo@mutix.org> +;;; Copyright © 2024 Troy Figiel <troy@troyfigiel.com> +;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com> ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +36,8 @@ #:use-module (ice-9 match) #:use-module (ice-9 regex) #:use-module (srfi srfi-1) + #:use-module (srfi srfi-34) + #:use-module (srfi srfi-35) #:export (%go-build-system-modules go-build go-build-system @@ -56,11 +61,13 @@ "([0-9A-Fa-f]{12})" ;commit hash "(\\+incompatible)?$"))) ;optional +incompatible tag -(define (go-version->git-ref version) +(define* (go-version->git-ref version #:key subdir) "Parse VERSION, a \"pseudo-version\" as defined at <https://golang.org/ref/mod#pseudo-versions>, and extract the commit hash from it, defaulting to full VERSION (stripped from the \"+incompatible\" suffix if -present) if a pseudo-version pattern is not recognized." +present) if a pseudo-version pattern is not recognized. If SUBDIR is +specified and this is not a pseudo-version, then this will prefix SUBDIR/ to +the returned tag; when VERSION misses 'v' prefix use SUBDIR/v instead." ;; A module version like v1.2.3 is introduced by tagging a revision in the ;; underlying source repository. Untagged revisions can be referred to ;; using a "pseudo-version" like v0.0.0-yyyymmddhhmmss-abcdefabcdef, where @@ -78,7 +85,13 @@ present) if a pseudo-version pattern is not recognized." (match (regexp-exec %go-pseudo-version-rx version))) (if match (match:substring match 2) - version))) + (cond + ((and subdir (string-prefix? "v" version)) + (string-append subdir "/" version)) + ((and subdir (not (string-prefix? "v" version))) + (string-append subdir "/v" version)) + (else + version))))) (define (go-pseudo-version? version) "True if VERSION is a Go pseudo-version, i.e., a version string made of a @@ -101,13 +114,19 @@ commit hash and its date rather than a proper release tag." (_ arch)) (match os ((or "mingw32" "cygwin") "windows") - (_ os)))))) + (_ os)))) + (_ + (raise + (condition + (&unsupported-cross-compilation-target-error + (build-system go-build-system) + (target target))))))) (define %go-build-system-modules ;; Build-side modules imported and used by default. `((guix build go-build-system) (guix build union) - ,@%gnu-build-system-modules)) + ,@%default-gnu-imported-modules)) (define (default-go) ;; Lazily resolve the binding to avoid a circular dependency. @@ -180,10 +199,14 @@ commit hash and its date rather than a proper release tag." (outputs '("out")) (search-paths '()) (install-source? #t) + (embed-files ''()) (import-path "") (unpack-path "") (build-flags ''()) (tests? #t) + (test-flags ''()) + (parallel-build? #t) + (parallel-tests? #t) (allow-go-reference? #f) (system (%current-system)) (goarch #f) @@ -206,6 +229,7 @@ commit hash and its date rather than a proper release tag." #:substitutable? #$substitutable? #:goarch #$goarch #:goos #$goos + #:embed-files #$embed-files #:search-paths '#$(sexp->gexp (map search-path-specification->sexp search-paths)) @@ -214,6 +238,9 @@ commit hash and its date rather than a proper release tag." #:unpack-path #$unpack-path #:build-flags #$build-flags #:tests? #$tests? + #:test-flags #$test-flags + #:parallel-build? #$parallel-build? + #:parallel-tests? #$parallel-tests? #:allow-go-reference? #$allow-go-reference? #:inputs #$(input-tuples->gexp inputs))))) @@ -236,10 +263,12 @@ commit hash and its date rather than a proper release tag." (unpack-path "") (build-flags ''()) (tests? #f) ; nothing can be done + (test-flags ''()) (allow-go-reference? #f) (system (%current-system)) (goarch (first (go-target target))) (goos (last (go-target target))) + (embed-files ''()) (guile #f) (imported-modules %go-build-system-modules) (modules '((guix build go-build-system) @@ -273,6 +302,7 @@ commit hash and its date rather than a proper release tag." #:target #$target #:goarch #$goarch #:goos #$goos + #:embed-files #$embed-files #:inputs %build-target-inputs #:native-inputs %build-host-inputs #:search-paths '#$(map search-path-specification->sexp @@ -285,6 +315,7 @@ commit hash and its date rather than a proper release tag." #:unpack-path #$unpack-path #:build-flags #$build-flags #:tests? #$tests? + #:test-flags #$test-flags #:make-dynamic-linker-cache? #f ;cross-compiling #:allow-go-reference? #$allow-go-reference? #:inputs %build-inputs)))) |