[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
125/172: build/go: Replace symlinks with a copy of the file.
From: |
guix-commits |
Subject: |
125/172: build/go: Replace symlinks with a copy of the file. |
Date: |
Sat, 9 Nov 2024 16:45:06 -0500 (EST) |
sharlatan pushed a commit to branch master
in repository guix.
commit 922d0170818b6f9ba55b6202825f689b645419eb
Author: Efraim Flashner <efraim@flashner.co.il>
AuthorDate: Mon Sep 16 18:38:46 2024 +0300
build/go: Replace symlinks with a copy of the file.
* guix/build/go-build-system.scm (fix-embed-files): New procedure.
(%standard-phases): Add 'fix-embed-files after 'unpack.
* guix/build-system/go.scm (#:embed-files): New key parameter.
* doc/guix.texi: (go-build-system): Document a new key.
Co-authored-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Change-Id: I27bc46fa1a3f4675ff73b6cba4ef5c3d177c22b1
---
doc/guix.texi | 7 +++++++
guix/build-system/go.scm | 6 ++++++
guix/build/go-build-system.scm | 30 ++++++++++++++++++++++++++++--
3 files changed, 41 insertions(+), 2 deletions(-)
diff --git a/doc/guix.texi b/doc/guix.texi
index 789e153189..8f65387e92 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -132,6 +132,8 @@ Copyright @copyright{} 2024 Denis 'GNUtoo' Carikli@*
Copyright @copyright{} 2024 Fabio Natali@*
Copyright @copyright{} 2024 Arnaud Daby-Seesaram@*
Copyright @copyright{} 2024 Nigko Yerden@*
+Copyright @copyright{} 2024 Troy Figiel@*
+Copyright @copyright{} 2024 Sharlatan Hellseher@*
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -9588,6 +9590,11 @@ the test binary. Build, test and test binary flags can
be provided as
@code{#:test-flags} parameter, default is @code{'()}. See @code{go help
test} and @code{go help testflag} for more details.
+The key @code{#:embed-files}, default is @code{'()}, provides a list of
+future embedded files or regexps matching files. They will be copied to
+build directory after @code{unpack} phase. See
+@url{https://pkg.go.dev/embed} for more details.
+
@end defvar
@defvar glib-or-gtk-build-system
diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm
index e6e8b84e48..97581a14c6 100644
--- a/guix/build-system/go.scm
+++ b/guix/build-system/go.scm
@@ -6,6 +6,8 @@
;;; 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.
;;;
@@ -197,6 +199,7 @@ 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 ''())
@@ -226,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))
@@ -264,6 +268,7 @@ commit hash and its date rather than a proper release tag."
(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)
@@ -297,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
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 3f0f5700a1..14cb5ae687 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -4,10 +4,12 @@
;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
-;;; Copyright © 2020, 2021, 2023 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2020, 2021, 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech>
;;; Copyright © 2024 Picnoir <picnoir@alternativebit.fr>
+;;; Copyright © 2024 Troy Figiel <troy@troyfigiel.com>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -28,8 +30,9 @@
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build union)
#:use-module (guix build utils)
- #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
#:use-module (ice-9 ftw)
+ #:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors)
@@ -201,6 +204,28 @@ dependencies, so it should be self-contained."
(delete-file-recursively tmpdir))
#t)
+(define* (fix-embed-files #:key embed-files #:allow-other-keys)
+ "Golang can't determine the valid directory of the module of embed file
+which is symlinked during setup environment phase, but easy resolved after
+coping file from the store to the build directory of the current package. Take
+a list of files or regexps matching files from EMBED-FILES paramter, failover
+to 'editions_defaults.binpb' which is a part of <github.com/golang/protobuf>."
+ ;; see details in Golang source:
+ ;;
+ ;; - URL: <https://github.com/golang/go/blob/>
+ ;; - commit: 82c14346d89ec0eeca114f9ca0e88516b2cda454
+ ;; - file: src/cmd/go/internal/load/pkg.go#L2059
+ (let ((embed-files (format #f "^(~{~a|~}~a)$"
+ embed-files
+ "editions_defaults.binpb")))
+ (for-each (lambda (file)
+ (when (eq? (stat:type (lstat file))
+ 'symlink)
+ (let ((file-store-path (readlink file)))
+ (delete-file file)
+ (copy-recursively file-store-path file))))
+ (find-files "src" embed-files))))
+
(define* (unpack #:key source import-path unpack-path #:allow-other-keys)
"Relative to $GOPATH, unpack SOURCE in UNPACK-PATH, or IMPORT-PATH when
UNPACK-PATH is unset. If the SOURCE archive has a single top level directory,
@@ -321,6 +346,7 @@ the standard install-license-files phase to first enter the
correct directory."
(delete 'patch-generated-file-shebangs)
(add-before 'unpack 'setup-go-environment setup-go-environment)
(replace 'unpack unpack)
+ (add-after 'unpack 'fix-embed-files fix-embed-files)
(replace 'build build)
(replace 'check check)
(replace 'install install)
- 107/172: gnu: Add go-github-com-circonus-labs-circonus-gometrics-v3., (continued)
- 107/172: gnu: Add go-github-com-circonus-labs-circonus-gometrics-v3., guix-commits, 2024/11/09
- 108/172: gnu: Add go-github-com-hashicorp-go-immutable-radix., guix-commits, 2024/11/09
- 102/172: gnu: Add go-github-com-datadog-datadog-go-v5., guix-commits, 2024/11/09
- 103/172: gnu: Add go-github-com-openhistogram-circonusllhist., guix-commits, 2024/11/09
- 106/172: gnu: Add go-github-com-circonus-labs-go-apiclient., guix-commits, 2024/11/09
- 110/172: gnu: Add go-github-com-xlab-treeprint., guix-commits, 2024/11/09
- 124/172: gnu: go-github-com-matttproud-golang-protobuf-extensions-v2: Fix build., guix-commits, 2024/11/09
- 130/172: gnu: Add go-github-com-aead-ecdh., guix-commits, 2024/11/09
- 132/172: gnu: go-github-com-aead-chacha20: Fix indentation., guix-commits, 2024/11/09
- 116/172: gnu: Add go-msgp., guix-commits, 2024/11/09
- 125/172: build/go: Replace symlinks with a copy of the file.,
guix-commits <=
- 122/172: gnu: go-github-com-nbrownus-go-metrics-prometheus: Fix build., guix-commits, 2024/11/09
- 131/172: gnu: go-github-com-aead-chacha20: Update to 0.0.0-20180709150244-8b13a72661da., guix-commits, 2024/11/09
- 128/172: gnu: go-github-com-deckarep-golang-set-v2: Update to 2.6.0., guix-commits, 2024/11/09
- 134/172: gnu: go-github-com-shadowsocks-go-shadowsocks2: Enable all tests., guix-commits, 2024/11/09
- 111/172: gnu: Add go-github-com-ryanuber-columnize., guix-commits, 2024/11/09
- 170/172: build/go: fix-embed-files: Adjust procedure docstring., guix-commits, 2024/11/09
- 171/172: gnu: go-1.22: Update to 1.22.7., guix-commits, 2024/11/09
- 148/172: gnu: trezord: Refresh package style., guix-commits, 2024/11/09
- 146/172: gnu: Add go-github-com-prometheus-community-pro-bing., guix-commits, 2024/11/09
- 145/172: gnu: go-github-com-sevlyar-go-daemon: Move to golang-xyz., guix-commits, 2024/11/09