add app template to simplify creating new apps

This commit is contained in:
pls.153 2022-02-18 11:13:51 +01:00
parent d7e3d7b46f
commit 3770db1756
23 changed files with 101 additions and 1 deletions

View file

@ -1,3 +1,14 @@
Prepare
-------
Please copy the app template files first:
```
$ cd ..
$ ./copy.sh 9999
```
Info Info
---- ----

View file

@ -0,0 +1,2 @@
*
!.gitignore

View file

@ -0,0 +1,2 @@
(in-package :app)

View file

@ -0,0 +1,4 @@
(defpackage :app
(:use :cl :qml)
(:export))

View file

@ -0,0 +1,6 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import Lisp 1.0
Item {
}

View file

@ -38,6 +38,8 @@ $ make apk
$ ./install.sh $ ./install.sh
``` ```
Log note: for showing only your own messages, see `log.sh`.
Build iOS app Build iOS app
@ -65,4 +67,4 @@ Please note:
If you cross-compiled ECL for the simulator, it should work there too, but this If you cross-compiled ECL for the simulator, it should work there too, but this
is currently only tested on **Intel**. is currently only tested on **Intel**.
Simulator note: ensure the virtual keyboard is shown, see keys `cmd-k`. Simulator note: to show the virtual keyboard, use `cmd-k`.

View file

@ -0,0 +1,14 @@
Run
---
```
lqml run.lisp
```
Optionally pass `-slime` to start a Swank server, and connect from Emacs with
`M-x slime-connect`.
Closing the window quits the app. If you try to kill it with `ctrl-c`, you need
an additional `ctrl-d` to exit from ECL. To quit from Slime, do `(qq)` which is
short for `(qquit)`.

View file

@ -0,0 +1,52 @@
;;; copies all template files to new directory passed as app name
(defvar *name* (first (last (ext:command-args))))
(when (search "copy-template" *name*)
(print "Usage: ecl -shell copy-template.lisp <name>.")
(terpri)
(ext:quit))
(defun string-substitute (new old string)
(let ((len (length old)))
(with-output-to-string (s)
(do ((e (search old string) (search old string :start2 (+ e len)))
(b 0 (+ e len)))
((not e) (write-string (subseq string b) s))
(write-string (subseq string b e) s)
(write-string new s)))))
(defun copy-stream (from to)
(let ((buf (make-array 8192 :element-type (stream-element-type from))))
(loop
(let ((pos (read-sequence buf from)))
(when (zerop pos)
(return))
(write-sequence buf to :end pos))))
(values))
(defun copy-file (from to)
(let ((element-type '(unsigned-byte 8)))
(with-open-file (in from :element-type element-type)
(with-open-file (out to :element-type element-type
:direction :output :if-exists :supersede)
(copy-stream in out)
(finish-output out)
(= (file-length in)
(file-length out))))))
(dolist (file (directory "app-template/**/*.*"))
(let* ((from (namestring file))
(to (string-substitute (format nil "/~A/" *name*)
"/app-template/"
from)))
(if (probe-file to)
(format t "~&skipping exisitng file: ~A" to)
(progn
(format t "~&copying file: ~A" to)
(ensure-directories-exist to)
(unless (copy-file from to)
(error "File ~A could not be copied." to))))))
(terpri)

1
examples/copy.sh Executable file
View file

@ -0,0 +1 @@
ecl -shell copy-template.lisp $1

6
examples/readme.md Normal file
View file

@ -0,0 +1,6 @@
To add a new app from the template, run:
```
$ ecl -shell copy-template.lisp <name>
```