From f1d136957d0d5634e60e5389a046a917169cdb9e Mon Sep 17 00:00:00 2001 From: David Craven Date: Thu, 29 Dec 2016 16:29:24 +0100 Subject: build-system: cargo: Handle Cargo.lock file not present. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * guix/build-system/cargo.scm (cargo-build): Add src output. (private-keywords): Add #:outputs. * guix/build/cargo-build-system.scm (configure): Use /share/rust-source when replacing inputs. (build, check): Don't do anything when there isn't a Cargo.lock file present. (install): Install sources to src output. When a Cargo.lock file is present use cargo install to install binaries to out. * guix/import/crate.scm (make-crate-sexp): Importer uses the src output for crate inputs by default. * guix/import/utils.scm (package-names->package-inputs, maybe-inputs, maybe-native-inputs): Take an optional output argument. * tests/crate.scm (crate->guix-package test): Update. Problem reported by Francisco Gómez García . --- guix/build/cargo-build-system.scm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'guix/build/cargo-build-system.scm') diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm index 4fa29b4cd3..7d656a8d58 100644 --- a/guix/build/cargo-build-system.scm +++ b/guix/build/cargo-build-system.scm @@ -54,7 +54,7 @@ (when (and crate path) (match (string-split (basename path) #\-) ((_ ... version) - (format port "\"~a:~a\" = { path = \"~a/rustsrc\" }~%" + (format port "\"~a:~a\" = { path = \"~a/share/rust-source\" }~%" crate version path))))))) inputs) (close-port port)) @@ -63,19 +63,22 @@ (define* (build #:key (cargo-build-flags '("--release" "--frozen")) #:allow-other-keys) "Build a given Cargo package." - (zero? (apply system* `("cargo" "build" ,@cargo-build-flags)))) + (if (file-exists? "Cargo.lock") + (zero? (apply system* `("cargo" "build" ,@cargo-build-flags))) + #t)) (define* (check #:key tests? #:allow-other-keys) "Run tests for a given Cargo package." - (when tests? - (zero? (system* "cargo" "test")))) + (if (and tests? (file-exists? "Cargo.lock")) + (zero? (system* "cargo" "test")) + #t)) (define* (install #:key inputs outputs #:allow-other-keys) "Install a given Cargo package." (let* ((out (assoc-ref outputs "out")) (src (assoc-ref inputs "source")) - (bin (string-append out "/bin")) - (rsrc (string-append out "/rustsrc"))) + (rsrc (string-append (assoc-ref outputs "src") + "/share/rust-source"))) (mkdir-p rsrc) ;; Rust doesn't have a stable ABI yet. Because of this ;; Cargo doesn't have a search path for binaries yet. @@ -87,8 +90,9 @@ ;; When the package includes executables we install ;; it using cargo install. This fails when the crate ;; doesn't contain an executable. - (system* "cargo" "install" "--root" bin) - #t)) + (if (file-exists? "Cargo.lock") + (system* "cargo" "install" "--root" out) + (mkdir out)))) (define %standard-phases ;; 'configure' phase is not needed. -- cgit v1.2.3