6 Commits 1d5f997876 ... 7dfb67f6e3

Auteur SHA1 Bericht Datum
  Maxime Devos 7dfb67f6e3 antioxidant-workspaces: Skip 'check' and 'install' by default when there is no Makefile. 2 jaren geleden
  Maxime Devos a022d43f2a libsequoia: Preserve some environment variables within a member. 2 jaren geleden
  Maxime Devos c6fd01cf72 libsequoia: Avoid non-building tests. 2 jaren geleden
  Maxime Devos c13df3dc71 libsequoia: Add various missing inputs. 2 jaren geleden
  Maxime Devos 2810a0bba5 libsequoia: Update to avoid non-building dependency. 2 jaren geleden
  Maxime Devos cb7995a0d8 libsequoia: Set dynamic linking flags. 2 jaren geleden
2 gewijzigde bestanden met toevoegingen van 105 en 19 verwijderingen
  1. 39 10
      antioxidant-packages.scm
  2. 66 9
      antioxidant-workspaces.scm

+ 39 - 10
antioxidant-packages.scm

@@ -175,7 +175,15 @@
      ,#~((add-after 'unpack 'avoid-subplot-build
 	   (lambda _
 	     (substitute* "sq/build.rs"
-	       (("^(.*)[Ss]ubplot(.*)$") ""))))))
+	       (("^(.*)[Ss]ubplot(.*)$") ""))))
+	 (add-after 'unpack 'avoid-build-failure
+	   (lambda _
+	     ;; Something about a 'send' trait.
+	     (for-each delete-file '("sq/tests/sq-certify.rs"
+				     "sq/tests/sq-revoke.rs"
+				     "sq/tests/sq-sign.rs"
+				     ;; TODO: fix OUT_DIR reference?
+				     "sq/tests/sq-subplot.rs"))))))
     ("python-blake3"
      ,#~((add-after 'build 'reduce-closure
 	   (lambda* (#:key outputs #:allow-other-keys)
@@ -270,9 +278,7 @@
      ,#~((add-after 'unpack 'remove-cargo-tests
 	   ;; Assumes Cargo.
 	   (lambda _
-	     (delete-file-recursively "crates/proc_macro_test")))
-	 (delete 'check) ; no makefile (TODO adjust antioxidant-workspaces)
-	 (delete 'install))) ; likewise
+	     (delete-file-recursively "crates/proc_macro_test")))))
     ("rust-arboard"
      ,#~((add-after 'unpack 'rust-image-compatibility
 	   (lambda _
@@ -508,9 +514,7 @@ fn _find_target_dir_unused(out_dir: &Path) -> TargetDir {"
 		     (lambda _
 		       (substitute* "crates/nu-completion/Cargo.toml"
 		         (("indexmap = (.*)$" line)
-			  (string-append line "rustyline = \"9.0.0\"")))))
-		   (delete 'check)
-		   (delete 'install)))
+			  (string-append line "rustyline = \"9.0.0\"")))))))
     ("rust-shadow-rs"
      ,#~((add-after 'unpack 'fixup-source-date-epoch
 	   (lambda _
@@ -5690,12 +5694,17 @@ RFC-compliant `EmailAddress` newtype. ")
       ("rust-system-deps" ,rust-system-deps)))
     ;; TODO: rust-sequoia-... are workspace members, remove.
     ("libsequoia" ; add required inputs for members (some of them are optional though)
-     (("rust-base64" ,(p rust-base64-0.13))
+     (("rust-assert-cmd" ,(p rust-assert-cmd-2))
+      ("rust-base64" ,(p rust-base64-0.13))
       ("rust-bzip2" ,(p rust-bzip2-0.4))
+      ("rust-capnp-rpc" ,(p rust-capnp-rpc-0.13))
       ("rust-chrono" ,(p rust-chrono-0.4))
       ("rust-clap" ,(p rust-clap-2))
+      ("rust-dirs" ,(p rust-dirs-3))
       ("rust-dyn-clone" ,(p rust-dyn-clone-1))
       ("rust-flate2" ,(p rust-flate2-1))
+      ("rust-fs2" ,(p rust-fs2-0.4))
+      ("rust-futures" ,(p rust-futures-0.3))
       ("rust-futures-util" ,(p rust-futures-util-0.3))
       ("rust-http" ,(p rust-http-0.2))
       ("rust-hyper" ,(p rust-hyper-0.14))
@@ -5706,6 +5715,8 @@ RFC-compliant `EmailAddress` newtype. ")
       ("rust-lalrop" ,(p rust-lalrpop-util-0.19))
       ("rust-nettle" ,(p rust-nettle-7))
       ("rust-percent-encoding" ,(p rust-percent-encoding-2))
+      ("rust-predicates " ,(p rust-predicates-2))
+      ("rust-rand" ,(p rust-rand-0.8))
       ("rust-regex" ,(p rust-regex-1))
       ("rust-regex-syntax" ,(p rust-regex-syntax-0.6))
       ("rust-rpassword" ,(p rust-rpassword-5))
@@ -5713,6 +5724,7 @@ RFC-compliant `EmailAddress` newtype. ")
       ("rust-syn" ,(p rust-syn-1))
       ("rust-tempfile" ,(p rust-tempfile-3))
       ("rust-term-size" ,(p rust-term-size-1))
+      ("rust-tokio-util" ,(p rust-tokio-util-0.3))
       ("rust-thiserror" ,(p rust-thiserror-1))
       ("rust-url" ,(p rust-url-2))
       ("rust-xxhash-rust" ,(p rust-xxhash-rust-0.8))
@@ -7898,10 +7910,28 @@ RFC-compliant `EmailAddress` newtype. ")
 (let ((new (vitaminate/auto (@ (gnu packages gnome) librsvg))))
   (set! (@ (gnu packages gnome) librsvg) new))
 
+(use-modules (gnu packages))
 ;; Likewise.
 (let ((new (package
 	    (inherit (vitaminate/auto (@ (gnu packages sequoia) libsequoia)))
-	    (build-system antioxidant-workspace-build-system))))
+	    ;; Update to avoid non-building rust-tokio-util@0.3 dependency.
+	    (source (origin
+		     (method git-fetch)
+		     (uri (git-reference
+			   (url "https://gitlab.com/sequoia-pgp/sequoia.git")
+			   (commit (string-append "openpgp/v" "1.8.0"))))
+		     (sha256
+		      (base32 "1s5yam6prqwrzk0fqyan7gpwlclbini2bmnl1zjnjsdxi8b9cmnr"))
+		     (file-name (git-file-name "sequoia" "1.8.0"))
+		     (patches (search-patches #;"libsequoia-remove-store.patch" ; doesn't apply, TODO still needed?
+			       #;"libsequoia-fix-ffi-Makefile.patch"))))
+	    (build-system antioxidant-workspace-build-system)
+	    ;; TODO: build the "rlib" for tests.
+	    (arguments (list #:override-member-crate-type
+			     #~'(("openpgp-ffi" . "cdylib"))
+			     #:rust-dynamic-library-arguments
+			     ;; TODO: needed?
+			     #~'("-C" "link-args=-rdynamic"))))))
   (set! (@ (gnu packages sequoia) libsequoia) new))
 
 ;; todo: cycle between rust-demo-hack and rust-demo-hack-impl
@@ -8017,7 +8047,6 @@ RFC-compliant `EmailAddress` newtype. ")
 	   ;; Keep old phases, adjusted for antioxidant-build-system.
 	   #~(modify-phases %antioxidant-workspaces-phases
 	       (delete 'configure)
-	       (delete 'check)
 	       (add-after 'build-workspace-members 'build-man-pages
 	         (lambda* (#:key inputs #:allow-other-keys)
 		   (define (scdoc-cmd doc lvl)

+ 66 - 9
antioxidant-workspaces.scm

@@ -34,7 +34,8 @@
 	    %antioxidant-member-extra-phases
 	    %antioxidant-workspaces-phases
 	    call-with-member
-	    with-member))
+	    with-member
+	    capture-per-member-environment))
 
 ;;;
 ;;; Workspaces are built recursively -- each member is built in turn and
@@ -49,24 +50,67 @@
 ;; If the workspace itself is a Rust crate, it is included as ".".
 (define *members* (make-parameter #false))
 
+(define (capture-per-member-environment)
+  "Return an association list of environment variable names / values
+considered specific to the current workspace member.  These should
+be restored when the member is entered again and unset when the
+member is exited."
+  (define %precious
+    ;; Required for libsequoia
+    '("OUT_DIR" "CARGO_MANIFEST_DIR"
+      ;; No known cases where preserving them is required, but seems
+      ;; potentially needed in theoru.
+      "CARGO_PKG_VERSION_MAJOR" "CARGO_PKG_VESION_MINOR"
+      "CARGO_PKG_VERSION_PATCH" "CARGO_PKG_VERSION_PRE" "CARGO_PKG_VERSION"
+      "CARGO_PKG_AUTHORS" "CARGO_PKG_NAME" "CARGO_PKG_DESCRIPTION"
+      "CARGO_PKG_HOMEPAGE" "CARGO_PKG_REPOSITORY" "CARGO_PKG_LICENSE"
+      "CARGO_PKG_LICENSE_FILE"))
+  (define (preserve? v)
+    (define =-index (string-index v #\=))
+    (define key (substring v 0 =-index))
+    (define value (substring v (+ 1 =-index)))
+    (and (member key %precious)
+	 (cons key value)))
+  (filter-map preserve? (environ)))
+
+(define (call-with-member-environment-excursion to-restore thunk)
+  ;; TODO: would be nice if 'environ' was a parameter object
+  (dynamic-wind
+      (lambda ()
+	(for-each (lambda (v)
+		    (setenv (car v) (cdr v)))
+		  to-restore))
+      thunk
+      (lambda ()
+	(for-each (lambda (v)
+		    (unsetenv (car v)))
+		  (capture-per-member-environment)))))
+
+;; Head: environment variables alist.
+;; Tail: argument for 'call-with-reset-state'
 (define *member-state* (make-hash-table))
+
 (define (call-with-member member thunk)
   "Call THUNK in an environment where the state arguments for MEMBER are set.
 If they are not defined yet, they are set to their initial values.  After
 a normal return, the new values of the state arguments are saved for the
 next call to call-with-member."
   (define old-state (hash-ref *member-state* member #false))
-  (define optional-arguments
+  (define-values (old-environment optional-arguments)
     (if old-state
-	(list old-state)
-	'()))
+	(values (car old-state) (list (cdr old-state)))
+	(values '() '())))
   (with-directory-excursion member
     (apply call-with-reset-state
 	   (lambda ()
-	     (thunk)
-	     ;; Save the new state, as the member might need to be re-entered
-	     ;; later.
-	     (hash-set! *member-state* member (capture-state)))
+	     (call-with-member-environment-excursion
+	      old-environment
+	      (lambda ()
+		(thunk)
+		;; Save the new state, as the member might need to be re-entered
+		;; later.
+		(hash-set! *member-state* member
+			   (cons (capture-per-member-environment) (capture-state))))))
 	   optional-arguments)))
 
 (define-syntax-rule (with-member member code code* ...)
@@ -201,6 +245,13 @@ If the workspace itself is a package, it is included as \".\"."
   (format #t "Doing per-workspace member things that might require dev-dependencies~%")
   (for-each do-workspace-member (*members*)))
 
+;; Some workspaces use a Makefile, but not all.
+(define (phase-if-makefile phase-name phase)
+  (lambda arguments
+    (if (file-exists? "Makefile")
+	(apply phase arguments)
+	(format #t "No Makefile exists, skipping ~a phase.~%" phase-name))))
+
 (define %antioxidant-member-main-phases
   (modify-phases %standard-antioxidant-phases
     ;; Delete phases that don't need to be done on a per-member basis.
@@ -241,4 +292,10 @@ If the workspace itself is a package, it is included as \".\"."
     (delete 'patch-generated-file-shebangs)
     (add-after 'build 'build-workspace-members build-workspace-members)
     (add-after 'build-workspace-members 'extra-member-phases extra-member-phases)
-    (delete 'build)))
+    (delete 'build)
+    (replace 'check (phase-if-makefile
+		     'check
+		     (assoc-ref %standard-phases 'check)))
+    (replace 'install (phase-if-makefile
+		       'install
+		       (assoc-ref %standard-phases 'install)))))