Standalone application

31 views
Skip to first unread message

Dmitry Solomennikov

unread,
Jun 29, 2011, 1:33:25 AM6/29/11
to eql-...@googlegroups.com
Hello!

I've made some changes to my_app, which is found in EQL archive.
The main idea is to make standalone application not so monolithic as it is.


One can use (load "<file>") to load code in runtime. I made bootstrap code,
this code is hardwired into executable and loads "main" lisp-code
after loading itself.

Take a look at files

my_app/main.cpp:
================

#include <QApplication>
#include <ecl/ecl.h>
#include "eql.h"

extern "C" void ini_app(cl_object);

int main(int argc, char** argv) {

cl_boot(1, argv);
QApplication qapp(argc, argv);

EQL eql;
eql.exec(ini_app, // see make-my-lib.lisp
"(START)", // the initial form to be evaluated
"BOOTSTRAP"); // your package name

return qapp.exec(); // closing the main/last window will quit the program
}

my_app/lisp/my.lisp:
====================
(defpackage :bootstrap
(:use :common-lisp :eql)
(:export
#:start))

(in-package :bootstrap)

(defparameter *bootstrap-file* "runtime/boot")

(defun start ()
(if (probe-file *bootstrap-file*)
(load *bootstrap-file*)
(progn
(qfun "QMessageBox" "critical" nil "OLang" (format nil "File '~A' not found.~%Application will be terminated." *bootstrap-file*))
(qq))))


User application (i.e. files to deploy) is a set of folders and files (Windows version):
/my_app
my_app.exe
my_app.bat
/runtime
/encodings
ecl.dll
*.asd
*.fas
*.fasb
ucd.dat
eql.dll
qt4*.dll
boot
/other files & folders

"runtime" folder includes files for application to start - ECL dll and dependent files, EQL dll, Qt dlls.
This folder is made available to application with my_app.bat file, which is simple

my_app.bat:
===========
set path=.;.\runtime
start %~n0.exe

The last thing is the runtime/boot file.

runtime/boot:
=============
(handler-case (load "runtime/app.lisp")
(error (err)
(let ((label
(qnew "QLabel(QString)" (princ-to-string err))))
(qfun label "show"))))

It is a simple error handler (it might be complex, but still enough for me) which fires application (in runtime/app.lisp).

Unix version of user application looks the same except that runtime folder contains only "boot" file and libeql.so
because of ECL is installed in operation system.


The whole schema looks a little bit complex, but it gives some sort of flexibility, especially when you deploy single application. User does not have to start application as eql.exe with parameters.

Thanks for reading.

Dmitry

Reply all
Reply to author
Forward
0 new messages