From e0c4d1c7f4f7317b9d1ae43851579b67e7c044bf Mon Sep 17 00:00:00 2001 From: "pls.153" Date: Fri, 18 Mar 2022 07:59:44 +0100 Subject: [PATCH] revisions --- examples/advanced-qml-auto-reload/app.asd | 2 ++ .../lisp/qml-reload/auto-reload-mobile.lisp | 15 +++-------- .../lisp/swank-quicklisp.lisp | 9 +------ examples/advanced-qml-auto-reload/make.lisp | 25 +++++++++++-------- examples/advanced-qml-auto-reload/readme.md | 4 +-- examples/app-template/make.lisp | 15 ++++++----- examples/swank-server/app.asd | 2 ++ .../lisp/qml-reload/auto-reload-mobile.lisp | 12 +++------ .../swank-server/lisp/swank-quicklisp.lisp | 9 +------ examples/swank-server/lisp/ui-vars.lisp | 2 ++ examples/swank-server/make.lisp | 25 +++++++++++-------- examples/swank-server/qml/main.qml | 1 + platforms/shared/make.lisp | 1 - slime/src/readme-sources.md | 2 +- src/lisp/ini.lisp | 7 ++++-- src/make.lisp | 7 ++++-- 16 files changed, 65 insertions(+), 73 deletions(-) diff --git a/examples/advanced-qml-auto-reload/app.asd b/examples/advanced-qml-auto-reload/app.asd index 1a11563..ae9a056 100644 --- a/examples/advanced-qml-auto-reload/app.asd +++ b/examples/advanced-qml-auto-reload/app.asd @@ -3,8 +3,10 @@ :depends-on () :components ((:file "lisp/package") (:file "lisp/ui-vars") + #+mobile (:file "lisp/swank-quicklisp") (:file "lisp/eval") + #+mobile (:file "lisp/qml-reload/auto-reload-mobile") (:file "lisp/curl") (:file "lisp/main"))) diff --git a/examples/advanced-qml-auto-reload/lisp/qml-reload/auto-reload-mobile.lisp b/examples/advanced-qml-auto-reload/lisp/qml-reload/auto-reload-mobile.lisp index c8fe057..2d6200b 100644 --- a/examples/advanced-qml-auto-reload/lisp/qml-reload/auto-reload-mobile.lisp +++ b/examples/advanced-qml-auto-reload/lisp/qml-reload/auto-reload-mobile.lisp @@ -2,11 +2,9 @@ (in-package :qml) -#+(or android ios) (defvar *reload-all* nil) (defvar *edited-file* nil) -#+(or android ios) (defun remote-ip () (terpri *query-io*) (princ "Please enter WiFi IP of desktop computer (hit RET to skip): " @@ -15,27 +13,20 @@ (unless (x:empty-string ip) (format nil "http://~A:8080/" ip)))) -#+(or android ios) (defvar *remote-ip* #+interpreter nil #-interpreter #.(remote-ip)) -#+(or android ios) (defun load* (file) (load (make-string-input-stream (curl (x:cc *remote-ip* file))))) -(export 'load*) - -#+(or android ios) (defun load-on-reloaded () (load* "lisp/qml-reload/on-reloaded.lisp")) -#+(or android ios) (defun qml:view-status-changed (status) (when (and (= 1 status) (reload-main-p)) (load-on-reloaded))) -#+(or android ios) (defun reload-main-p () (prog1 (or *reload-all* @@ -43,7 +34,6 @@ (when (eql :once *reload-all*) (setf *reload-all* nil)))) -#+(or android ios) (let ((secs 0) (ini t)) (defun auto-reload-qml () @@ -70,5 +60,6 @@ (setf secs curr))))) (qsingle-shot 250 'auto-reload-qml))) -#+(or android ios) -(export 'auto-reload-qml) +(export + (list 'load* + 'auto-reload-qml)) diff --git a/examples/advanced-qml-auto-reload/lisp/swank-quicklisp.lisp b/examples/advanced-qml-auto-reload/lisp/swank-quicklisp.lisp index d9389e2..f15249d 100644 --- a/examples/advanced-qml-auto-reload/lisp/swank-quicklisp.lisp +++ b/examples/advanced-qml-auto-reload/lisp/swank-quicklisp.lisp @@ -2,7 +2,7 @@ (in-package :qml) -#+(and (or android ios) (not interpreter)) +#-interpreter (ffi:clines "extern void init_lib_ASDF(cl_object);") (defun %sym (symbol package) @@ -10,14 +10,12 @@ ;;; Quicklisp setup -#+(or android ios) (defun ensure-asdf () (unless (find-package :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 () (ensure-asdf) (unless (find-package :quicklisp) @@ -36,7 +34,6 @@ ;;; Swank setup -#+(or android ios) (defun swank/create-server (interface port dont-close style) (funcall (%sym 'create-server :swank) :interface interface @@ -44,7 +41,6 @@ :dont-close dont-close :style style)) -#+(or android ios) (defun start-swank (&key (port 4005) (interface "0.0.0.0") (style :spawn) (load-contribs t) (setup t) (delete t) (quiet t) (dont-close t) log-events) @@ -64,20 +60,17 @@ "SLIME-listener" (lambda () (swank/create-server interface port dont-close style))))) -#+(or android ios) (defun stop-swank (&optional (port 4005)) (when (find-package :swank) (funcall (%sym 'stop-server :swank) port) :stopped)) -#+(or android ios) (progn ;; be careful not to use :s, :q in your mobile app code ;; ios simulator note: wrap :s and :q in qrun* (would crash otherwise) (define-symbol-macro :s (start-swank)) (define-symbol-macro :q (quicklisp))) -#+(or android ios) (export (list #+ios 'start-swank 'stop-swank diff --git a/examples/advanced-qml-auto-reload/make.lisp b/examples/advanced-qml-auto-reload/make.lisp index d937c4f..3cca949 100644 --- a/examples/advanced-qml-auto-reload/make.lisp +++ b/examples/advanced-qml-auto-reload/make.lisp @@ -7,24 +7,27 @@ (list "/ecl-android/" "/ecl-ios/") (list :android :ios))) +#+(or android ios) +(pushnew :mobile *features*) + ;;; copy Swank and ECL contrib files (mobile only) (defun cc (&rest args) (apply 'concatenate 'string args)) -#+(or android ios) +#+mobile (defvar *assets* #+android "../platforms/android/assets/lib/" #+ios "../platforms/ios/assets/Library/") -#+(or android ios) +#+mobile (defun find-swank () (probe-file (cc *assets* "quicklisp/local-projects/slime/swank.lisp"))) -#+(or android ios) +#+mobile (defun shell (command) (ext:run-program "sh" (list "-c" command))) -#+(or android ios) +#+mobile (progn (unless (find-swank) (let ((to (cc *assets* "quicklisp/local-projects/slime/"))) @@ -36,7 +39,7 @@ (shell (cc "cp " lib "*.doc " *assets*)) (shell (cc "cp -r " lib "encodings " *assets*))))) -#+(or android ios) +#+mobile (unless (find-swank) (error "Swank files missing, please see /slime/src/readme-sources.md")) @@ -59,7 +62,7 @@ (dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols (load (merge-pathnames file "src/lisp/"))) -#-(or android ios) +#-mobile (progn (require :ecl-curl) (asdf:make-build "app" @@ -68,7 +71,7 @@ :move-here (cc *current* "build/tmp/") :init-name "ini_app")) -#+(or android ios) +#+mobile (progn (pushnew :interpreter *features*) (defvar *asdf-system* "app") @@ -83,11 +86,11 @@ ;;; 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")) +(let* ((from #-mobile (cc *current* "build/tmp/app--all-systems.a") + #+mobile (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))) + (to* #-mobile (cc *current* "build/tmp/" to) + #+mobile (cc *library-path* to))) (when (probe-file to*) (delete-file to*)) (rename-file from to)) diff --git a/examples/advanced-qml-auto-reload/readme.md b/examples/advanced-qml-auto-reload/readme.md index e26771b..7507dc5 100644 --- a/examples/advanced-qml-auto-reload/readme.md +++ b/examples/advanced-qml-auto-reload/readme.md @@ -20,8 +20,8 @@ $ cd .. $ ./copy.sh advanced-qml-auto-reload ``` -See also [../../slime/src/readme-sources](../../slime/src/readme-sources.md) for -installing the Slime sources where this example can find them. +See also [../../slime/src/readme-sources](../../slime/src/readme-sources.md) +for installing the Slime sources where this example can find them. diff --git a/examples/app-template/make.lisp b/examples/app-template/make.lisp index c5c1567..7bc81a1 100644 --- a/examples/app-template/make.lisp +++ b/examples/app-template/make.lisp @@ -6,6 +6,9 @@ (list "/ecl-android/" "/ecl-ios/") (list :android :ios))) +#+(or android ios) +(pushnew :mobile *features*) + (require :asdf) (push (merge-pathnames "../") @@ -26,14 +29,14 @@ (defun cc (&rest args) (apply 'concatenate 'string args)) -#-(or android ios) +#-mobile (asdf:make-build "app" :monolithic t :type :static-library :move-here (cc *current* "build/tmp/") :init-name "ini_app") -#+(or android ios) +#+mobile (progn (pushnew :interpreter *features*) (defvar *asdf-system* "app") @@ -47,11 +50,11 @@ (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")) +(let* ((from #-mobile (cc *current* "build/tmp/app--all-systems.a") + #+mobile (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))) + (to* #-mobile (cc *current* "build/tmp/" to) + #+mobile (cc *library-path* to))) (when (probe-file to*) (delete-file to*)) (rename-file from to)) diff --git a/examples/swank-server/app.asd b/examples/swank-server/app.asd index 1a11563..ae9a056 100644 --- a/examples/swank-server/app.asd +++ b/examples/swank-server/app.asd @@ -3,8 +3,10 @@ :depends-on () :components ((:file "lisp/package") (:file "lisp/ui-vars") + #+mobile (:file "lisp/swank-quicklisp") (:file "lisp/eval") + #+mobile (:file "lisp/qml-reload/auto-reload-mobile") (:file "lisp/curl") (:file "lisp/main"))) diff --git a/examples/swank-server/lisp/qml-reload/auto-reload-mobile.lisp b/examples/swank-server/lisp/qml-reload/auto-reload-mobile.lisp index 247af8d..855a34a 100644 --- a/examples/swank-server/lisp/qml-reload/auto-reload-mobile.lisp +++ b/examples/swank-server/lisp/qml-reload/auto-reload-mobile.lisp @@ -2,7 +2,6 @@ (in-package :qml) -#+(or android ios) (defun remote-ip () (terpri *query-io*) (princ "Please enter WiFi IP of desktop computer (hit RET to skip): " @@ -11,22 +10,16 @@ (unless (x:empty-string ip) (format nil "http://~A:8080/" ip)))) -#+(or android ios) (defvar *remote-ip* #+interpreter nil #-interpreter #.(remote-ip)) -#+(or android ios) (defun load* (file) (load (make-string-input-stream (curl (x:cc *remote-ip* file))))) -(export 'load*) - -#+(or android ios) (defun qml:view-status-changed (status) (when (= 1 status) (load* "lisp/qml-reload/on-reloaded.lisp"))) -#+(or android ios) (let ((secs 0) (ini t)) (defun auto-reload-qml () @@ -45,5 +38,6 @@ (setf secs curr))) (qsingle-shot 250 'auto-reload-qml))) -#+(or android ios) -(export 'auto-reload-qml) +(export + (list 'load* + 'auto-reload-qml)) diff --git a/examples/swank-server/lisp/swank-quicklisp.lisp b/examples/swank-server/lisp/swank-quicklisp.lisp index d9389e2..f15249d 100644 --- a/examples/swank-server/lisp/swank-quicklisp.lisp +++ b/examples/swank-server/lisp/swank-quicklisp.lisp @@ -2,7 +2,7 @@ (in-package :qml) -#+(and (or android ios) (not interpreter)) +#-interpreter (ffi:clines "extern void init_lib_ASDF(cl_object);") (defun %sym (symbol package) @@ -10,14 +10,12 @@ ;;; Quicklisp setup -#+(or android ios) (defun ensure-asdf () (unless (find-package :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 () (ensure-asdf) (unless (find-package :quicklisp) @@ -36,7 +34,6 @@ ;;; Swank setup -#+(or android ios) (defun swank/create-server (interface port dont-close style) (funcall (%sym 'create-server :swank) :interface interface @@ -44,7 +41,6 @@ :dont-close dont-close :style style)) -#+(or android ios) (defun start-swank (&key (port 4005) (interface "0.0.0.0") (style :spawn) (load-contribs t) (setup t) (delete t) (quiet t) (dont-close t) log-events) @@ -64,20 +60,17 @@ "SLIME-listener" (lambda () (swank/create-server interface port dont-close style))))) -#+(or android ios) (defun stop-swank (&optional (port 4005)) (when (find-package :swank) (funcall (%sym 'stop-server :swank) port) :stopped)) -#+(or android ios) (progn ;; be careful not to use :s, :q in your mobile app code ;; ios simulator note: wrap :s and :q in qrun* (would crash otherwise) (define-symbol-macro :s (start-swank)) (define-symbol-macro :q (quicklisp))) -#+(or android ios) (export (list #+ios 'start-swank 'stop-swank diff --git a/examples/swank-server/lisp/ui-vars.lisp b/examples/swank-server/lisp/ui-vars.lisp index 20b81bf..0e2f169 100644 --- a/examples/swank-server/lisp/ui-vars.lisp +++ b/examples/swank-server/lisp/ui-vars.lisp @@ -4,6 +4,7 @@ #:*flick-output* #:*history-back* #:*history-forward* + #:*main* #:*progress* #:*repl-input* #:*repl-output* @@ -14,6 +15,7 @@ (defparameter *flick-output* "flick_output") (defparameter *history-back* "history_back") (defparameter *history-forward* "history_forward") +(defparameter *main* "main") (defparameter *progress* "progress") (defparameter *repl-input* "repl_input") (defparameter *repl-output* "repl_output") diff --git a/examples/swank-server/make.lisp b/examples/swank-server/make.lisp index d937c4f..3cca949 100644 --- a/examples/swank-server/make.lisp +++ b/examples/swank-server/make.lisp @@ -7,24 +7,27 @@ (list "/ecl-android/" "/ecl-ios/") (list :android :ios))) +#+(or android ios) +(pushnew :mobile *features*) + ;;; copy Swank and ECL contrib files (mobile only) (defun cc (&rest args) (apply 'concatenate 'string args)) -#+(or android ios) +#+mobile (defvar *assets* #+android "../platforms/android/assets/lib/" #+ios "../platforms/ios/assets/Library/") -#+(or android ios) +#+mobile (defun find-swank () (probe-file (cc *assets* "quicklisp/local-projects/slime/swank.lisp"))) -#+(or android ios) +#+mobile (defun shell (command) (ext:run-program "sh" (list "-c" command))) -#+(or android ios) +#+mobile (progn (unless (find-swank) (let ((to (cc *assets* "quicklisp/local-projects/slime/"))) @@ -36,7 +39,7 @@ (shell (cc "cp " lib "*.doc " *assets*)) (shell (cc "cp -r " lib "encodings " *assets*))))) -#+(or android ios) +#+mobile (unless (find-swank) (error "Swank files missing, please see /slime/src/readme-sources.md")) @@ -59,7 +62,7 @@ (dolist (file (list "package" "x" "ecl-ext" "ini" "qml")) ; load LQML symbols (load (merge-pathnames file "src/lisp/"))) -#-(or android ios) +#-mobile (progn (require :ecl-curl) (asdf:make-build "app" @@ -68,7 +71,7 @@ :move-here (cc *current* "build/tmp/") :init-name "ini_app")) -#+(or android ios) +#+mobile (progn (pushnew :interpreter *features*) (defvar *asdf-system* "app") @@ -83,11 +86,11 @@ ;;; 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")) +(let* ((from #-mobile (cc *current* "build/tmp/app--all-systems.a") + #+mobile (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))) + (to* #-mobile (cc *current* "build/tmp/" to) + #+mobile (cc *library-path* to))) (when (probe-file to*) (delete-file to*)) (rename-file from to)) diff --git a/examples/swank-server/qml/main.qml b/examples/swank-server/qml/main.qml index 60d9e45..23cd7db 100644 --- a/examples/swank-server/qml/main.qml +++ b/examples/swank-server/qml/main.qml @@ -5,6 +5,7 @@ import "ext/" as Ext Item { width: 300 height: 500 + objectName: "main" Ext.Repl {} diff --git a/platforms/shared/make.lisp b/platforms/shared/make.lisp index a784b1a..0ad8f73 100644 --- a/platforms/shared/make.lisp +++ b/platforms/shared/make.lisp @@ -49,7 +49,6 @@ (setf *features* (remove :interpreter *features*)) -#+(or android ios) (load (merge-pathnames (format nil "platforms/~A/cross-compile" #+android "android" #+ios "ios"))) diff --git a/slime/src/readme-sources.md b/slime/src/readme-sources.md index d06397e..284b53c 100644 --- a/slime/src/readme-sources.md +++ b/slime/src/readme-sources.md @@ -4,7 +4,7 @@ Info This is meant for the Swank server on mobile. -Please donwload latest [Slime sources](https://github.com/slime/slime/releases) +Please download latest [Slime sources](https://github.com/slime/slime/releases) and put them in this directory, that is, put the contents of `slime-x.x/` in this directory. diff --git a/src/lisp/ini.lisp b/src/lisp/ini.lisp index f27887e..772fd27 100644 --- a/src/lisp/ini.lisp +++ b/src/lisp/ini.lisp @@ -239,6 +239,9 @@ ;;; mobile ini #+(or android ios) +(pushnew :mobile *features*) + +#+mobile (defvar *assets* #+android "assets:/lib/" #+ios "assets/") @@ -263,7 +266,7 @@ (ext:setenv (car el) (namestring (merge-pathnames (cdr el) (user-homedir-pathname)))))) -#+(or android ios) +#+mobile (defun copy-asset-files (&optional (dir-name *assets*) origin) "Copy asset files to home directory." (flet ((directory-p (path) @@ -290,7 +293,7 @@ (return-from copy-asset-files)))))) t) -#+(or android ios) +#+mobile (defun %ini-mobile () ;; internal use, see 'main.cpp' (ext:install-bytecodes-compiler) diff --git a/src/make.lisp b/src/make.lisp index a3b992f..db351dc 100644 --- a/src/make.lisp +++ b/src/make.lisp @@ -7,6 +7,9 @@ (list "/ecl-android/" "/ecl-ios/") (list :android :ios))) +#+(or android ios) +(pushnew :mobile *features*) + ;;; compile ASDF system (require :asdf) @@ -17,7 +20,7 @@ (setf *default-pathname-defaults* (merge-pathnames "../../")) ; LQML root -#-(or android ios) +#-mobile (asdf:make-build "lqml" :monolithic t :type :static-library @@ -26,7 +29,7 @@ #+darwin "macos") :init-name "ini_LQML") -#+(or android ios) +#+mobile (progn (pushnew :interpreter *features*) (defvar *asdf-system* "lqml")