From cfbd8a6288ece7c64b481983c881e5aa20d726d1 Mon Sep 17 00:00:00 2001 From: Javier Olaechea Date: Mon, 15 Jun 2015 05:09:31 -0500 Subject: [PATCH] Buildapp scaffold --- Makefile | 81 ++++++++++++++++++++++++++++++++++++++++++++ build/.gitignore | 5 +++ build/bin/.gitignore | 4 +++ coleslaw-cli.asd | 10 ++++++ coleslaw.asd | 6 ++-- src/cli.lisp | 35 +++++++++++++++++-- version.lisp-expr | 1 + 7 files changed, 136 insertions(+), 6 deletions(-) create mode 100644 Makefile create mode 100644 build/.gitignore create mode 100644 build/bin/.gitignore create mode 100644 coleslaw-cli.asd create mode 100644 version.lisp-expr diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..609ac25 --- /dev/null +++ b/Makefile @@ -0,0 +1,81 @@ +APP_NAME = coleslaw +VERSION_FILE := version.lisp-expr +VERSION := $(shell cat ${VERSION_FILE}) + +# use either sbcl or ccl +CL = sbcl + +# default to 4096 MB of RAM size in the image +DYNSIZE = 4096 + +LISP_SRC = $(wildcard src/*lisp) \ + coleslaw-cli.asd \ + coleslaw.asd + +BUILDDIR = build +LIBS = $(BUILDDIR)/libs.stamp +QLDIR = $(BUILDDIR)/quicklisp +MANIFEST = $(BUILDDIR)/manifest.ql + +BUILDAPP = $(BUILDDIR)/bin/buildapp.sbcl +CL_OPTS = --no-sysinit --no-userinit + +BUILDAPP_OPTS = --require sb-posix \ + --require sb-bsd-sockets \ + --require sb-rotate-byte + +COLESLAW = $(BUILDDIR)/bin/$(APP_NAME) + +clean: + rm -rf $(LIBS) $(QLDIR) $(MANIFEST) $(BUILDAPP) $(COLESLAW) + +$(QLDIR)/setup.lisp: + mkdir -p $(BUILDDIR) + curl -o $(BUILDDIR)/quicklisp.lisp https://beta.quicklisp.org/quicklisp.lisp + $(CL) $(CL_OPTS) --load $(BUILDDIR)/quicklisp.lisp \ + --eval '(quicklisp-quickstart:install :path "$(BUILDDIR)/quicklisp")' \ + --eval '(quit)' + +quicklisp: $(QLDIR)/setup.lisp ; + +$(LIBS): $(QLDIR)/setup.lisp + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ + --eval '(push "$(PWD)/" asdf:*central-registry*)' \ + --eval '(ql:quickload "coleslaw-cli")' \ + --eval '(quit)' + touch $@ + +libs: $(LIBS) ; + +$(MANIFEST): $(LIBS) + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ + --eval '(ql:write-asdf-manifest-file "$(MANIFEST)")' \ + --eval '(quit)' + +manifest: $(MANIFEST) ; + +$(BUILDAPP): $(QLDIR)/setup.lisp + mkdir -p $(BUILDDIR)/bin + $(CL) $(CL_OPTS) --load $(QLDIR)/setup.lisp \ + --eval '(ql:quickload "buildapp")' \ + --eval '(buildapp:build-buildapp "$@")' \ + --eval '(quit)' + +buildapp: $(BUILDAPP) ; + +$(COLESLAW): $(MANIFEST) $(BUILDAPP) $(LISP_SRC) + mkdir -p $(BUILDDIR)/bin + $(BUILDAPP) --logfile /tmp/build.log \ + $(BUILDAPP_OPTS) \ + --sbcl $(CL) \ + --asdf-path . \ + --manifest-file $(MANIFEST) \ + --asdf-tree $(QLDIR)/dists \ + --asdf-path . \ + --load-system $(APP_NAME) \ + --load-system coleslaw-cli \ + --entry coleslaw-cli:main \ + --output $@ + + +coleslaw: $(COLESLAW) ; diff --git a/build/.gitignore b/build/.gitignore new file mode 100644 index 0000000..70b5e5f --- /dev/null +++ b/build/.gitignore @@ -0,0 +1,5 @@ +# Ignore everything in this directory +* +# Except this file +!bin +!.gitignore \ No newline at end of file diff --git a/build/bin/.gitignore b/build/bin/.gitignore new file mode 100644 index 0000000..86d0cb2 --- /dev/null +++ b/build/bin/.gitignore @@ -0,0 +1,4 @@ +# Ignore everything in this directory +* +# Except this file +!.gitignore \ No newline at end of file diff --git a/coleslaw-cli.asd b/coleslaw-cli.asd new file mode 100644 index 0000000..d1ddc84 --- /dev/null +++ b/coleslaw-cli.asd @@ -0,0 +1,10 @@ +(defsystem #:coleslaw-cli + :name "coleslaw-cli" + :description "CLI tools for Coleslaw" + :version (:read-file-from "version.lisp-expr") + :license "BSD" + :author "Javier Olaechea " :pathname "src/" @@ -25,13 +25,13 @@ (:file "posts") (:file "indexes") (:file "feeds") - (:file "coleslaw") - (:file "cli")) + (:file "coleslaw")) :in-order-to ((test-op (load-op coleslaw-tests))) :perform (test-op :after (op c) (funcall (intern "RUN!" :coleslaw-tests) (intern "COLESLAW-TESTS" :coleslaw-tests)))) + (defsystem #:coleslaw-tests :description "A test suite for coleslaw." :license "BSD" diff --git a/src/cli.lisp b/src/cli.lisp index 49c8a14..8232157 100644 --- a/src/cli.lisp +++ b/src/cli.lisp @@ -1,10 +1,11 @@ (defpackage #:coleslaw-cli - (:use :cl) + (:use #:cl) (:documentation "CLI processing tools.") (:export - #:process-parameters)) + #:process-parameters + #:main)) -(in-package :coleslaw-cli) +(in-package #:coleslaw-cli) (defun process-parameters (argv) "Return an alist where the key is the option name and the value the @@ -21,3 +22,31 @@ (second argv) alist)))))) (%iter argv nil))) + +(defparameter *usage* + "Usage: coleslaw [--config ] + +OPTIONS + + --config + The coleslaw configuration file to use. + + +COMMANDS + + build + build the site + + clean + remove all the generated files. + + rebuild + The equivalent of calling clean and build. + + serve + Start a web server +") + +(defun main (argv) + "The CLI entry point." + (format t "~A~%" *usage*)) diff --git a/version.lisp-expr b/version.lisp-expr new file mode 100644 index 0000000..d29c461 --- /dev/null +++ b/version.lisp-expr @@ -0,0 +1 @@ +"0.9.7" \ No newline at end of file