several revisions; prepare for iOS static ECL contrib libs

This commit is contained in:
pls.153 2022-03-01 17:02:08 +01:00
parent 6806218645
commit 1106db7c0a
6 changed files with 55 additions and 22 deletions

View file

@ -19,7 +19,7 @@ PRE_TARGETDEPS += tmp/libapp.a
QT += quick qml
TEMPLATE = app
CONFIG += no_keywords release
DEFINES += INI_LISP # SWANK
DEFINES += INI_LISP # NO_QT_RESTART
INCLUDEPATH = /usr/local/include
LIBS = -L/usr/local/lib -lecl
DESTDIR = .

View file

@ -78,3 +78,14 @@ If you cross-compiled ECL for the simulator, it should work there too, but this
is currently only tested on **Intel**.
Simulator note: to show the virtual keyboard, use `cmd-k`.
Advanced note
-------------
For conditions during Qt event processing, a fallback restart is added at
startup (needed in e.g. Slime).
If you don't want this, define the following in `app.pro`:
```
DEFINES += NO_QT_RESTART
```

View file

@ -7,6 +7,9 @@ lqml run.lisp
Optionally pass `-slime` to start a Swank server, and connect from Emacs with
`M-x slime-connect`.
During development you can pass `-auto`, which will releoad all QML files after
you made a change to any of them and saved it, see `auto-reload-qml.lisp`.
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

@ -6,17 +6,10 @@ QML Preview and Slime
This shows how to use **QML Preview** (live QML updates while you are typing).
First you need to apply 2 small changes:
* edit `lisp/main.lisp` of an example, and add this line at the end:
* edit `lisp/main.lisp` of an example, and append this line:
```
(load "~/slime/lqml-start-swank.lisp")
```
* edit `app.pro` and change `DEFINES` to:
```
DEFINES += INI_LISP SWANK
```
* open `app.pro` in **Qt Creator**; under 'Projects' (menu on the left) /
'Configure Project' choose 'Debug' and change the 'Build directory' to
`build/` from the example

View file

@ -19,6 +19,19 @@
extern "C" void ini_app(cl_object);
#endif
#ifdef INI_ECL_CONTRIB
// for iOS (static lib)
extern "C" {
void init_lib_ASDF(cl_object);
void init_lib_DEFLATE(cl_object);
void init_lib_ECL_CDB(cl_object);
void init_lib_ECL_HELP(cl_object);
void init_lib_QL_MINITAR(cl_object);
void init_lib_SOCKETS(cl_object);
void init_lib_ECL_CURL(cl_object);
}
#endif
int catch_all_qexec() {
int ret = 0;
CL_CATCH_ALL_BEGIN(ecl_process_env()) {
@ -46,6 +59,7 @@ int main(int argc, char* argv[]) {
view.setFormat(f);
}
view.connect(view.engine(), &QQmlEngine::quit, &app, &QCoreApplication::quit);
view.connect(&app, &QGuiApplication::lastWindowClosed, []() { LQML::eval("(qml:qquit)"); });
LQML lqml(argc, argv, &view);
if (arguments.contains("-v") || arguments.contains("--version")) {
@ -87,11 +101,26 @@ int main(int argc, char* argv[]) {
#endif
}
#ifdef INI_ECL_CONTRIB
// for iOS (static lib); ASDF is loaded on demand (slow)
ecl_init_module(NULL, init_lib_DEFLATE);
ecl_init_module(NULL, init_lib_ECL_CDB);
ecl_init_module(NULL, init_lib_ECL_HELP);
ecl_init_module(NULL, init_lib_QL_MINITAR);
ecl_init_module(NULL, init_lib_SOCKETS);
ecl_init_module(NULL, init_lib_ECL_CURL);
#endif
#ifdef INI_LISP
ecl_init_module(NULL, ini_app);
#endif
#ifdef NO_QT_RESTART
bool slime = false;
#else
bool slime = true;
#endif
if (arguments.contains("-slime")
|| (arguments.indexOf(QRegularExpression(".*start-swank.*")) != -1)) {
arguments.removeAll("-slime");
@ -99,22 +128,14 @@ int main(int argc, char* argv[]) {
}
// load Lisp file
if (arguments.length() > 1) {
QString arg1(QDir::fromNativeSeparators(arguments.at(1)));
if (arg1.endsWith(".lisp")) {
LQML::eval(QString("(load \"%1\")").arg(arg1), true);
}
QStringList lisp = arguments.filter(".lisp");
if (!lisp.isEmpty()) {
QString file = QDir::fromNativeSeparators(lisp.first());
LQML::eval(QString("(load \"%1\")").arg(file), true);
}
#ifdef SWANK
slime = true;
#endif
if (slime) {
// fallback restart for conditions while processing the Qt event loop
LQML::eval("(loop (with-simple-restart (restart-qt-events \"Restart Qt event processing.\")"
" (qexec)))",
true);
LQML::eval("(qml::exec-with-qt-restart)", true);
return 0;
}

View file

@ -205,6 +205,11 @@
x))
arguments))))
(defun exec-with-qt-restart ()
;; for internal use; for conditions in Slime during Qt event loop processing
(loop (with-simple-restart (restart-qt-events "Restart Qt event processing.")
(qexec))))
(defun qquit (&optional (exit-status 0) (kill-all-threads t))
"args: (&optional (exit-status 0) (kill-all-threads t))
alias: qq