| 1 |
;;; |
| 2 |
;;; This an extremely simple example of how to build standalone programs and |
| 3 |
;;; unified fasl files from a system definition file. You should peruse this |
| 4 |
;;; file and also test it by loading it on your copy of ECL. |
| 5 |
;;; |
| 6 |
|
| 7 |
;;; |
| 8 |
;;; First of all, we need to include the ASDF module and the compiler |
| 9 |
;;; |
| 10 |
|
| 11 |
(require 'asdf) |
| 12 |
(require 'cmp) |
| 13 |
|
| 14 |
(setf *load-verbose* nil) |
| 15 |
(setf *compile-verbose* nil) |
| 16 |
(setf c::*suppress-compiler-warnings* t) |
| 17 |
(setf c::*suppress-compiler-notes* t) |
| 18 |
|
| 19 |
;;; This flag determines how lisp constants are compiled into the program. |
| 20 |
;;; The default scheme does not work well in statically linked libraries |
| 21 |
;;; yet. |
| 22 |
(setf c::*compile-in-constants* t) |
| 23 |
|
| 24 |
(push (make-pathname :name nil :type nil :version nil |
| 25 |
:defaults *load-truename*) |
| 26 |
asdf:*central-registry*) |
| 27 |
|
| 28 |
;;; |
| 29 |
;;; This will show you what is running behind the walls of ASDF. Everything |
| 30 |
;;; is built on top of the powerful C::BUILDER routine, which allows one |
| 31 |
;;; to build anything from executables to shared libraries. |
| 32 |
;;; |
| 33 |
;;(trace c::builder) |
| 34 |
|
| 35 |
;;; |
| 36 |
;;; Now we attempt building a single FASL file containing all those files. |
| 37 |
;;; Notice that we remove any previous fasl file. |
| 38 |
;;; |
| 39 |
|
| 40 |
(princ " |
| 41 |
|
| 42 |
Building FASL file 'example.fasb' |
| 43 |
|
| 44 |
") |
| 45 |
(asdf:make-build :example :type :fasl :move-here "./") |
| 46 |
|
| 47 |
;;; |
| 48 |
;;; Now we load the previous file! |
| 49 |
;;; |
| 50 |
|
| 51 |
(princ " |
| 52 |
|
| 53 |
Loading FASL file example.fasb |
| 54 |
|
| 55 |
") |
| 56 |
(load "example.fasb") |
| 57 |
|
| 58 |
;;; |
| 59 |
;;; Now that it worked, we attempt building a single program file with everything. |
| 60 |
;;; |
| 61 |
|
| 62 |
(princ " |
| 63 |
|
| 64 |
Building standalone executable 'example-mono' ('example-mono.exe' in Windows) |
| 65 |
|
| 66 |
") |
| 67 |
(asdf:make-build :example |
| 68 |
:type :program :epilogue-code '(ext:quit 0) |
| 69 |
:move-here "./") |
| 70 |
|
| 71 |
;;; |
| 72 |
;;; Test the program |
| 73 |
;;; |
| 74 |
|
| 75 |
(princ " |
| 76 |
|
| 77 |
Executing standalone file 'example' |
| 78 |
|
| 79 |
") |
| 80 |
(ext:system "./example") |
| 81 |
|
| 82 |
;;; |
| 83 |
;;; Clean up everything |
| 84 |
;;; |
| 85 |
|
| 86 |
(mapc #'delete-file (append (directory "*.o") |
| 87 |
(directory "*.obj") |
| 88 |
(directory "example-mono*"))) |