From c87cf7910c4d6026ffe036cd20b22343ecee229e Mon Sep 17 00:00:00 2001 From: polos Date: Thu, 20 Jul 2017 00:28:41 +0200 Subject: [PATCH] extend "my_app/" template for use with ASDF and dependencies (loaded via Quicklisp) --- my_app/README.txt | 39 ++++++++++++++++++++++++++++++++++----- my_app/dependencies.lisp | 2 ++ my_app/lisp/my.lisp | 16 +++++----------- my_app/main.cpp | 8 ++++---- my_app/make-ASDF.lisp | 24 ++++++++++++++++++++++++ my_app/make.lisp | 18 ++++++++++-------- my_app/my-app.asd | 5 +++++ my_app/my_app.pro | 2 +- my_app/package.lisp | 7 +++++++ my_app/run.lisp | 6 ++++++ my_app/tr.lisp | 2 +- 11 files changed, 99 insertions(+), 30 deletions(-) create mode 100644 my_app/dependencies.lisp create mode 100644 my_app/make-ASDF.lisp create mode 100644 my_app/my-app.asd create mode 100644 my_app/package.lisp create mode 100644 my_app/run.lisp diff --git a/my_app/README.txt b/my_app/README.txt index e6d280d..1884a53 100644 --- a/my_app/README.txt +++ b/my_app/README.txt @@ -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 + diff --git a/my_app/dependencies.lisp b/my_app/dependencies.lisp new file mode 100644 index 0000000..636c287 --- /dev/null +++ b/my_app/dependencies.lisp @@ -0,0 +1,2 @@ +(ql:quickload :alexandria) + diff --git a/my_app/lisp/my.lisp b/my_app/lisp/my.lisp index 1fcc4dd..7165c7e 100644 --- a/my_app/lisp/my.lisp +++ b/my_app/lisp/my.lisp @@ -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 "

~A ~{~R~^ ~},
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 "

~{~R~^ ~},
I want to sleep until ~R" + (loop for i from 1 to 7 collect i) + 11)) "alignment" |Qt.AlignCenter| "margin" 10))) + +(start) diff --git a/my_app/main.cpp b/my_app/main.cpp index eeb40f6..62f2d5a 100644 --- a/my_app/main.cpp +++ b/my_app/main.cpp @@ -7,7 +7,8 @@ #include #include -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 diff --git a/my_app/make-ASDF.lisp b/my_app/make-ASDF.lisp new file mode 100644 index 0000000..3b8dffb --- /dev/null +++ b/my_app/make-ASDF.lisp @@ -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)) + diff --git a/my_app/make.lisp b/my_app/make.lisp index 8e129f5..33aa09c 100644 --- a/my_app/make.lisp +++ b/my_app/make.lisp @@ -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) diff --git a/my_app/my-app.asd b/my_app/my-app.asd new file mode 100644 index 0000000..0980240 --- /dev/null +++ b/my_app/my-app.asd @@ -0,0 +1,5 @@ +(defsystem :my-app + :serial t + :depends-on (:alexandria) + :components ((:file "package") + (:file "lisp/my"))) diff --git a/my_app/my_app.pro b/my_app/my_app.pro index 2867568..9e07e25 100644 --- a/my_app/my_app.pro +++ b/my_app/my_app.pro @@ -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/ diff --git a/my_app/package.lisp b/my_app/package.lisp new file mode 100644 index 0000000..2080a83 --- /dev/null +++ b/my_app/package.lisp @@ -0,0 +1,7 @@ +(in-package :cl-user) + +(defpackage :example + (:use :cl :eql) + (:export + #:start)) + diff --git a/my_app/run.lisp b/my_app/run.lisp new file mode 100644 index 0000000..1c63bf7 --- /dev/null +++ b/my_app/run.lisp @@ -0,0 +1,6 @@ +(load "dependencies") + +(push "./" asdf:*central-registry*) + +(asdf:load-system "my-app") + diff --git a/my_app/tr.lisp b/my_app/tr.lisp index dda7fd6..9d7bf7a 100644 --- a/my_app/tr.lisp +++ b/my_app/tr.lisp @@ -1,5 +1,5 @@ (defpackage :eql-tr - (:use :common-lisp :eql)) + (:use :cl :eql)) (in-package :eql-tr)