Maniac rework.
[clon.git] / com.dvlsoft.clon.asd
blob114f19371d55c206b31940698b6cd2bc7026b090
1 ;;; com.dvlsoft.clon.asd --- ASDF system definition
3 ;; Copyright (C) 2010, 2011, 2012 Didier Verna.
5 ;; Author:     Didier Verna <didier@lrde.epita.fr>
6 ;; Maintainer: Didier Verna <didier@lrde.epita.fr>
8 ;; This file is part of clon.
10 ;; Permission to use, copy, modify, and distribute this software for any
11 ;; purpose with or without fee is hereby granted, provided that the above
12 ;; copyright notice and this permission notice appear in all copies.
14 ;; THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
15 ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
16 ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
17 ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
18 ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
19 ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
20 ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 ;;; Commentary:
25 ;; Contents management by FCM version 0.1.
28 ;;; Code:
30 (in-package :cl-user)
33 ;; ------------------
34 ;; Package definition
35 ;; ------------------
37 (defpackage :com.dvlsoft.clon.asdf
38   (:documentation "The Command-Line Options Nuker package for ASDF.")
39   (:use :cl))
41 (in-package :com.dvlsoft.clon.asdf)
44 ;; --------------------
45 ;; Very early utilities
46 ;; --------------------
48 ;; Configuration
50 (defvar cl-user::com.dvlsoft.clon.configuration nil
51   "The Clon configuration settings.
52 This variable contains a property list of configuration options.
53 Current options are:
54 - :swank-eval-in-emacs (Boolean)
55 - :restricted (Boolean)
56 - :dump (Boolean)
58 See section A.1 of the user manual for more information.")
60 (defun configuration (key)
61   "Return KEY's value in the current Clon configuration."
62   (getf cl-user::com.dvlsoft.clon.configuration key))
64 (defun set-configuration (key value)
65   "Set KEY to VALUE in the current Clon configuration."
66   (setf (getf cl-user::com.dvlsoft.clon.configuration key) value))
68 (defsetf configuration set-configuration)
71 ;; Versionning
73 (defmacro define-constant (name value &optional doc)
74   `(defconstant ,name (if (boundp ',name) (symbol-value ',name) ,value)
75      ,@(when doc (list doc))))
77 (defconstant +release-major-level+ 1
78   "The major level of this release.")
80 (defconstant +release-minor-level+ 0
81   "The minor level of this release.")
83 (defconstant +release-status+ :beta
84   "The status of this release.")
86 (defconstant +release-status-level+ 21
87   "The status level of this release.")
89 (define-constant +release-name+ "Michael Brecker"
90   "The name of this release.")
92 ;; #### TODO: I'm sure the format strings can be improved
93 (defun %version (type major minor status level name)
94   (ecase type
95     (:number
96      (apply #'+
97        (* major 10000)
98        (* minor 100)
99        (when (eq status :patchlevel)
100          (list level))))
101     (:short
102      (format nil "~S.~S~
103                  ~[~
104                    a~*~S~;~
105                    b~*~S~;~
106                    rc~*~S~;~
107                    ~:[.~S~;~*~]~
108                  ~]"
109        major
110        minor
111        (ecase status
112          (:alpha 0)
113          (:beta 1)
114          (:rc 2)
115          (:patchlevel 3))
116        (zerop level)
117        level))
118     (:long
119      (format nil "~S.~S ~
120                  ~[~
121                    alpha ~*~S ~;~
122                    beta ~*~S ~;~
123                    release candidate ~*~S ~;~
124                    ~:[patchlevel ~S ~;~*~]~
125                  ~]~
126                  ~S"
127        major
128        minor
129        (ecase status
130          (:alpha 0)
131          (:beta 1)
132          (:rc 2)
133          (:patchlevel 3))
134        (zerop level)
135        level
136        name))))
138 (defun version (&optional (type :number))
139   "Return the current version of Clon.
140 TYPE can be one of :number, :short or :long.
142 A version number is computed as major*10000 + minor*100 + patchlevel, leaving
143 two digits for each level. Alpha, beta and rc status are ignored in version
144 numbers.
146 A short version is something like 1.3{a,b,rc}4, or 1.3.4 for patchlevel.
147 Alpha, beta or rc levels start at 1. Patchlevels start at 0 but are ignored
148 in the output, so that 1.3.0 appears as just 1.3.
150 A long version is something like
151 1.3 {alpha,beta,release candidate,patchlevel} 4 \"Michael Brecker\". As for
152 the short version, a patchlevel of 0 is ignored in the output."
153   (%version type +release-major-level+ +release-minor-level+
154             +release-status+ +release-status-level+
155             +release-name+))
158 ;; -------------------
159 ;; System requirements
160 ;; -------------------
162 (unless (configuration :restricted)
163   #+sbcl    (handler-case (asdf:load-system :sb-grovel)
164               (error ()
165                 (format *error-output* "~
166 *******************************************************************
167 * WARNING: unable to load module SB-GROVEL.                       *
168 * Clon will be loaded without support for terminal autodetection. *
169 * See section A.1 of the user manual for more information.        *
170 *******************************************************************")
171                 (setf (configuration :restricted) t)))
172   #+allegro (handler-case (asdf:load-system :cffi-grovel)
173               (error ()
174                 (format *error-output* "~
175 *******************************************************************
176 * WARNING: unable to load ASDF component CFFI-GROVEL.             *
177 * Clon will be loaded without support for terminal autodetection. *
178 * See section A.1 of the user manual for more information.        *
179 *******************************************************************")
180                 (setf (configuration :restricted) t)))
181   #+clisp   (cond ((member :ffi *features*)
182                    (handler-case (asdf:load-system :cffi-grovel)
183                      (error ()
184                        (format *error-output* "~
185 *******************************************************************
186 * WARNING: unable to load ASDF component CFFI-GROVEL.             *
187 * Clon will be loaded without support for terminal autodetection. *
188 * See section A.1 of the user manual for more information.        *
189 *******************************************************************")
190                        (setf (configuration :restricted) t))))
191                   (t
192                    (format *error-output* "~
193 *******************************************************************
194 * WARNING: CLISP is compiled without FFI support.                 *
195 * Clon will be loaded without support for terminal autodetection. *
196 * See section A.1 of the user manual for more information.        *
197 *******************************************************************")
198                    (setf (configuration :restricted) t)))
199   #+abcl    (progn (format *error-output* "~
200 *******************************************************************
201 * NOTE: ABCL is in use.                                           *
202 * Clon will be loaded without support for terminal autodetection. *
203 * See section A.1 of the user manual for more information.        *
204 *******************************************************************")
205                    (setf (configuration :restricted) t)))
207 (unless (configuration :restricted)
208   (push :com.dvlsoft.clon.termio *features*))
211 ;; -----------------
212 ;; System definition
213 ;; -----------------
215 (asdf:defsystem :com.dvlsoft.clon
216   :description "The Command-Line Options Nuker."
217   :long-description "Clon is a library for command-line option management.
218 It is intended to ease the creation of standalone Common Lisp applications by
219 providing a powerful and uniform command-line option interface.
220 The most important features of Clon are:
221 - [from the programmer's point of view] Centralized command-line options
222   specification and management, including automatic generation of help
223   strings, conversion from command-line / environment strings to
224   application-level option values, global or on-demand option retrieval, and
225   extensibility (the programmer can define his own option types).
226 - [from the end-user's point of view] Uniform command-line option syntax
227   across Clonified applications, including customization of the help strings
228   layout (with optional ISO6429 coloring on terminals that support it),
229   possibly abbreviated option calls and short/long syntax."
230   :author "Didier Verna <didier@lrde.epita.fr>"
231   :maintainer "Didier Verna <didier@lrde.epita.fr>"
232   :license "BSD"
233   :version #.(version :long)
234   :depends-on (#+sbcl :sb-posix
235                #+(and clisp com.dvlsoft.clon.termio) :cffi)
236   :serial t
237   :components ((:file "package")
238                #+com.dvlsoft.clon.termio
239                (:module "termio"
240                 :serial t
241                 :components
242                 (#+sbcl
243                  (:module "sbcl"
244                   :components ((sb-grovel:grovel-constants-file "constants"
245                                 :package :com.dvlsoft.clon)))
246                  #+(or allegro clisp)
247                  (:module "cffi"
248                   :components ((cffi-grovel:grovel-file "constants")))
249                  (:file "termio")))
250                (:module "src"
251                 :depends-on (#+com.dvlsoft.clon.termio "termio")
252                 :components ((:file "util")
253                              (:file "item" :depends-on ("util"))
254                              (:file "text" :depends-on ("item"))
255                              (:module "options"
256                               :depends-on ("text")
257                               :components ((:file "option")
258                                            (:file "flag"
259                                             :depends-on ("option"))
260                                            (:file "valued"
261                                             :depends-on ("option"))
262                                            (:file "negatable"
263                                             :depends-on ("valued"))
264                                            (:file "switch-base"
265                                             :depends-on ("negatable"))
266                                            (:file "switch"
267                                             :depends-on
268                                                   ("switch-base"))
269                                            (:file "stropt"
270                                             :depends-on ("valued"))
271                                            (:file "lispobj"
272                                             :depends-on ("valued"))
273                                            (:file "path"
274                                             :depends-on ("valued"))
275                                            (:file "enum-base")
276                                            (:file "enum"
277                                             :depends-on
278                                                   ("valued"
279                                                    "enum-base"))
280                                            (:file
281                                             "xswitch"
282                                             :depends-on ("valued"
283                                                          "switch-base"
284                                                          "enum-base"))))
285                              (:file "container" :depends-on ("options"))
286                              (:file "group" :depends-on ("container"))
287                              (:module "retrieval"
288                               :depends-on ("options")
289                               :components ((:file "cmdline")
290                                            (:file "environ")))
291                              (:file "synopsis" :depends-on ("group"))
292                              (:module "output"
293                               :depends-on ("synopsis" "retrieval")
294                               :components ((:file "face")
295                                            (:file "sheet"
296                                             :depends-on ("face"))))
297                              (:file "context"
298                               :depends-on ("output"))))))
301 ;;; com.dvlsoft.clon.asd ends here