unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Petter <petter@mykolab.ch>
To: Leo Famulari <leo@famulari.name>
Cc: guix-devel@gnu.org
Subject: Re: gnu: Add Go build system.
Date: Fri, 16 Dec 2016 10:57:34 +0100	[thread overview]
Message-ID: <ef2acad6fed9bc402f68f462a82819f2@mykolab.ch> (raw)
In-Reply-To: <20161216044945.GA4016@jasmine>

On 2016-12-16 03:05, Leo Famulari wrote:
> On Sun, Dec 11, 2016 at 01:17:48AM +0100, Petter wrote:
>> +(define* (build #:key import-path #:allow-other-keys)
>> +  (system* "go" "install" import-path))
>> +
>> +(define* (install #:key inputs outputs #:allow-other-keys)
>> +  (copy-recursively "bin" (string-append (assoc-ref outputs "out") 
>> "/bin"))
>> +  (copy-recursively "pkg" (string-append (assoc-ref outputs "out") 
>> "/pkg"))
>> +  (copy-recursively "src" (string-append (assoc-ref outputs "out") 
>> "/src")))
> 
> It looks like `go install` knows "where" to install the files, but
> installs them in the wrong place, and then we copy them into place in
> the install phase. I think it's inefficient to move the files twice.
> 
> Can the build phase use something like `go build`, followed by the
> install phase using `go install` to move the files directly to the
> package's output directory in /gnu/store?

The differences between `go install` and `go build` here is that `go
install` compiles and moves the result to $GOPATH/bin (unless GOBIN is
set to somewhere else).

`go build` compiles (always from source I believe) and leaves the
resulting binary in current directory.

`go install` compiles and also creates package objects in pkg/ which I
believe is a compiled object that is compiled once and then reused,
unless source is changed. Not sure if timestamps are used to determine
whether source has changed, and how that works on Guix.

Optimizations could be made for sure, I will look at this at
convenience.

On 2016-12-16 05:49, Leo Famulari wrote:
> On Sun, Dec 11, 2016 at 01:17:48AM +0100, Petter wrote:
>> From 4c0597a95ae3cd111ef12d675edf501c559458ba Mon Sep 17 00:00:00 2001
>> From: Petter <petter@mykolab.ch>
>> Date: Sun, 11 Dec 2016 01:10:09 +0100
>> Subject: [PATCH] gnu: Add Go build system.
>> 
>> * guix/build-system/go.scm: New file
>> * guix/build/go-build-system.scm: New file.
> 
> Another question: does this build system try to run tests? In my own
> Syncthing packaging I used `go run build.go test`, but I noticed that
> your Syncthing package built with this build system doesn't seem to run
> the tests.

No. It only builds/installs at the moment. Tests, docs,
cross-compilation and other things (if there are more things), are not
dealt with at this point.

Note that Syncthing uses their own build program (build.go). This is
atypical. There will be a test phase, and Syncthing will override this
with their way of running tests.

Regarding cross-compilation. Go supports: 386, amd64, amd64p32, arm,
arm64, mips64, mips64le, ppc64, ppc64le and s390x as far as I can
tell. With mips32 being added in February. I have yet to discover how
the build system should deal with cross-compilations. The Go part is
easy, just set the GOARCH environment variable before compiling.
`GOARCH=mips64 go install ...`

      reply	other threads:[~2016-12-16  9:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-11  0:17 gnu: Add Go build system Petter
2016-12-16  2:05 ` Leo Famulari
2016-12-16  4:49 ` Leo Famulari
2016-12-16  9:57   ` Petter [this message]

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=ef2acad6fed9bc402f68f462a82819f2@mykolab.ch \
    --to=petter@mykolab.ch \
    --cc=guix-devel@gnu.org \
    --cc=leo@famulari.name \
    /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).