From mboxrd@z Thu Jan 1 00:00:00 1970 From: Leo Famulari Subject: [go-build-system] How to access properties or keys of a package on the build side? Date: Mon, 28 Aug 2017 14:51:44 -0400 Message-ID: <20170828185144.GA24652@jasmine.lan> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="YZ5djTAD1cGYuMQK" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:46922) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmP9H-0006Pc-1g for guix-devel@gnu.org; Mon, 28 Aug 2017 14:52:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmP9C-0004Gf-NJ for guix-devel@gnu.org; Mon, 28 Aug 2017 14:52:35 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:34685) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmP9C-0004Fk-IG for guix-devel@gnu.org; Mon, 28 Aug 2017 14:52:30 -0400 Received: from localhost (unknown [172.58.201.15]) by mail.messagingengine.com (Postfix) with ESMTPA id 0287424605 for ; Mon, 28 Aug 2017 14:52:27 -0400 (EDT) Content-Disposition: inline List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: guix-devel@gnu.org --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Recently I made some progress on finishing the prototype go-build-system =66rom Petter [0], and I need some advice. AFAICT, building a Go program requires the program's Go dependencies to have a particular filesystem layout, which corresponds to the way these dependencies are imported by the program's code. So, a Go build system needs to somehow create a symlink union of the dependency graph, making the dependencies available at the correct paths relative to the root of the build environment. AFAICT, we can't figure these paths out programatically; they must be supplied by the packager in advance, for example: ------ (arguments `(#:import-path "github.com/AudriusButkevicius/go-nat-pmp")) ------ Petter's prototype creates the symlink union, but instead of using the #:import-path key, it instead duplicates the import path while listing a package's dependencies, like this: ------ (inputs `(("github.com/AudriusButkevicius/go-nat-pmp" ,golang-github-com-audriusbutkevicius-go-nat-pmp) ------ =2E.. putting the import path in the car of the input, and using it as shown below: ------ (define* (symlinking #:key inputs #:allow-other-keys) (for-each (lambda (input) (let ((import-path (car input)) (storepath (cdr input))) ; Don't deal with the compiler or source inputs (if (and (not (string=3D? import-path "go")) (not (string=3D? import-path "source"))) (begin (mkdir-p (string-append "src/" (string-take import-path (string-rindex import-path #\/= )))) (let ((from (string-append storepath "/src/" import-p= ath)) (to (string-append "src/" import-path))) (if (file-exists? to) (delete-file-recursively to)) (symlink (string-append storepath "/src/" import-path) (string-append "src/" import-path))))))) inputs)) ------ Are there any examples in the code base of accessing the inputs' keys? That seems like a better solution to me, but I'm not sure how to achieve it. [0] https://lists.gnu.org/archive/html/guix-devel/2016-12/msg00399.html --YZ5djTAD1cGYuMQK Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEsFFZSPHn08G5gDigJkb6MLrKfwgFAlmkZjwACgkQJkb6MLrK fwhFnQ//Yx10wPa6H557mJz7yAuddwE4vSBwyEB0XPKj9dMQosLk9KF+hWlnXM6E HEKIEYqR6n/W6gFVQ4UIJWU5sp9nd8ujbRUwezoZeLpAVXTP1TnEC4ykFU5dv6KT FO0VvBL0DvEzzUEiVBqFandph1HTn+2tpJ4paWHXmI5/am60rscZdfVDfRl7/Klz 1S+1OIC4nxTuGZgwS09tLYbxYtd7d0IQMXmbsl6xZqc+OtsSBeN6W3pw217mIJRB 8+LqSnLZHO1hbGAVEr84AwbOtH1A3bAFx3klNIdDkkBGibwoxGL0gAaYFgdHv2GS d2CKXsE19o6Lsd4j8Qm00R23zSTsZeyJWIP9uEDitJo2I8300giP8+Mu5q65hbOp j2c3D/dSqxX9boPaoFziYxRpmR1casnW7a7zV62jEhWbQdkU5ynXn5B/UE/H7GqZ QcYmXK+6jH+tCzBsmrBBAw1A8r1tnRU3xcep9Rx7S+7bwgzKhKbx7072xRY157+b 0HUq3zHpCtYNJ3WRVfsfOXjD8cFgw1u+A3ns5Ss2xDakZwI//gWgBVGMEdO1z/aV 4Nde0xnUCw6agwfteXxUQn2umpzCrDymmY/ub/IZe41bX7TGQH+pFY2nK32bGBnt V+YrCQFrLBwdPYCyQn5GV8e11orcUUhfRMdZo7/JLN1PU4NGpIE= =NguB -----END PGP SIGNATURE----- --YZ5djTAD1cGYuMQK--