important: several revisions, simplifications (this commit is tested and stable)

This commit is contained in:
pls.153 2022-03-17 16:15:32 +01:00
parent fee4358760
commit 5bd6b31630
19 changed files with 216 additions and 324 deletions

View file

@ -19,7 +19,7 @@ PRE_TARGETDEPS += tmp/libapp.a
QT += quick qml
TEMPLATE = app
CONFIG += no_keywords release
DEFINES += INI_LISP INI_ECL_CONTRIB
DEFINES += DESKTOP_APP INI_LISP INI_ECL_CONTRIB
INCLUDEPATH = /usr/local/include
ECL_VERSION = $$lower($$system(ecl -v))
ECL_VERSION = $$replace(ECL_VERSION, " ", "-")
@ -36,12 +36,14 @@ macx: LIBS += -L../../../platforms/macos/lib
android {
QT += androidextras
DEFINES += INI_ASDF
DEFINES -= DESKTOP_APP
INCLUDEPATH = $$(ECL_ANDROID)/include
ECL_VERSION = $$lower($$system($ECL_ANDROID/../ecl-android-host/bin/ecl -v))
ECL_VERSION = $$replace(ECL_VERSION, " ", "-")
LIBS = -L$$(ECL_ANDROID)/lib -lecl
LIBS += -L$$(ECL_ANDROID)/lib/$$ECL_VERSION
LIBS += -lecl-help -ldeflate -lecl-cdb -lecl-curl -lql-minitar -lsockets
LIBS += -lasdf -lecl-help -ldeflate -lecl-cdb -lecl-curl -lql-minitar -lsockets
LIBS += -L../../../platforms/android/lib
ANDROID_ABIS = "arm64-v8a"
@ -50,6 +52,8 @@ android {
}
ios {
DEFINES += INI_ASDF
DEFINES -= DESKTOP_APP
INCLUDEPATH = $$(ECL_IOS)/include
ECL_VERSION = $$lower($$system($ECL_IOS/../ecl-ios-host/bin/ecl -v))
ECL_VERSION = $$replace(ECL_VERSION, " ", "-")

View file

@ -0,0 +1 @@
ecl -shell qml/.create-qml-loaders.lisp

View file

@ -173,11 +173,7 @@
~% :q (quicklisp)")
(values))
(defun ini ()
(x:while (not (find-quick-item ui:*repl-model*))
(qsleep 0.5))
(progn
(ini-streams)
(in-package :qml-user)
(eval-in-thread "(qml::help)" nil))
(qlater 'ini)

View file

@ -2,5 +2,5 @@
(in-package :qml-user)
;; delay needed here
(qsingle-shot 500 (lambda () (eval:eval-in-thread "(qml::help)"))) ; show help in REPL
;; delay needed here because of initial reload
(qsingle-shot 1000 (lambda () (eval:eval-in-thread "(qml::help)"))) ; show help in REPL

View file

@ -2,88 +2,20 @@
(in-package :qml)
;; for mobile app updates:
;; to be incremented on every ECL upgrade in order to replace all asset files
#+(or android ios)
(defconstant +app-version+ 1)
#+(and ios (not interpreter))
#+(and (or android ios) (not interpreter))
(ffi:clines "extern void init_lib_ASDF(cl_object);")
#+(or android ios)
(defvar *assets* #+android "assets:/lib/"
#+ios "assets/")
#+ios
(defvar *bundle-root* (namestring *default-pathname-defaults*))
#+(or android ios)
(defun copy-asset-files (&optional (dir-name *assets*) origin)
"Copy asset files to home directory."
(flet ((directory-p (path)
(x:ends-with "/" path))
(translate (name)
#+android
(if (x:starts-with *assets* name)
(subseq name (length *assets*))
name)
#+ios
(namestring
(merge-pathnames (x:cc "../" (subseq name (length origin)))))))
(ensure-directories-exist (translate dir-name))
;; note: both QDIRECTORY and QCOPY-FILE are prepared for accessing
;; APK asset files, which can't be accessed directly from Lisp
(dolist (from (qdirectory dir-name))
(if (directory-p from)
(copy-asset-files from origin)
(let ((to (translate from)))
(when (probe-file to)
(delete-file to))
(unless (qcopy-file from to)
(qlog "Error copying asset file: ~S" from)
(return-from copy-asset-files))))))
t)
#+(or android ios)
(let ((file ".app-version"))
(defun app-version ()
(if (probe-file file)
(with-open-file (s file)
(let ((str (make-string (file-length s))))
(read-sequence str s)
(values (parse-integer str))))
0))
(defun save-app-version ()
(with-open-file (s file :direction :output :if-exists :supersede)
(princ +app-version+ s))
(values)))
(defun %sym (symbol package)
(intern (symbol-name symbol) package))
;;; Quicklisp setup
#+ios
(defun load-asdf ()
(unless (find-package :asdf)
;; needed for ASDF and Quicklisp
(setf (logical-pathname-translations "SYS")
(list (list "sys:**;*.*"
(merge-pathnames "**/*.*" (user-homedir-pathname)))))
(setf (logical-pathname-translations "HOME")
(list (list "home:**;*.*"
(merge-pathnames "**/*.*" (user-homedir-pathname)))))
(ffi:c-inline nil nil :void "ecl_init_module(NULL, init_lib_ASDF)" :one-liner t)
(in-package :qml-user))
:asdf)
#+(or android ios)
(defun ensure-asdf ()
(unless (find-package :asdf)
#+android
(require :asdf)
#+ios
(load-asdf)))
(ffi:c-inline nil nil :void "ecl_init_module(NULL, init_lib_ASDF)" :one-liner t)
(in-package :qml-user))
:asdf)
#+(or android ios)
(defun quicklisp ()
@ -147,45 +79,6 @@
#+(or android ios)
(export (list #+ios
'load-asdf
'start-swank
'stop-swank
'quicklisp))
#+ios
(progn
;; adapt paths to iOS specific values
(defvar *user-homedir-pathname-orig* (symbol-function 'user-homedir-pathname))
(ext:package-lock :common-lisp nil)
(defun cl:user-homedir-pathname (&optional host)
(merge-pathnames "Library/" (funcall *user-homedir-pathname-orig* host)))
(ext:package-lock :common-lisp t)
(dolist (el '(("XDG_DATA_HOME" . "")
("XDG_CONFIG_HOME" . "")
("XDG_DATA_DIRS" . "")
("XDG_CONFIG_DIRS" . "")
("XDG_CACHE_HOME" . ".cache")))
(ext:setenv (car el) (namestring (merge-pathnames (cdr el)
(user-homedir-pathname))))))
;;; ini
#+(or android ios)
(defun startup-ini ()
#+ios
(setf *default-pathname-defaults* (user-homedir-pathname))
(ext:install-bytecodes-compiler)
(and (/= +app-version+ (app-version))
#+ios
(let ((dir (namestring (merge-pathnames *assets* *bundle-root*))))
(copy-asset-files dir dir))
#+android
(copy-asset-files)
(save-app-version)))
#+(or android ios)
(qlater 'startup-ini)

View file

@ -30,16 +30,9 @@
(let ((to (cc *assets* "quicklisp/local-projects/slime/")))
(ensure-directories-exist to)
(shell (cc "cp -r ../../../slime/src/* " to))))
#+android
(let ((lib (cc (ext:getenv "ECL_ANDROID") "/lib/ecl-*/")))
(shell (cc "cp -f " lib "asdf.fas " *assets*))
(shell (cc (ext:getenv "ANDROID_NDK_TOOLCHAIN") "/bin/aarch64-linux-android-strip " (cc *assets* "asdf.fas")))
(unless (probe-file (cc *assets* "encodings"))
(shell (cc "cp " lib "*.doc " *assets*))
(shell (cc "cp -r " lib "encodings " *assets*))))
#+ios
(unless (probe-file (cc *assets* "encodings"))
(let ((lib (cc (ext:getenv "ECL_IOS") "/lib/ecl-*/")))
(let ((lib (cc (ext:getenv #+android "ECL_ANDROID" #+ios "ECL_IOS")
"/lib/ecl-*/")))
(shell (cc "cp " lib "*.doc " *assets*))
(shell (cc "cp -r " lib "encodings " *assets*)))))

View file

@ -9,7 +9,12 @@ A small demo can be found here: [short video clip](http://cl-repl.org/lqml.htm)
Prepare
-------
Please copy the app template files first:
Run this script once, and every time after adding new qml files:
```
$ ./ini-reload.sh
```
Copy the app template files:
```
$ cd ..
$ ./copy.sh advanced-qml-auto-reload

View file

@ -25,4 +25,3 @@
(when (option "-slime")
(load "~/slime/lqml-start-swank")) ; for 'slime-connect' from Emacs
(load "qml/.create-qml-loaders.lisp")