mirror of
https://github.com/dimitri/pgloader.git
synced 2026-05-04 18:36:12 +02:00
Implement the save.lisp idea for the bundle.
This should make it easier to build pgloader with CCL rather than SBCL, all from the bundle distribution, and also easier to support windows. In passing, add a new file in the bundle distribution: version.sexp should contain a CL string containing the pgloader version string.
This commit is contained in:
parent
18bcf10903
commit
6e325f67e0
10
Makefile
10
Makefile
@ -1,6 +1,6 @@
|
||||
# pgloader build tool
|
||||
APP_NAME = pgloader
|
||||
VERSION = 3.5.2
|
||||
VERSION = 3.6.0
|
||||
|
||||
# use either sbcl or ccl
|
||||
CL = sbcl
|
||||
@ -24,7 +24,7 @@ QLDIR = $(BUILDDIR)/quicklisp
|
||||
MANIFEST = $(BUILDDIR)/manifest.ql
|
||||
LATEST = $(BUILDDIR)/pgloader-latest.tgz
|
||||
|
||||
BUNDLEDIST = 2018-04-30
|
||||
BUNDLEDIST = 2018-10-18
|
||||
BUNDLENAME = pgloader-bundle-$(VERSION)
|
||||
BUNDLEDIR = $(BUILDDIR)/bundle/$(BUNDLENAME)
|
||||
BUNDLE = $(BUILDDIR)/$(BUNDLENAME).tgz
|
||||
@ -182,8 +182,12 @@ $(BUNDLEDIR):
|
||||
--eval '(defvar *ql-dist* "$(BUNDLEDIST)")' \
|
||||
--load bundle/ql.lisp
|
||||
|
||||
$(BUNDLE): $(BUNDLEDIR)
|
||||
$(BUNDLEDIR)/version.sexp: $(BUNDLEDIR)
|
||||
echo "\"$(VERSION)\"" > $@
|
||||
|
||||
$(BUNDLE): $(BUNDLEDIR) $(BUNDLEDIR)/version.sexp
|
||||
cp bundle/README.md $(BUNDLEDIR)
|
||||
cp bundle/save.lisp $(BUNDLEDIR)
|
||||
sed -e s/%VERSION%/$(VERSION)/ < bundle/Makefile > $(BUNDLEDIR)/Makefile
|
||||
git archive --format=tar --prefix=pgloader-$(VERSION)/ master \
|
||||
| tar -C $(BUNDLEDIR)/local-projects/ -xf -
|
||||
|
||||
@ -61,4 +61,7 @@ $(PGLOADER): $(BUILDAPP)
|
||||
test: $(PGLOADER)
|
||||
$(MAKE) PGLOADER=$(realpath $(PGLOADER)) -C $(SRCDIR)/test regress
|
||||
|
||||
save:
|
||||
sbcl --no-userinit --load ./save.lisp
|
||||
|
||||
check: test ;
|
||||
|
||||
47
bundle/save.lisp
Normal file
47
bundle/save.lisp
Normal file
@ -0,0 +1,47 @@
|
||||
;;;
|
||||
;;; Create a build/bin/pgloader executable from the source code, using
|
||||
;;; Quicklisp to load pgloader and its dependencies.
|
||||
;;;
|
||||
|
||||
(in-package #:cl-user)
|
||||
|
||||
(require :asdf) ; should work in SBCL and CCL
|
||||
|
||||
(let* ((cwd (uiop:getcwd))
|
||||
(bundle.lisp (uiop:merge-pathnames* "bundle.lisp" cwd))
|
||||
(version-file (uiop:merge-pathnames* "version.sexp" cwd))
|
||||
(version-string (uiop:read-file-form version-file))
|
||||
(asdf:*central-registry* (list cwd)))
|
||||
|
||||
(format t "Loading bundle.lisp~%")
|
||||
(load bundle.lisp)
|
||||
|
||||
(format t "Loading system pgloader ~a~%" version-string)
|
||||
(asdf:load-system :pgloader :verbose nil)
|
||||
(load (asdf:system-relative-pathname :pgloader "src/hooks.lisp"))
|
||||
|
||||
(let* ((pgl (find-package "PGLOADER"))
|
||||
(version-symbol (find-symbol "*VERSION-STRING*" pgl)))
|
||||
(setf (symbol-value version-symbol) version-string)))
|
||||
|
||||
(defun pgloader-image-main ()
|
||||
(let ((argv #+sbcl sb-ext:*posix-argv*
|
||||
#+ccl ccl:*command-line-argument-list*))
|
||||
(pgloader::main argv)))
|
||||
|
||||
(let* ((cwd (uiop:getcwd))
|
||||
(bin-dir (uiop:merge-pathnames* "bin/" cwd))
|
||||
(bin-filename (uiop:merge-pathnames* "pgloader" bin-dir)))
|
||||
|
||||
(ensure-directories-exist bin-dir)
|
||||
|
||||
#+ccl
|
||||
(ccl:save-application bin-filename
|
||||
:toplevel-function #'cl-user::pgloader-image-main
|
||||
:prepend-kernel t)
|
||||
#+sbcl
|
||||
(sb-ext:save-lisp-and-die bin-filename
|
||||
:toplevel #'cl-user::pgloader-image-main
|
||||
:executable t
|
||||
:save-runtime-options t
|
||||
:compression t))
|
||||
@ -27,7 +27,9 @@
|
||||
(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*))
|
||||
(let ((command (format nil "curl -o ~a ~a" ql.lisp *quicklisp.lisp*)))
|
||||
(format t "Running command: ~a~%" command)
|
||||
(uiop:run-program command))
|
||||
(load ql.lisp)
|
||||
(let* ((quickstart (find-package "QUICKLISP-QUICKSTART"))
|
||||
(ql-install (find-symbol "INSTALL" quickstart)))
|
||||
@ -57,7 +59,9 @@
|
||||
#+ccl ccl:*command-line-argument-list*))
|
||||
(pgloader::main argv)))
|
||||
|
||||
(let ((image-filename "/Users/dim/dev/pgloader/build/bin/pgloader"))
|
||||
(let* ((cwd (uiop:getcwd))
|
||||
(build-dir (uiop:merge-pathnames* "build/bin/" cwd))
|
||||
(image-filename (uiop:merge-pathnames* "pgloader" build-dir)))
|
||||
#+ccl
|
||||
(ccl:save-application image-filename
|
||||
:toplevel-function #'cl-user::pgloader-image-main
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user