extend "my_app/" template for use with ASDF and dependencies (loaded via Quicklisp)

This commit is contained in:
polos 2017-07-20 00:28:41 +02:00
parent 2814efdfaf
commit c87cf7910c
11 changed files with 99 additions and 30 deletions

View file

@ -3,25 +3,45 @@ HOWTO
Prepare:
--------
- in "make.lisp", add all of your lisp files to *lisp-files* (see "lisp/")
- adapt main.cpp (translations, initial Lisp form to evaluate, package name).
Build:
Build (simple, no ASDF):
------------------------
remove "tmp/" (if present)
eql5 make
qmake
make (MSVC: nmake)
$ eql5 make
$ qmake
$ make (MSVC: nmake)
Now you should find a "my_app" executable.
Build (using ASDF with dependencies):
-------------------------------------
remove "tmp/" (if present)
$ eql5 make-ASDF
$ qmake
$ make (MSVC: nmake)
Please note files:
my-app.asd ; define system
package.lisp ; example package
dependencies.lisp ; for Quicklisp (used in "run" and "make-ASDF")
run.lisp ; load system
Notes:
------
[Windows]
@ -31,3 +51,12 @@ Notes:
in main.cpp, as printing to *standard-output* would crash your GUI
application.
Deploy:
-------
You may want to strip your exe before deploying:
$ strip my_app

2
my_app/dependencies.lisp Normal file
View file

@ -0,0 +1,2 @@
(ql:quickload :alexandria)

View file

@ -1,17 +1,11 @@
(defpackage :example
(:use :common-lisp :eql)
(:export
#:start))
(in-package :example)
(defparameter *alarm* 11)
(defun start ()
(! "show" (qnew "QLabel"
"text" (tr (format nil "<h3>~A ~{~R~^ ~},<br>I want to sleep until ~R."
(string-capitalize (format nil "~R" 1))
(loop for i from 2 to 7 collect i)
*alarm*))
"text" (tr (format nil "<h3>~{~R~^ ~},<br>I want to sleep until ~R"
(loop for i from 1 to 7 collect i)
11))
"alignment" |Qt.AlignCenter|
"margin" 10)))
(start)

View file

@ -7,7 +7,8 @@
#include <QSettings>
#include <QTranslator>
extern "C" void ini_app(cl_object);
// adapt "MY_APP" (here: from "my-app.asd")
extern "C" void init_lib_MY_APP__ALL_SYSTEMS(cl_object);
int catch_all_qexec() {
int ret = 0;
@ -43,8 +44,7 @@ int main(int argc, char** argv) {
eql.ignoreIOStreams();
#endif
eql.exec(ini_app, // see make.lisp
"(start)", // initial form to be evaluated (optional)
"example"); // package name (optional)
// adapt "MY_APP" (here: from "my-app.asd")
eql.exec(init_lib_MY_APP__ALL_SYSTEMS);
return catch_all_qexec(); } // closing the main/last window will quit the program

24
my_app/make-ASDF.lisp Normal file
View file

@ -0,0 +1,24 @@
#-eql5
(error "Please use the EQL5 executable (see README)")
(require :cmp)
(load "dependencies")
(load "tr")
(push "./" asdf:*central-registry*)
(asdf:make-build "my-app"
:monolithic t
:type :static-library
:move-here "./")
(let ((lib-name #+msvc "my_app_lib.lib"
#-msvc "libmy_app_lib.a"))
(when (probe-file lib-name)
(delete-file lib-name))
(rename-file (x:cc "my-app--all-systems"
#+msvc ".lib"
#-msvc ".a")
lib-name))

View file

@ -9,18 +9,20 @@
(setf c::*compile-in-constants* t)
(defparameter *lisp-files*
(list "my")
(list "package"
"lisp/my")
"All Lisp files of the application.")
(dolist (f *lisp-files*)
(let ((file (format nil "lisp/~A" f)))
(load file)
(compile-file file :system-p t)))
(dolist (file *lisp-files*)
(load file)
(compile-file file :system-p t))
(c:build-static-library "my_lib"
(c:build-static-library "my_app_lib"
:lisp-files (mapcar (lambda (file)
(format nil "lisp/~A.~A" file #+msvc "obj" #-msvc "o"))
(x:cc file #+msvc ".obj"
#-msvc ".o"))
*lisp-files*)
:init-name "ini_app")
;; name as computed in ASDF version
:init-name "init_lib_MY_APP__ALL_SYSTEMS")
(eql:qq)

5
my_app/my-app.asd Normal file
View file

@ -0,0 +1,5 @@
(defsystem :my-app
:serial t
:depends-on (:alexandria)
:components ((:file "package")
(:file "lisp/my")))

View file

@ -2,7 +2,7 @@ QT += widgets printsupport uitools
TEMPLATE = app
CONFIG += no_keywords release
INCLUDEPATH += /usr/local/include
LIBS += -lecl -L. -lmy_lib -L/usr/local/lib -leql5
LIBS += -lecl -L. -lmy_app_lib -L/usr/local/lib -leql5
TARGET = my_app
DESTDIR = ./
OBJECTS_DIR = ./tmp/

7
my_app/package.lisp Normal file
View file

@ -0,0 +1,7 @@
(in-package :cl-user)
(defpackage :example
(:use :cl :eql)
(:export
#:start))

6
my_app/run.lisp Normal file
View file

@ -0,0 +1,6 @@
(load "dependencies")
(push "./" asdf:*central-registry*)
(asdf:load-system "my-app")

View file

@ -1,5 +1,5 @@
(defpackage :eql-tr
(:use :common-lisp :eql))
(:use :cl :eql))
(in-package :eql-tr)