mirror of
https://github.com/dimitri/pgloader.git
synced 2025-08-07 23:07:00 +02:00
Implement a new way of building pgloader: make save.
This time we directly call into the save-lisp-and-die feature of the implementation. As pgloader only supports SBCL and CCL at the time being, doing things without an abstraction layer is easy enough. This needs more testing and a special version for the bundle case too. One step at a time, etc.
This commit is contained in:
parent
3f2f10eef1
commit
1c18b41cd7
3
Makefile
3
Makefile
@ -164,6 +164,9 @@ pgloader-standalone:
|
||||
test: $(PGLOADER)
|
||||
$(MAKE) PGLOADER=$(realpath $(PGLOADER)) CL=$(CL) -C test regress
|
||||
|
||||
save: ./src/save.lisp $(LISP_SRC)
|
||||
sbcl --no-userinit --load ./src/save.lisp
|
||||
|
||||
clean-bundle:
|
||||
rm -rf $(BUNDLEDIR)
|
||||
rm -rf $(BUNDLETESTD)/$(BUNDLENAME)/*
|
||||
|
70
src/save.lisp
Normal file
70
src/save.lisp
Normal file
@ -0,0 +1,70 @@
|
||||
;;;
|
||||
;;; Create a build/bin/pgloader executable from the source code, using
|
||||
;;; Quicklisp to load pgloader and its dependencies.
|
||||
;;;
|
||||
|
||||
(in-package #:cl-user)
|
||||
|
||||
;; ccl provides an implementation of getenv already.
|
||||
#+sbcl
|
||||
(defun getenv (name &optional default)
|
||||
"Return the current value for the environment variable NAME, or default
|
||||
when unset."
|
||||
(or (sb-ext:posix-getenv name) default))
|
||||
|
||||
(require :asdf) ; should work in SBCL and CCL
|
||||
|
||||
(defvar *quicklisp.lisp* "http://beta.quicklisp.org/quicklisp.lisp")
|
||||
|
||||
(let* ((cwd (uiop:getcwd))
|
||||
(build-dir (uiop:merge-pathnames* "build/" cwd))
|
||||
(ql.lisp (uiop:merge-pathnames* "quicklisp.lisp" build-dir))
|
||||
(qldir (uiop:merge-pathnames* "quicklisp/" build-dir))
|
||||
(qlsetup (uiop:merge-pathnames* "setup.lisp" qldir)))
|
||||
;;
|
||||
;; We might have to install Quicklisp in build/quicklisp
|
||||
;;
|
||||
(unless (probe-file qlsetup)
|
||||
(format t "File ~a is not found, installing Quicklisp from ~a~%"
|
||||
qlsetup *quicklisp.lisp*)
|
||||
(uiop:run-program (format nil "curl -o ~a ~a" ql.lisp *quicklisp.lisp*))
|
||||
(load ql.lisp)
|
||||
(let* ((quickstart (find-package "QUICKLISP-QUICKSTART"))
|
||||
(ql-install (find-symbol "INSTALL" quickstart)))
|
||||
(funcall ql-install :path qldir :proxy (getenv "http_proxy"))))
|
||||
|
||||
;;
|
||||
;; Now that we have Quicklisp, load it and push our copy of pgloader in
|
||||
;; ql:*local-project-directories* where Quicklisp will find it.
|
||||
;;
|
||||
(format t "Loading file ~a~%" qlsetup)
|
||||
(load qlsetup)
|
||||
|
||||
(let* ((ql (find-package "QL"))
|
||||
(lpd (find-symbol "*LOCAL-PROJECT-DIRECTORIES*" ql))
|
||||
(quickload (find-symbol "QUICKLOAD" ql)))
|
||||
(push cwd (symbol-value lpd))
|
||||
|
||||
;;
|
||||
;; And finally load pgloader and its image-based hooks
|
||||
;;
|
||||
(format t "Loading system pgloader~%")
|
||||
(funcall quickload :pgloader)
|
||||
(load (asdf:system-relative-pathname :pgloader "src/hooks.lisp"))))
|
||||
|
||||
(defun pgloader-image-main ()
|
||||
(let ((argv #+sbcl sb-ext:*posix-argv*
|
||||
#+ccl ccl:*command-line-argument-list*))
|
||||
(pgloader::main argv)))
|
||||
|
||||
(let ((image-filename "/Users/dim/dev/pgloader/build/bin/pgloader"))
|
||||
#+ccl
|
||||
(ccl:save-application image-filename
|
||||
:toplevel-function #'cl-user::pgloader-image-main
|
||||
:prepend-kernel t)
|
||||
#+sbcl
|
||||
(sb-ext:save-lisp-and-die image-filename
|
||||
:toplevel #'cl-user::pgloader-image-main
|
||||
:executable t
|
||||
:save-runtime-options t
|
||||
:compression t))
|
Loading…
Reference in New Issue
Block a user