X-Git-Url: http://repo.macrolet.net/gitweb/?p=jscl.git;a=blobdiff_plain;f=jscl.lisp;h=19c5c54b9eb9c6d0321320f60ecefc8e4c971fbf;hp=9dd2b5ad91fd0bb61a044d55ffec9f02a7c6eda0;hb=HEAD;hpb=212339794f45942973ca539691e37e87059e5832 diff --git a/jscl.lisp b/jscl.lisp index 9dd2b5a..19c5c54 100644 --- a/jscl.lisp +++ b/jscl.lisp @@ -22,6 +22,11 @@ (in-package :jscl) +(defvar *version* "0.0.2") + +(defvar *base-directory* + (or #.*load-pathname* *default-pathname-defaults*)) + ;;; List of all the source files that need to be compiled, and whether they ;;; are to be compiled just by the host, by the target JSCL, or by both. ;;; All files have a `.lisp' extension, and @@ -36,28 +41,32 @@ ;;; target, and that src/bar/baz.lisp and src/bar/quux.lisp need to be ;;; compiled in the host (defvar *source* - '(("boot" :target) - ("compat" :host) - ("utils" :both) - ("numbers" :target) - ("char" :target) - ("list" :target) - ("array" :target) - ("string" :target) - ("sequence" :target) - ("stream" :target) - ("print" :target) - ("package" :target) - ("misc" :target) - ("ffi" :both) - ("read" :both) - ("defstruct" :both) - ("lambda-list" :both) - ("backquote" :both) + '(("boot" :target) + ("compat" :host) + ("setf" :target) + ("utils" :both) + ("numbers" :target) + ("char" :target) + ("list" :target) + ("array" :target) + ("string" :target) + ("sequence" :target) + ("stream" :target) + ("hash-table" :target) + ("print" :target) + ("documentation" :target) + ("misc" :target) + ("ffi" :target) + ("symbol" :target) + ("package" :target) + ("read" :both) + ("defstruct" :both) + ("lambda-list" :both) + ("backquote" :both) ("compiler" - ("codegen" :both) - ("compiler" :both)) - ("toplevel" :target))) + ("codegen" :both) + ("compiler" :both)) + ("toplevel" :target))) (defun get-files (file-list type dir) "Traverse FILE-LIST and retrieve a list of the files within which match @@ -84,11 +93,12 @@ `(dolist (,name (get-files *source* ,type '(:relative "src"))) ,@body)) -(defun source-pathname - (filename &key (directory '(:relative "src")) (type nil) (defaults filename)) - (if type - (make-pathname :type type :directory directory :defaults defaults) - (make-pathname :directory directory :defaults defaults))) +(defun source-pathname (filename &key (directory '(:relative "src")) (type nil) (defaults filename)) + (merge-pathnames + (if type + (make-pathname :type type :directory directory :defaults defaults) + (make-pathname :directory directory :defaults defaults)) + *base-directory*)) ;;; Compile jscl into the host (with-compilation-unit () @@ -113,7 +123,7 @@ (*compile-print-toplevels* print)) (let* ((source (read-whole-file filename)) (in (make-string-stream source))) - (format t "Compiling ~a...~%" filename) + (format t "Compiling ~a...~%" (enough-namestring filename)) (loop with eof-mark = (gensym) for x = (ls-read in nil eof-mark) @@ -152,17 +162,22 @@ (setq *variable-counter* 0 *gensym-counter* 0 *literal-counter* 0) - (with-open-file (out "jscl.js" :direction :output :if-exists :supersede) + (with-open-file (out (merge-pathnames "jscl.js" *base-directory*) + :direction :output + :if-exists :supersede) (write-string (read-whole-file (source-pathname "prelude.js")) out) (do-source input :target (!compile-file input out)) (dump-global-environment out)) ;; Tests - (with-open-file (out "tests.js" :direction :output :if-exists :supersede) + (with-open-file (out (merge-pathnames "tests.js" *base-directory*) + :direction :output + :if-exists :supersede) (dolist (input (append (directory "tests.lisp") (directory "tests/*.lisp") (directory "tests-report.lisp"))) - (!compile-file input out))))) + (!compile-file input out))) + (report-undefined-functions))) ;;; Run the tests in the host Lisp implementation. It is a quick way