unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Sharlatan Hellseher <sharlatanus@gmail.com>
To: 74668@debbugs.gnu.org
Cc: Sharlatan Hellseher <sharlatanus@gmail.com>,
	Katherine Cox-Buday <cox.katherine.e+guix@gmail.com>,
	Sharlatan Hellseher <sharlatanus@gmail.com>
Subject: [bug#74668] [PATCH 1/2] build: go-build-system: Relax build verbosity.
Date: Tue,  3 Dec 2024 11:45:33 +0000	[thread overview]
Message-ID: <3ea6c0ae31e373d3eac4212dee0bc6b706765ee2.1733224617.git.sharlatanus@gmail.com> (raw)
In-Reply-To: <cover.1733224617.git.sharlatanus@gmail.com>

During the build phase "-x" option forces go compiler to generate quite
a noisy build log which does not help too much when the build is failed.
This change makes it optional and governed by #:verbosity key passed to
`build' procedure.

* guix/build/go-build-system.scm (build): Provide a link to online
example.  Consolidate options in GOFLAGS environment variable, make "-x"
optional.  Add description for "-trimpath" option.

Change-Id: Icf1b03eb79db8a6f79f86f3cc212a53de5aa7c1c
---
 guix/build/go-build-system.scm | 40 +++++++++++++++++++++++++---------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index e53d8cb53c..a463189011 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -283,23 +283,43 @@ (define (go-inputs inputs)
                 (_ #f))
               inputs))))
 
-(define* (build #:key import-path build-flags (parallel-build? #t)
+(define* (build #:key
+                build-flags
+                import-path
+                (parallel-build? #t)
+                (verbosity 1)
                 #:allow-other-keys)
   "Build the package named by IMPORT-PATH."
-  (let* ((njobs (if parallel-build? (parallel-job-count) 1)))
+  (let* ((njobs (if parallel-build? (parallel-job-count) 1))
+         ;; Utilizing GOFLAGS for flexible build options passthrough, refer
+         ;; for more examples to online documentation of Golang
+         ;; <https://go.dev/src/cmd/go/testdata/script/goflags.txt>.
+         (goflags (string-join
+                   (list
+                    ;; Print the name of packages (pathes) as they are compiled.
+                    "-v"
+                    ;; Print each command as it is invoked. When enabled, it
+                    ;; generates a lot of noisy logs which makes identifying
+                    ;; build failures harder to determine.
+                    (if (> verbosity 1) "-x" "")
+                    ;; Respectively, strip the symbol table and debug
+                    ;; information, and the DWARF symbol table.
+                    "-ldflags=-s -w"
+                    ;; Remove all file system paths from the resulting
+                    ;; executable.  Instead of absolute file system paths, the
+                    ;; recorded file names will begin either a module
+                    ;; path@version (when using modules), or a plain import
+                    ;; path (when using the standard library, or GOPATH).
+                    "-trimpath")
+                   " ")))
+    (setenv "GOFLAGS" goflags)
     (setenv "GOMAXPROCS" (number->string njobs)))
 
   (with-throw-handler
     #t
     (lambda _
-      (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"
-              "-trimpath"
-              `(,@build-flags ,import-path)))
+      (apply invoke "go" "install" `(,@build-flags ,import-path)))
+
     (lambda (key . args)
       (display (string-append "Building '" import-path "' failed.\n"
                               "Here are the results of `go env`:\n"))
-- 
2.46.0





  reply	other threads:[~2024-12-03 11:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-03 11:44 [bug#74668] [PATCH 0/2] Golang build-system adjustments Sharlatan Hellseher
2024-12-03 11:45 ` Sharlatan Hellseher [this message]
2024-12-03 11:45 ` [bug#74668] [PATCH 2/2] build-system/go: Add test-subdirs option key Sharlatan Hellseher

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

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3ea6c0ae31e373d3eac4212dee0bc6b706765ee2.1733224617.git.sharlatanus@gmail.com \
    --to=sharlatanus@gmail.com \
    --cc=74668@debbugs.gnu.org \
    --cc=cox.katherine.e+guix@gmail.com \
    /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 public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).