about summary refs log tree commit diff
path: root/third_party/lisp
diff options
context:
space:
mode:
authorsterni <sternenseemann@systemli.org>2021-08-02T13·15+0200
committersterni <sternenseemann@systemli.org>2021-09-01T22·57+0000
commit8f6955176ffb216e996b0b9548127045b85522c0 (patch)
tree5d3a5169fb88416130290a0e01618e406878afe7 /third_party/lisp
parent901364869c4e404df0a7c0e80cfd080a56f1965e (diff)
feat(3p/lisp/mime4cl): build using buildLisp r/2815
The following changes are required to make mime4cl build:

* file-position doesn't like to be called with NIL as the position
  argument, so we have to make sure to not do that in
  stream-file-position. My workaround is a bit clunky, but works.

* Tests discover the sample file via relative path resolution. This
  doesn't work when they are imported into the nix store as individual
  files. Instead we make use of the fact that DEFVAR is a no-op if the
  variable is already defined and inject a file via the nix build that
  sets the relevant ones. For the path to sample1.msg, we need to create
  a new variable.

Change-Id: I74eeda7bf2c2a4f64cc2b90e72081513ec3285d5
Reviewed-on: https://cl.tvl.fyi/c/depot/+/3270
Tested-by: BuildkiteCI
Reviewed-by: grfn <grfn@gws.fyi>
Diffstat (limited to 'third_party/lisp')
-rw-r--r--third_party/lisp/mime4cl/.skip-subtree1
-rw-r--r--third_party/lisp/mime4cl/OWNERS3
-rw-r--r--third_party/lisp/mime4cl/README7
-rw-r--r--third_party/lisp/mime4cl/default.nix48
-rw-r--r--third_party/lisp/mime4cl/streams.lisp4
-rw-r--r--third_party/lisp/mime4cl/test/mime.lisp11
6 files changed, 69 insertions, 5 deletions
diff --git a/third_party/lisp/mime4cl/.skip-subtree b/third_party/lisp/mime4cl/.skip-subtree
new file mode 100644
index 000000000000..5051f60d6b86
--- /dev/null
+++ b/third_party/lisp/mime4cl/.skip-subtree
@@ -0,0 +1 @@
+prevent readTree from creating entries for subdirs that don't contain an .nix files
diff --git a/third_party/lisp/mime4cl/OWNERS b/third_party/lisp/mime4cl/OWNERS
new file mode 100644
index 000000000000..f16dd105d761
--- /dev/null
+++ b/third_party/lisp/mime4cl/OWNERS
@@ -0,0 +1,3 @@
+inherited: true
+owners:
+  - sterni
diff --git a/third_party/lisp/mime4cl/README b/third_party/lisp/mime4cl/README
new file mode 100644
index 000000000000..73f0efbda9d5
--- /dev/null
+++ b/third_party/lisp/mime4cl/README
@@ -0,0 +1,7 @@
+MIME4CL is a Common Lisp library for dealing with MIME messages.
+It has originally been written by Walter C. Pelissero and vendored
+into depot as upstream has become inactive and provides no repo
+of any kind. Upstream and depot version may diverge.
+
+Upstream Website: http://wcp.sdf-eu.org/software/#mime4cl
+Vendored Tarball: http://wcp.sdf-eu.org/software/mime4cl-20150207T211851.tbz
diff --git a/third_party/lisp/mime4cl/default.nix b/third_party/lisp/mime4cl/default.nix
new file mode 100644
index 000000000000..5165774074c1
--- /dev/null
+++ b/third_party/lisp/mime4cl/default.nix
@@ -0,0 +1,48 @@
+# Copyright (C) 2021 by the TVL Authors
+# SPDX-License-Identifier: LGPL-2.1-or-later
+{ depot, pkgs, ... }:
+
+depot.nix.buildLisp.library {
+  name = "mime4cl";
+
+  deps = [
+    depot.third_party.lisp.sclf
+    depot.third_party.lisp.npg
+  ];
+
+  srcs = [
+    ./package.lisp
+    ./endec.lisp
+    ./streams.lisp
+    ./mime.lisp
+    ./address.lisp
+  ];
+
+  tests = {
+    name = "mime4cl-tests";
+
+    srcs = [
+      ./test/rt.lisp
+      ./test/package.lisp
+      (pkgs.writeText "nix-samples.lisp" ''
+        (in-package :mime4cl-tests)
+
+        ;; missing from the tarball completely
+        (defvar *samples-directory* (pathname "/this/does/not/exist"))
+        ;; override auto discovery which doesn't work in store
+        (defvar *sample1-file* (pathname "${./test/sample1.msg}"))
+      '')
+      ./test/endec.lisp
+      ./test/address.lisp
+      ./test/mime.lisp
+    ];
+
+    expression = "(rtest:do-tests)";
+  };
+
+  # limited by sclf
+  brokenOn = [
+    "ccl"
+    "ecl"
+  ];
+}
diff --git a/third_party/lisp/mime4cl/streams.lisp b/third_party/lisp/mime4cl/streams.lisp
index 4b3da19a9905..64c7adeec571 100644
--- a/third_party/lisp/mime4cl/streams.lisp
+++ b/third_party/lisp/mime4cl/streams.lisp
@@ -1,6 +1,7 @@
  ;;; eds.lisp --- En/De-coding Streams
 
  ;;; Copyright (C) 2012 by Walter C. Pelissero
+ ;;; Copyright (C) 2021 by the TVL Authors
 
  ;;; Author: Walter C. Pelissero <walter@pelissero.de>
  ;;; Project: mime4cl
@@ -63,7 +64,8 @@
 	       :initarg :dont-close)))
 
 (defmethod stream-file-position ((stream coder-stream-mixin) &optional position)
-  (file-position (slot-value stream 'real-stream) position))
+  (apply #'file-position (remove nil (list (slot-value stream 'real-stream)
+                                           position))))
 
 (defclass coder-input-stream-mixin (fundamental-binary-input-stream coder-stream-mixin)
   ())
diff --git a/third_party/lisp/mime4cl/test/mime.lisp b/third_party/lisp/mime4cl/test/mime.lisp
index d1a56b0c0433..1488f927fcd3 100644
--- a/third_party/lisp/mime4cl/test/mime.lisp
+++ b/third_party/lisp/mime4cl/test/mime.lisp
@@ -1,6 +1,7 @@
  ;;; mime.lisp --- MIME regression tests
 
  ;;; Copyright (C) 2012 by Walter C. Pelissero
+ ;;; Copyright (C) 2021 by the TVL Authors
 
  ;;; Author: Walter C. Pelissero <walter@pelissero.de>
  ;;; Project: mime4cl
@@ -28,11 +29,13 @@
 			 *load-pathname*
 			 #P"")))
 
+(defvar *sample1-file* (make-pathname :defaults #.(or *compile-file-pathname*
+                                                      *load-pathname*)
+                                      :name "sample1"
+                                      :type "msg"))
+
 (deftest mime.1
-    (let* ((orig (mime-message (make-pathname :defaults #.(or *compile-file-pathname*
-							   *load-pathname*)
-					   :name "sample1"
-					   :type "msg")))
+    (let* ((orig (mime-message *sample1-file*))
 	   (dup (mime-message (with-output-to-string (out) (encode-mime-part orig out)))))
       (mime= orig dup))
   t)