Commits (11)
if test "$1" = "--all"
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
echo "clean.sh called with --all (cleaning base directory and ~/.cache/common-lisp)"
bash clean.sh
if [ -d ~/.cache/common-lisp ]; then
echo "cleaning ~/.cache/common-lisp"
cd ~/.cache/common-lisp
bash "$BASE_DIR/clean.sh"
if [ -d ~/quicklisp ]; then
echo "cleaning ~/quicklisp"
cd ~/quicklisp/
bash "$BASE_DIR/clean.sh"
find . -name '*.ppcf' -exec rm -v {} \;
find . -name '*.*fsl' -exec rm -v {} \;
find . -name '*.fasl' -exec rm -v {} \;
find . -name '*.fas' -exec rm -v {} \;
find . -name '*.*fasl' -exec rm -v {} \;
find . -name '*.x86f' -exec rm -v {} \;
find . -name '*.*x*fsl' -exec rm -v {} \;
find . -name '*~.lisp' -exec rm -v {} \;
find . -name '*~.asd' -exec rm -v {} \;
find . -name '*~' -exec rm -v {} \;
find . -name '*.elc' -exec rm -v {} \;
find . -name '.#*' -exec rm -v {} \;
find . -name '*.allegro-warnings' -exec rm -v {} \;
find . -name '*.build-report' -exec rm -v {} \;
find . -name '*.64xfasl' -exec rm -v {} \;
rm -rvf .tmp/*
;;;; init-babel.lisp
;;;; Registers all Babel asdf systems
;;;; Before you can work with Babel, you have to evaluate
;;;; (load "/your/path/to/Babel2/init-babel.lisp")
;;;; Tip: add this command in your lisp system's init file.
(in-package :cl-user)
;; ############################################################################
;; asdf system registration
;; ----------------------------------------------------------------------------
(export '(babel-pathname))
;;; The root path of the Babel system.
(defparameter *babel-path*
(make-pathname :directory (pathname-directory (or *load-truename*
(defun babel-pathname (&key directory name type)
"Generates a pathname for a file relative to BABEL's root directory."
(merge-pathnames (make-pathname :directory (cons :relative directory)
:name name :type type)
(ensure-directories-exist (babel-pathname :directory '(".tmp")))
(asdf:initialize-source-registry `(:source-registry
(:tree ,(babel-pathname))
(format t "~&~%* Initializing BABEL.")
(format t "~% The BABEL path is: ~a" (directory-namestring *babel-path*))
;; put's the feature :hunchentoot-available-on-this-platform on
;; *features* except in some cases
(eval-when (:compile-toplevel :load-toplevel :execute)
(when (or (and (find :sbcl *features*) (find :sb-thread *features*))
(find :cmucl *features*)
(find :openmcl *features*) (find :mcl *features*)
(find :lispworks *features*)
(find :allegro-cl-enterprise *features*))
(pushnew :hunchentoot-available-on-this-platform *features*)))
;; we don't need ssl for hunchentoot
(pushnew :hunchentoot-no-ssl *features*)
;; when t, then the web-interface is automatically started upon compiling
(defvar *automatically-start-web-interface* t)
;; in some lisps *print-pretty* is t by default, that means everything
;; passed to format, print, mkstr, etc or everything returned from an
;; evaluation is pprinted. The monitors and other printing mechanisms
;; in Babel2 are actually very good in deciding what to pprint and
;; what not so your Babel2 experience is much greater when it is off
;; by default (and of course you can still use pprint).
(setf *print-pretty* nil)
(setf *print-circle* nil)
;; the test framework needs to be loaded before other systems are loaded
;; because it adds asdf methods that have to be there before other systems
;; are loaded
(asdf:operate 'asdf:load-op :test-framework :verbose nil)
;; ccl by default creates a thread with a copy of the global random
;; state and gensym counter for every evaluation from an Emacs
;; buffer. At the beginning of every swank thread, the code below
;; creates a new random state and copies the global gensym
;; counters. To make sure that these changes end up in the right
;; threads, we hook into asdf:perform
#+ccl(defmethod asdf:perform :before ((operation asdf:load-op)
(system asdf:system))
(when (find-package :swank-backend)
(let ((gsc (list *gensym-counter*)))
(setf (get (read-from-string "swank-backend:spawn")
(read-from-string "swank-backend::implementation"))
#'(lambda (fun &key name)
(or name "Anonymous (Swank)")
(lambda ()
(setq *random-state* (make-random-state t))
(setq *gensym-counter* (car gsc))
(funcall fun)
(setf (car gsc) *gensym-counter*))))))))
(let ((init-babel-user (babel-pathname :name "init-babel-user" :type "lisp")))
(when (probe-file init-babel-user)
(load init-babel-user)))
;;;;; File: test-babel-installation.lisp
;;;;; This file helps you to check whether Babel2 was initialized
;;;;; successfully and whether supporting tools such as gnuplot and
;;;;; graphviz were installed correctly. This file accompanies the
;;;;; step by step instruction for getting Babel2 running.
;;;;; Please evaluate each expression step by step and compare
;;;;; the results with the expected ones.
;;;;; --------------------------------------------------------------------------
;;;;; 1. The minimal requirements: a Lisp and Babel2
;;;;; In order to use Babel2, the Babel2/init-babel.lisp file needs to
;;;;; be loaded.
;;;;; We recommend adding the following lines to your lisp
;;;;; initialization file so that Babel2 is automatically initialized
;;;;; when your lisp starts.
;; (load "/directory-to-Babel/libraries/asdf")
;; (load "/directory-to-Babel/init-babel")
;;;;; replace directory-to-Babel by the correct path to where the
;;;;; file init-babel.lisp resides.
;;;;; e.g. (load "/Users/pieter/Babel2/init-babel")
(in-package :cl-user)
;;;;; This function should return the path to your Babel directory, for
;;;;; example #P"/Users/pieter/Projects/Babel2/".
(print (babel-pathname))
;;;;; If not, then something went wrong with your initialization of
;;;;; Babel2 (i.e. init-babel.lisp was not loaded) (go back to step 1
;;;;; of "Installing Babel 2")
;;;;; The next expression loads the most of the Babel2 systems. If
;;;;; that does not work, one of the steps above went wrong.
;(asdf:operate 'asdf:load-op :irl)
(ql:quickload :irl)
;;;;; If all of the above works you have the minimal requirements to
;;;;; run Babel2.
;;;;; --------------------------------------------------------------------------
;;;;; 2. The web interface
;;;;; You will have only a very limited user experience with Babel2
;;;;; and especially FCG and IRL when the web interface does not work
;;;;; on your machine/ lisp. Basically, your lisp needs to support
;;;;; threading.
;;;;; If the evaluation of the following line give you a 'yes!', then
;;;;; the webserver runs on your machine. If not try another lisp
;;;;; implementation.
(progn #+hunchentoot-available-on-this-platform (print "yes!"))
;;;;; The following line will load the web-interface:
;(asdf:operate 'asdf:load-op :web-interface)
(ql:quickload :web-interface)
;;;;; Open your web browser, preferably firefox, safari or
;;;;; google chrome (and definitely not internet explorer) and open
;;;;; http://localhost:8000/. This should present you with a white
;;;;; page containing a reset button.
;;;;; And the following should display hello world in your web
;;;;; browser.
(wi:add-element `((h1) "hello world"))
;;;;; --------------------------------------------------------------------------
;;;;; 3. Gnuplot
;;;;; Gnuplot is used by virtually all multi-agent experiments for
;;;;; plotting graphs. It is only required when running language game
;;;;; experiments. It is not needed for grammar engineers only
;;;;; interested in FCG. The next expression tests two things: -
;;;;; whether pipes into programs work on your lisp - whether your
;;;;; gnuplot is installed properly.
;;;;; What should happen is that a gnuplot window opens with the plot
;;;;; of a sinus in it.
(utils:with-open-pipe (stream (monitors:pipe-to-gnuplot))
(format stream "plot sin(x)~c" #\newline)
(finish-output stream))
;;;;; If nothing happens, then 3 things might be wrong:
;;;;; 1. You don't have gnuplot. Get one through apt-get/ fink/ cygwin
;;;;; etc. or by manually installing it from http://www.gnuplot.info/
;;;;; 2. You have gnuplot but your lisp doesn't find it. Make sure
;;;;; that it is in the path. (Note that lisp usually doesn't open a
;;;;; shell to execute a program, so it has to be where all other
;;;;; system wide programs are).
;;;;; On Macosx and linux try linking your binary to /usr/bin:
;;;;; ln -s /path/to/your/gnuplot /usr/bin/gnuplot
;;;;; On windows, add the c:\path-to-gnuplot\gnuplot\bin directory
;;;;; to the system path.
;;;;; 3. Your gnuplot is not configured to automatically open a graph
;;;;; window. To try this out, go to your terminal/ command line
;;;;; and type 'gnuplot'. Gnuplot should start and then you type
;;;;; 'plot sin(x)':
;; Leibniz:~ loetzsch$ gnuplot
;; G N U P L O T
;; Version 4.6 patchlevel 3 last modified 2013-04-12
;; Build System: Darwin x86_64
;; Copyright (C) 1986-1993, 1998, 2004, 2007-2013
;; Thomas Williams, Colin Kelley and many others
;; gnuplot home: http://www.gnuplot.info
;; faq, bugs, etc: type "help FAQ"
;; immediate help: type "help" (plot window: hit 'h')
;; Terminal type set to 'aqua'
;; gnuplot> plot sin(x)
;;;;; if you don't see a window with a sinus, then you need to
;;;;; configure your gnuplot to do so.
;;;;; --------------------------------------------------------------------------
;;;;; 4. Graphviz
;;;;; Some experiments use graphviz to visualize network structures
;;;;; (you definitely will want graphviz when you work with irl).
;;;;; This should create a .png file in Babel2/.tmp/ which contains a
;;;;; small network. Additionally, the image should be
;;;;; opened in a preview window. (This can take some time the first time)
(irl:draw-irl-program '((foo ?a ?b) (bar ?b ?c) (baz ?c ?a)) :open t :format "pdf")
;;;;; If this doesn't happen, then two things might be wrong:
;;;;; 1. You don't have graphviz installed. To check this, go to to
;;;;; your command line/ terminal and type 'dot'. If this command is
;;;;; not found, then you don't have graphviz installed. Install it
;;;;; with apt-get/ fink/ cygwin etc or install it manually from
;;;;; http://www.graphviz.org/.
;;;;; 2. You have graphviz but your lisp doesn't find the 'dot'
;;;;; program. Either put the dot program somewhere where the system
;;;;; can find it or (on linux/ mac) create a symbolic link:
;;;;; ln -s /path/to/your/dot /usr/bin/dot
;;;;; On windows, add the c:\path-to-graphviz\bin directory
;;;;; to the system path.