important: fix ASDF cross-compiling to work properly (should now work with any library)

This commit is contained in:
pls.153 2022-03-14 21:54:00 +01:00
parent 14b5eff7ea
commit 97606681db
14 changed files with 125 additions and 157 deletions

View file

@ -6,5 +6,6 @@
(:file "lisp/swank-quicklisp")
(:file "lisp/eval")
(:file "lisp/qml-reload/auto-reload-mobile")
(:file "lisp/curl")
(:file "lisp/main")))

View file

@ -21,9 +21,7 @@
#+(or android ios)
(defun load* (file)
(load (make-string-input-stream
(funcall (%sym 'curl :qml)
(x:cc *remote-ip* file)))))
(load (make-string-input-stream (curl (x:cc *remote-ip* file)))))
(export 'load*)
@ -46,18 +44,11 @@
(setf *reload-all* nil))))
#+(or android ios)
(let ((load t)
(secs 0)
(let ((secs 0)
(ini t))
(defun auto-reload-qml ()
(when load
(setf load nil)
(require :ecl-curl)
(load "curl"))
(let ((curr/file (ignore-errors
(x:split (funcall (%sym 'curl :qml)
(x:cc *remote-ip*
"cgi-bin/qml-last-modified.py"))
(x:split (curl (x:cc *remote-ip* "cgi-bin/qml-last-modified.py"))
#.(coerce (list #\Return #\Newline) 'string)))))
(when (= 2 (length curr/file))
(destructuring-bind (curr file)

View file

@ -68,38 +68,31 @@
(load (merge-pathnames file "src/lisp/")))
#-(or android ios)
(progn
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
(let* ((from (cc *current* "build/tmp/app--all-systems.a"))
(to "libapp.a")
(to* (cc *current* "build/tmp/" to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to)))
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
#+(or android ios)
(progn
(pushnew :interpreter *features*)
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-name* (format nil "~Abuild-~A/tmp/app"
*current*
#+android "android"
#+ios "ios"))
(defvar *epilogue-code* nil)
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-path* (format nil "~Abuild-~A/tmp/"
*current*
#+android "android"
#+ios "ios"))
(defvar *require* (list :ecl-curl))
(load "platforms/shared/make"))
;;; byte compile curl (delayed load)
#+(or android ios)
(progn
(require :ecl-curl)
(ext:install-bytecodes-compiler)
(compile-file (cc *current* "lisp/curl.lisp")
:output-file (cc *current* "lisp/" *assets* "curl.fasc")))
;; rename lib
(let* ((from #-(or android ios) (cc *current* "build/tmp/app--all-systems.a")
#+(or android ios) (cc *library-path* "app--all-systems.a"))
(to "libapp.a")
(to* #-(or android ios) (cc *current* "build/tmp/" to)
#+(or android ios) (cc *library-path* to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to))

View file

@ -72,12 +72,10 @@ Important notes for mobile
Please remember that installing a new version of your app on mobile will
**keep all app data** present on the device.
So, if you changed e.g. `lisp/curl.lisp` (loaded on demand, not compiled into
the app), a simple update will not replace that file, because it has been
copied from the assets directory, and is only replaced if you increment
`+app-version+` in `lisp/swank-quicklisp.lisp`.
The same goes for all files under `./platforms/.../assets/...`.
So, if you changed e.g. your Slime version under `platforms/<platform>/assets/,
an update will not replace those files, because they have been copied from the
assets on the first start of the app. If you want to replace them, you need to
increase `+app-version+` in `lisp/swank-quicklisp.lisp`.
A simple way to guarantee a clean install is simply uninstalling the app first,
both on the device and on the emulator (android) or simulator (iOS).

View file

@ -1,3 +1,5 @@
;;; check target
(let ((arg (first (ext:command-args))))
(mapc (lambda (name feature)
(when (search name arg)
@ -27,28 +29,31 @@
(apply 'concatenate 'string args))
#-(or android ios)
(progn
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
(let* ((from (cc *current* "build/tmp/app--all-systems.a"))
(to "libapp.a")
(to* (cc *current* "build/tmp/" to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to)))
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
#+(or android ios)
(progn
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-name* (format nil "~Abuild-~A/tmp/app"
*current*
#+android "android"
#+ios "ios"))
(defvar *epilogue-code* nil)
(pushnew :interpreter *features*)
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-path* (format nil "~Abuild-~A/tmp/"
*current*
#+android "android"
#+ios "ios"))
(defvar *require* (list :ecl-curl))
(load "platforms/shared/make"))
;; rename lib
(let* ((from #-(or android ios) (cc *current* "build/tmp/app--all-systems.a")
#+(or android ios) (cc *library-path* "app--all-systems.a"))
(to "libapp.a")
(to* #-(or android ios) (cc *current* "build/tmp/" to)
#+(or android ios) (cc *library-path* to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to))

View file

@ -6,5 +6,6 @@
(:file "lisp/swank-quicklisp")
(:file "lisp/eval")
(:file "lisp/qml-reload/auto-reload-mobile")
(:file "lisp/curl")
(:file "lisp/main")))

View file

@ -17,9 +17,7 @@
#+(or android ios)
(defun load* (file)
(load (make-string-input-stream
(funcall (%sym 'curl :qml)
(x:cc *remote-ip* file)))))
(load (make-string-input-stream (curl (x:cc *remote-ip* file)))))
(export 'load*)
@ -29,18 +27,12 @@
(load* "lisp/qml-reload/on-reloaded.lisp")))
#+(or android ios)
(let ((load t)
(secs 0)
(let ((secs 0)
(ini t))
(defun auto-reload-qml ()
(when load
(setf load nil)
(require :ecl-curl)
(load "curl"))
(let ((curr (ignore-errors
(parse-integer
(funcall (%sym 'curl :qml)
(x:cc *remote-ip* "cgi-bin/qml-last-modified.py"))))))
(curl (x:cc *remote-ip* "cgi-bin/qml-last-modified.py"))))))
(when (and curr (/= secs curr))
(when (plusp secs)
(if ini

View file

@ -68,38 +68,31 @@
(load (merge-pathnames file "src/lisp/")))
#-(or android ios)
(progn
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
(let* ((from (cc *current* "build/tmp/app--all-systems.a"))
(to "libapp.a")
(to* (cc *current* "build/tmp/" to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to)))
(asdf:make-build "app"
:monolithic t
:type :static-library
:move-here (cc *current* "build/tmp/")
:init-name "ini_app")
#+(or android ios)
(progn
(pushnew :interpreter *features*)
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-name* (format nil "~Abuild-~A/tmp/app"
*current*
#+android "android"
#+ios "ios"))
(defvar *epilogue-code* nil)
(defvar *asdf-system* "app")
(defvar *ql-libs* (cc *current* "ql-libs.lisp"))
(defvar *init-name* "ini_app")
(defvar *library-path* (format nil "~Abuild-~A/tmp/"
*current*
#+android "android"
#+ios "ios"))
(defvar *require* (list :ecl-curl))
(load "platforms/shared/make"))
;;; byte compile curl (delayed load)
#+(or android ios)
(progn
(require :ecl-curl)
(ext:install-bytecodes-compiler)
(compile-file (cc *current* "lisp/curl.lisp")
:output-file (cc *current* "lisp/" *assets* "curl.fasc")))
;; rename lib
(let* ((from #-(or android ios) (cc *current* "build/tmp/app--all-systems.a")
#+(or android ios) (cc *library-path* "app--all-systems.a"))
(to "libapp.a")
(to* #-(or android ios) (cc *current* "build/tmp/" to)
#+(or android ios) (cc *library-path* to)))
(when (probe-file to*)
(delete-file to*))
(rename-file from to))

View file

@ -90,9 +90,10 @@ Important notes for mobile
Please remember that installing a new version of your app on mobile will
**keep all app data** present on the device.
So, if you changed e.g. `lisp/curl.lisp`, a simple update will not replace
that file, because it has been copied from the assets directory, and is only
replaced if you increment `+app-version+` in `lisp/swank-quicklisp.lisp`.
So, if you changed e.g. your Slime version under `platforms/<platform>/assets/,
an update will not replace those files, because they have been copied from the
assets on the first start of the app. If you want to replace them, you need to
increase `+app-version+` in `lisp/swank-quicklisp.lisp`.
A simple way to guarantee a clean install is simply uninstalling the app first,
both on the device and on the emulator (android) or simulator (iOS).

View file

@ -1,9 +1,23 @@
;;; cross-compile ASDF system, using the byte-codes compiler
;;; as an intermediate step
;; optional vars, to be set in 'make.lisp' in your app dir
(defvar *epilogue-code* nil)
(defvar *ql-libs* nil)
(in-package :cl-user)
(dolist (lib *require*)
(require lib))
;; optional, to be set in 'make.lisp' in your app dir
(defvar *ql-libs* nil)
(defun cc (&rest args)
(apply 'concatenate 'string args))
(let* ((cache (namestring asdf:*user-cache*))
(p (search "/ecl" cache)))
(setf asdf:*user-cache*
(pathname (cc (subseq cache 0 p)
"/ecl-" #+android "android" #+ios "ios"
(subseq cache (+ 4 p))))))
;;; *** (1) byte-compile ASDF system ***
@ -15,22 +29,12 @@
(when (probe-file quicklisp-init)
(load quicklisp-init))))
;;; load ASDF system and collect file names
;;; load ASDF system
(defvar *source-files* nil)
(defmethod asdf:perform ((o asdf:load-op) (c asdf:cl-source-file))
(let ((source (namestring (asdf:component-pathname c))))
(push (subseq source 0 (position #\. source :from-end t))
*source-files*))
(asdf::perform-lisp-load-fasl o c))
(load *ql-libs*) ; eventual dependencies
(load *ql-libs*) ; eventual, not yet installed dependencies
(asdf:load-system *asdf-system*)
(setf *source-files* (nreverse *source-files*))
;;; *** (2) cross-compile ***
;;; load and prepare cross-compiler
@ -39,9 +43,6 @@
(setf *features* (remove :interpreter *features*))
(defun cc (&rest args)
(apply 'concatenate 'string args))
#+(or android ios)
(load (merge-pathnames (format nil "platforms/~A/cross-compile"
#+android "android"
@ -58,29 +59,19 @@
(load (merge-pathnames "src/lisp/tr.lisp")) ; i18n
(setf *break-on-signals* 'error)
(in-package :asdf/lisp-action)
;;; compile/link manually (byte-compiled version is already loaded)
(defmethod asdf:perform ((o asdf:load-op) (c asdf:cl-source-file))
(if-let (fasl (first (input-files o c)))
(progn
;; load above compiled .fasc instead of cross-compiled .fas
(setf fasl (cl-user::cc (namestring fasl) "c"))
(load fasl))))
(defvar *object-files* nil)
(dolist (file *source-files*)
(let ((src (cc file ".lisp"))
(obj (merge-pathnames (format nil "src/.cache/ecl~A-~A/~A.o"
(lisp-implementation-version)
*architecture*
file))))
(when (or (not (probe-file obj))
(> (file-write-date src)
(file-write-date obj)))
(ensure-directories-exist obj)
(compile-file src :output-file obj :system-p t))
(push obj *object-files*)))
(setf *object-files* (nreverse *object-files*))
(c:build-static-library *library-name*
:lisp-files *object-files*
:init-name *init-name*
:epilogue-code *epilogue-code*)
(in-package :cl-user)
(asdf:make-build *asdf-system*
:monolithic t
:type :static-library
:move-here *library-path*
:init-name *init-name*)

View file

@ -2,9 +2,10 @@
Important note
--------------
* **Lisp**: the cross-compile cache is `src/.cache`. Please remember to purge
it if you want to rebuild everything after any change to your ECL version
(read: not all changes to ECL are caught automatically).
* **Lisp**: the cross-compile cache is
`~/.cache/commmon-lisp/ecl-<target-platform>...`. Please remember to purge it
if you want to rebuild everything after any change to your ECL version (read:
not all changes to ECL are caught automatically).
* **Qt**: in the above case, a `make clean` will also force the recompilation
of any Lisp code next time you do a build.

View file

@ -38,8 +38,7 @@ Build cross-compiled ECL for android
------------------------------------
To build the cross-compiled ECL **aarch64**, just use the 2 scripts included in
this project. As of February 2022, please use latest ECL from development
branch.
this project. As of March 2022, please use latest ECL from development branch.
* extract a fresh copy of the ECL sources in e.g. `~/ecl`, and rename
`ecl-21.2.1` to `android`

View file

@ -15,6 +15,8 @@ immediately in your current terminal session.)
Build cross-compiled ECL for iOS
--------------------------------
As of March 2022, please use latest ECL from development branch.
* extract a fresh copy of the ECL sources in e.g. `~/ecl`, and rename
`ecl-21.2.1` to `ios`
* copy the 2 scripts from [platforms/ios/build-ecl/](platforms/ios/build-ecl/)

View file

@ -7,7 +7,7 @@
#include <QQuickView>
#include <QDebug>
const char LQML::version[] = "22.3.3"; // Mar 2022
const char LQML::version[] = "22.3.4"; // Mar 2022
extern "C" void ini_LQML(cl_object);