From 6d668a16be4af017aacf8e20ecfa044b84d637d3 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Mon, 8 Jul 2019 18:34:39 +0200 Subject: build: svn-fetch: Use "svn export". * guix/build/svn.scm (svn-fetch): Use "svn export" instead of "svn checkout" because it does not include the .svn directory and allows us to fetch single files. --- guix/build/svn.scm | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'guix/build') diff --git a/guix/build/svn.scm b/guix/build/svn.scm index 913f89471b..e3188add3e 100644 --- a/guix/build/svn.scm +++ b/guix/build/svn.scm @@ -36,7 +36,7 @@ (define* (svn-fetch url revision directory "Fetch REVISION from URL into DIRECTORY. REVISION must be an integer, and a valid Subversion revision. Return #t on success, #f otherwise." (apply invoke svn-command - "checkout" "--non-interactive" + "export" "--non-interactive" ;; Trust the server certificate. This is OK as we ;; verify the checksum later. This can be removed when ;; ca-certificates package is added. @@ -46,13 +46,6 @@ (define* (svn-fetch url revision directory (string-append "--password=" password)) '()) ,url ,directory)) - - ;; The contents of '.svn' vary as a function of the current status - ;; of the repo. Since we want a fixed output, this directory needs - ;; to be taken out. - (with-directory-excursion directory - (for-each delete-file-recursively (find-files "." "^\\.svn$" #:directories? #t))) - #t) ;;; svn.scm ends here -- cgit v1.2.3 From a3316239312b2dfd43c51f283860352e5652ea06 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Thu, 20 Apr 2017 16:43:35 +0200 Subject: guix: ant-build-system: Use ant-task "jar" instead of executing "jar". * guix/build/ant-build-system.scm (default-build.xml): Change XML for target "jar" to use ant-task "jar" instead of "exec". --- guix/build/ant-build-system.scm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'guix/build') diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index d79a2d55ed..a0dd6f0fb4 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -118,10 +118,9 @@ (define* (default-build.xml jar-name prefix #:optional (target (@ (name "jar") (depends "compile, manifest")) (mkdir (@ (dir "${jar.dir}"))) - (exec (@ (executable "jar")) - (arg (@ (line ,(string-append "-cmf ${manifest.file} " - "${jar.dir}/" jar-name - " -C ${classes.dir} .")))))) + (jar (@ (destfile ,(string-append "${jar.dir}/" jar-name)) + (manifest "${manifest.file}") + (basedir "${classes.dir}")))) (target (@ (name "install")) (copy (@ (todir "${dist.dir}")) -- cgit v1.2.3 From cbad3570db3e692af55eac5b69cb6db062a39d77 Mon Sep 17 00:00:00 2001 From: Hartmut Goebel Date: Mon, 5 Sep 2016 11:08:39 +0200 Subject: guix: ant-build-system: Put dummy project-name into default build.xml. Without this, ant reported error messages like Target "tests" does not exist in the project "null". Simple using the jar-name is a good compromise. * guix/build/ant-build-system.scm (default-build.xml): Add attribute to sxml expression. --- guix/build/ant-build-system.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix/build') diff --git a/guix/build/ant-build-system.scm b/guix/build/ant-build-system.scm index a0dd6f0fb4..49549c1b4b 100644 --- a/guix/build/ant-build-system.scm +++ b/guix/build/ant-build-system.scm @@ -43,7 +43,8 @@ (define* (default-build.xml jar-name prefix #:optional (call-with-output-file "build.xml" (lambda (port) (sxml->xml - `(project (@ (basedir ".")) + `(project (@ (basedir ".") + (name ,jar-name)) (property (@ (name "classes.dir") (value "${basedir}/build/classes"))) (property (@ (name "manifest.dir") -- cgit v1.2.3 From ac6b78488faa80a83e85ee38e4a701d9c3c90c46 Mon Sep 17 00:00:00 2001 From: Efraim Flashner Date: Mon, 29 Jul 2019 22:01:05 +0300 Subject: build/cargo-build-system: Patch cargo checksums. * guix/build/cargo-build-system.scm (generate-all-checksums): New procedure. (update-cargo-lock, patch-cargo-checksums): New phases. (%standard-phases): Add 'update=cargo-lock after 'configure and 'patch-cargo-checksums after 'patch-generated-file-shebangs. * doc/guix.texi (Build System)[cargo-build-system]: Mention how Cargo.lock files are handled. --- doc/guix.texi | 7 ++++-- guix/build/cargo-build-system.scm | 48 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 50 insertions(+), 5 deletions(-) (limited to 'guix/build') diff --git a/doc/guix.texi b/doc/guix.texi index ccc36a8a97..cb60d5c7b7 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5854,8 +5854,11 @@ should be added to the package definition via the In its @code{configure} phase, this build system will make any source inputs specified in the @code{#:cargo-inputs} and @code{#:cargo-development-inputs} -parameters available to cargo. The @code{install} phase installs any crate -the binaries if they are defined by the crate. +parameters available to cargo. The @code{update-cargo-lock} phase will, +when there is a @code{Cargo.lock} file, update the @code{Cargo.lock} file +with the inputs and their versions available at build time. The +@code{install} phase installs any crate the binaries if they are defined by +the crate. @end defvr @cindex Clojure (programming language) diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index f38de16cf7..7d363a18a5 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2016 David Craven ;;; Copyright © 2017 Mathieu Othacehe ;;; Copyright © 2019 Ivan Petkov +;;; Copyright © 2019 Efraim Flashner ;;; ;;; This file is part of GNU Guix. ;;; @@ -39,6 +40,21 @@ (define-module (guix build cargo-build-system) ;; ;; Code: +;; TODO: Move this to (guix build cargo-utils). Will cause a full rebuild +;; of all rust compilers. + +(define (generate-all-checksums dir-name) + (for-each + (lambda (filename) + (let* ((dir (dirname filename)) + (checksum-file (string-append dir "/.cargo-checksum.json"))) + (when (file-exists? checksum-file) (delete-file checksum-file)) + (display (string-append + "patch-cargo-checksums: generate-checksums for " + dir "\n")) + (generate-checksums dir))) + (find-files dir-name "Cargo.toml$"))) + (define (manifest-targets) "Extract all targets from the Cargo.toml manifest" (let* ((port (open-input-pipe "cargo read-manifest")) @@ -94,8 +110,7 @@ (define* (configure #:key inputs ;; so that we can generate any cargo checksums. ;; The --strip-components argument is needed to prevent creating ;; an extra directory within `crate-dir`. - (invoke "tar" "xvf" path "-C" crate-dir "--strip-components" "1") - (generate-checksums crate-dir))))) + (invoke "tar" "xvf" path "-C" crate-dir "--strip-components" "1"))))) inputs) ;; Configure cargo to actually use this new directory. @@ -121,6 +136,31 @@ (define* (configure #:key inputs (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc")) #t) +;; The Cargo.lock file tells the build system which crates are required for +;; building and hardcodes their version and checksum. In order to build with +;; the inputs we provide, we need to recreate the file with our inputs. +(define* (update-cargo-lock #:key + (vendor-dir "guix-vendor") + #:allow-other-keys) + "Regenerate the Cargo.lock file with the current build inputs." + (when (file-exists? "Cargo.lock") + (begin + ;; Unfortunately we can't generate a Cargo.lock file until the checksums + ;; are generated, so we have an extra round of generate-all-checksums here. + (generate-all-checksums vendor-dir) + (delete-file "Cargo.lock") + (invoke "cargo" "generate-lockfile"))) + #t) + +;; After the 'patch-generated-file-shebangs phase any vendored crates who have +;; their shebangs patched will have a mismatch on their checksum. +(define* (patch-cargo-checksums #:key + (vendor-dir "guix-vendor") + #:allow-other-keys) + "Patch the checksums of the vendored crates after patching their shebangs." + (generate-all-checksums vendor-dir) + #t) + (define* (build #:key skip-build? (cargo-build-flags '("--release")) @@ -162,7 +202,9 @@ (define %standard-phases (replace 'configure configure) (replace 'build build) (replace 'check check) - (replace 'install install))) + (replace 'install install) + (add-after 'configure 'update-cargo-lock update-cargo-lock) + (add-after 'patch-generated-file-shebangs 'patch-cargo-checksums patch-cargo-checksums))) (define* (cargo-build #:key inputs (phases %standard-phases) #:allow-other-keys #:rest args) -- cgit v1.2.3