Added generate-cli.lisp

Pascal J. Bourguignon [2018-08-06 19:14]
Added generate-cli.lisp
Filename
README
src/Makefile
src/com.informatimago.hangman.tui.asd
src/generate-cli.lisp
diff --git a/README b/README
index 704164d..5876655 100644
--- a/README
+++ b/README
@@ -34,6 +34,13 @@ after modifications, one can reset it with:
      (initialize-game *controller*))


+To run the text UI version in the REPL:
+
+   (push :debugging *features*)
+   (ql:quickload :com.informatimago.hangman.tui)
+   (com.informatimago.hangman.cocoa::play)
+
+
 Production
 ----------

@@ -45,6 +52,17 @@ This generates an application package on the desktop named
 Hangman.app, using the generate-application.lisp script.


+To generate the CLI program, with the Makefile:
+
+
+    make cli
+
+this installs the executable in /usr/local/bin/hangman and the
+resources in /usr/local/games/hangman/.
+
+Note: the cli version should be compilable with any CL implementation;
+update the generate-cli.lisp script with the save lisp image function
+specific to your implementation.

 License
 -------
diff --git a/src/Makefile b/src/Makefile
index 794087c..4cf27ab 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -1,3 +1,5 @@
 all:application
 application:
 	ccl -norc < generate-application.lisp
+cli:
+	ccl -norc < generate-cli.lisp
diff --git a/src/com.informatimago.hangman.tui.asd b/src/com.informatimago.hangman.tui.asd
new file mode 100644
index 0000000..102b3eb
--- /dev/null
+++ b/src/com.informatimago.hangman.tui.asd
@@ -0,0 +1,49 @@
+;;;; -*- mode:lisp;coding:utf-8 -*-
+;;;;**************************************************************************
+;;;;FILE:               com.informatimago.hangman.asd
+;;;;LANGUAGE:           Common-Lisp
+;;;;SYSTEM:             Common-Lisp
+;;;;USER-INTERFACE:     NONE
+;;;;DESCRIPTION
+;;;;
+;;;;    Hangman Cocoa Application
+;;;;
+;;;;AUTHORS
+;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
+;;;;MODIFICATIONS
+;;;;    2015-06-17 <PJB> Created.
+;;;;BUGS
+;;;;LEGAL
+;;;;    AGPL3
+;;;;
+;;;;    Copyright Pascal J. Bourguignon 2015 - 2015
+;;;;
+;;;;    This program is free software: you can redistribute it and/or modify
+;;;;    it under the terms of the GNU Affero General Public License as published by
+;;;;    the Free Software Foundation, either version 3 of the License, or
+;;;;    (at your option) any later version.
+;;;;
+;;;;    This program is distributed in the hope that it will be useful,
+;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;;    GNU Affero General Public License for more details.
+;;;;
+;;;;    You should have received a copy of the GNU Affero General Public License
+;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;;;**************************************************************************
+
+(asdf:defsystem "com.informatimago.hangman.tui"
+  :description "A Hangman game with a Text User Interface."
+  :author "Pascal J. Bourguignon"
+  :version "1.0.0"
+  :license "AGPL3"
+  :depends-on ("com.informatimago.common-lisp.cesarum")
+  :components (      (:file "packages"             :depends-on ())
+                     (:file "hangman"              :depends-on ("packages"))
+                     (:file "hangman-tui"          :depends-on ("packages" "hangman")))
+
+  ;; :in-order-to ((asdf:test-op (asdf:test-op "com.informatimago.editor.test")))
+  )
+
+;;;; THE END ;;;;
+
diff --git a/src/generate-cli.lisp b/src/generate-cli.lisp
new file mode 100644
index 0000000..9cb03dc
--- /dev/null
+++ b/src/generate-cli.lisp
@@ -0,0 +1,94 @@
+;;;; -*- mode:lisp;coding:utf-8 -*-
+;;;;**************************************************************************
+;;;;FILE:               generate-cli.lisp
+;;;;LANGUAGE:           Common-Lisp
+;;;;SYSTEM:             Common-Lisp
+;;;;USER-INTERFACE:     NONE
+;;;;DESCRIPTION
+;;;;
+;;;;    This script generates the Hangman CLI with CCL.
+;;;;
+;;;;AUTHORS
+;;;;    <PJB> Pascal J. Bourguignon <pjb@informatimago.com>
+;;;;MODIFICATIONS
+;;;;    2018-08-06 <PJB> Created.
+;;;;BUGS
+;;;;LEGAL
+;;;;    AGPL3
+;;;;
+;;;;    Copyright Pascal J. Bourguignon 2015 - 2018
+;;;;
+;;;;    This program is free software: you can redistribute it and/or modify
+;;;;    it under the terms of the GNU Affero General Public License as published by
+;;;;    the Free Software Foundation, either version 3 of the License, or
+;;;;    (at your option) any later version.
+;;;;
+;;;;    This program is distributed in the hope that it will be useful,
+;;;;    but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;;;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;;;    GNU Affero General Public License for more details.
+;;;;
+;;;;    You should have received a copy of the GNU Affero General Public License
+;;;;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
+;;;;**************************************************************************
+(in-package "COMMON-LISP-USER")
+
+;;; --------------------------------------------------------------------
+;;; Load quicklisp
+(format t "~%;;; Loading quicklisp.~%")
+(finish-output)
+(load #P"~/quicklisp/setup.lisp")
+(setf quicklisp-client:*quickload-verbose* t)
+
+;;; --------------------------------------------------------------------
+;;; Load the application:
+
+(defparameter *program-name*      "hangman")
+(defparameter *release-directory* #P"/usr/local/bin/")
+(defparameter *program-pathname*  (merge-pathnames *program-name* *release-directory*))
+(defparameter *version*           "1.0.1")
+(defparameter *copyright*
+  "Copyright 2018 Pascal Bourguignon
+License: AGPL3")
+
+(push (or *load-pathname* #P"./") asdf:*central-registry*)
+(ql:quickload :com.informatimago.common-lisp.cesarum)
+(ql:quickload :com.informatimago.hangman.tui)
+;; (push (function com.informatimago.hangman.cocoa:play) ccl:*lisp-startup-functions*)
+
+;;; --------------------------------------------------------------------
+;;; Save the application package.
+
+(format t "Generating ~A~%" *program-pathname*)
+
+(shadow 'copy-file)
+(defun copy-file (source destination)
+  (ensure-directories-exist destination)
+  (format t "Copying ~A~%" destination)
+  (com.informatimago.common-lisp.cesarum.file:copy-file source destination
+                                                        :element-type '(unsigned-byte 8)
+                                                        :if-exists :supersede))
+
+(copy-file #P"~/src/public/games/hangman-cocoa-lisp/src/hangman.states"
+           #P"/usr/local/games/hangman/hangman.sexp")
+
+
+(defun save-hangman-program ()
+  ;; ccl::save-application
+  ;;  calls ccl::%save-application-interal
+  ;;  calls ccl::save-image
+  #+ccl
+  (ccl::save-application               ; This doesn't return.
+   *program-pathname*
+   :toplevel-function (function com.informatimago.hangman.cocoa::play)
+   :init-file nil
+   :error-handler :quit
+   :purify t
+   :mode #o755
+   :prepend-kernel t))
+
+
+(save-hangman-program)
+
+
+;;;; THE END ;;;;
ViewGit