changelog shortlog graph tags branches changeset files revisions annotate raw help

Mercurial > demo / tk.lisp

changeset 6: 3d202b181d6c
parent: 4230ce61dcfa
child: 315fedf35bc7
author: ellis <ellis@rwest.io>
date: Sun, 07 May 2023 01:32:31 -0400
permissions: -rw-r--r--
description: tkup
1 (in-package #:demo)
2 
3 (defvar *cargo-target* #P"/Users/ellis/dev/otom8/demo/target/")
4 
5 (defmacro find-rust-dll (name &optional debug)
6  "Find the rust dll specified by NAME."
7  (cond
8  ((uiop:directory-exists-p (merge-pathnames *cargo-target* "release"))
9  `,(mkstr "./target/release/" name))
10  ((uiop:directory-exists-p (merge-pathnames *cargo-target* "debug"))
11  `,(mkstr "./target/debug/" name))
12  (t (progn
13  (uiop:run-program `("cargo" "build" ,(unless debug "--release")) :output t)
14  `,(find-rust-dll name debug)))))
15 
16 (defun random-id ()
17  (format NIL "~8,'0x-~8,'0x" (random #xFFFFFFFF) (get-universal-time)))
18 
19 (defun scan-dir (dir filename callback)
20  (dolist (path (directory (merge-pathnames (merge-pathnames filename "**/") dir)))
21  (funcall callback path)))
22 
23 (defun mkstr (&rest args)
24  (with-output-to-string (s)
25  (dolist (a args) (princ a s))))
26 
27 (defun symb (&rest args)
28  (values (intern (apply #'mkstr args))))
29 
30 (defun sbq-reader (stream sub-char numarg)
31  "The anaphoric sharp-backquote reader: #`((,a1))"
32  (declare (ignore sub-char))
33  (unless numarg (setq numarg 1))
34  `(lambda ,(loop for i from 1 to numarg
35  collect (symb 'a i))
36  ,(funcall
37  (get-macro-character #\`) stream nil)))
38 
39 (eval-when (:execute)
40  (set-dispatch-macro-character
41  #\# #\` #'demo:sbq-reader))