-
Notifications
You must be signed in to change notification settings - Fork 35
/
clpython.asd
196 lines (177 loc) · 10.6 KB
/
clpython.asd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
;; -*- Mode: LISP; Syntax: COMMON-LISP; Package: CL-USER -*-
;;
;; This software is Copyright (c) Franz Inc. and Willem Broekema.
;; Franz Inc. and Willem Broekema grant you the rights to
;; distribute and use this software as governed by the terms
;; of the Lisp Lesser GNU Public License
;; (http://opensource.franz.com/preamble.html),
;; known as the LLGPL.
;;;; ASDF System Definitions
(eval-when (:compile-toplevel)
(error "This ASDF file should be run interpreted."))
;;; CL-Python is split into several ASDF systems, to make it possible to load
;;; specific components -- in particular, to load the compiler or parser without
;;; the runtime environment.
;;;
;;; The main system :CLPYTHON is the sum of all components, including contributions.
;;; Suppress some warnings about package trickery
(defun call-with-suppressed-clpython-package-warnings (thunk)
(handler-bind (#+sbcl
(sb-int:package-at-variance #'muffle-warning)
#+lispworks
(simple-warning (lambda (c)
(let ((fmt (slot-value c 'conditions::format-string)))
(when (search "Using DEFPACKAGE" fmt)
(muffle-warning c))))))
(funcall thunk)))
(defsystem "clpython/basic"
:description "CLPython package and utils"
:depends-on ("closer-mop")
:serial t
:components ((:file "package" :around-compile call-with-suppressed-clpython-package-warnings)
(:module "util"
:components ((:file "utils")
(:file "readtable")
(:file "macro-state" :depends-on ("utils"))
(:file "patternmatch")))
(:module "shared"
:serial t
:components ((:file "ssetup")
(:file "aureadtable")
(:file "errors")
(:file "aupprint")))))
;;; In Allegro, which provides its own Yacc, CL-Yacc can optionally be used.
;;; In other implementations CL-Yacc must be used.
(when (asdf:find-system "yacc" nil)
(pushnew :have-cl-yacc *features*))
(defsystem "clpython/parser"
:description "Python parser, code walker, and pretty printer"
:depends-on ("clpython/basic"
"closer-mop"
(:feature (:or (:not :allegro) :have-cl-yacc) "yacc"))
:components ((:module "parser"
:components ((:file "grammar" )
(:file "lexer" :depends-on ("grammar"))
(:file "parser" :depends-on ("grammar" "lexer"))
(:file "grammar-aclyacc" :depends-on ("grammar" "lexer" "parser") :if-feature :allegro)
(:file "grammar-clyacc" :depends-on ("grammar" "lexer" "parser") :if-feature (:or (:not :allegro) :have-cl-yacc))
(:file "ast-util" :depends-on ("grammar"))
(:file "walk" )
(:file "pprint" )))))
(defsystem "clpython/compiler"
:description "Python compiler"
:depends-on ("clpython/basic" "clpython/parser" "clpython/runtime" "closer-mop")
:serial t
:components ((:module "compiler"
:serial t
:components ((:file "csetup" )
(:file "pydecl" )
(:file "namespace" )
(:file "compiler" )
(:file "generator" )
(:file "optimize" )))))
(defsystem "clpython/runtime"
:description "Python runtime environment"
:depends-on ("clpython/basic" "closer-mop" #+(or abcl clisp ecl) "cl-custom-hash-table" "cl-fad")
:components ((:module "runtime"
:serial t
:components ((:file "rsetup" )
(:file "formatstring" )
(:file "metaclass" )
(:file "dictattr" )
(:file "classes" )
(:file "exceptions" )
(:file "habitat" )
(:file "run" )
(:file "import" )))))
(defsystem "clpython/lib"
:description "Python module library"
:depends-on ("clpython/basic" "clpython/runtime" "clpython/compiler" #| TODO: remove compiler dep |#)
:components ((:module "lib"
:serial t
:components ((:file "lsetup" :around-compile call-with-suppressed-clpython-package-warnings)
(:file "builtins-file" :depends-on ("lsetup"))
(:file "builtins-set" :depends-on ("lsetup"))
(:file "builtins-buffer" :depends-on ("lsetup"))
(:file "builtins" :depends-on ("builtins-file" "builtins-set" "builtins-buffer"))
(:file "array" :depends-on ("lsetup"))
(:file "_ast" :depends-on ("lsetup"))
(:file "binascii" :depends-on ("lsetup"))
(:file "_bsddb" :depends-on ("lsetup"))
(:file "_collections" :depends-on ("lsetup"))
(:file "_codecs" :depends-on ("lsetup"))
(:file "cStringIO" :depends-on ("lsetup"))
(:file "datetime" :depends-on ("lsetup"))
(:file "errno" :depends-on ("lsetup"))
(:file "exceptions" :depends-on ("lsetup"))
(:file "_functools" :depends-on ("lsetup"))
(:file "gc" :depends-on ("lsetup"))
(:file "imp" :depends-on ("lsetup"))
(:file "itertools" :depends-on ("lsetup"))
(:file "marshal" :depends-on ("lsetup"))
(:file "math" :depends-on ("lsetup"))
(:file "_md5" :depends-on ("lsetup"))
(:file "operator" :depends-on ("lsetup"))
(:file "posix" :depends-on ("lsetup"))
(:file "_random" :depends-on ("lsetup"))
(:file "re" :depends-on ("lsetup"))
(:file "_sha" :depends-on ("lsetup"))
(:file "_sha256" :depends-on ("lsetup"))
(:file "_sha512" :depends-on ("lsetup"))
(:file "_socket" :depends-on ("lsetup"))
(:file "_sre" :depends-on ("lsetup"))
(:file "_ssl" :depends-on ("lsetup"))
(:file "_struct" :depends-on ("lsetup"))
(:file "sys" :depends-on ("lsetup"))
(:file "string" :depends-on ("lsetup"))
(:file "symbol" :depends-on ("lsetup"))
(:file "thread" :depends-on ("lsetup"))
(:file "time" :depends-on ("lsetup"))
(:file "_weakref" :depends-on ("lsetup"))))))
(defsystem "clpython/contrib"
:description "CLPython contributions and experiments"
:depends-on ("clpython/basic" "clpython/runtime" "clpython/compiler")
:components ((:module "contrib"
:components ((:file "repl")
(:file "lispy")
(:file "executable" )
#+(or) ;; disable while in development
;; #+(and allegro allegro-version>= (version>= 8 2))
(:file "source" )))))
;;; Show usage after loading the system
(defun show-clpython-quick-start ()
(format t "~%CLPython quick start guide:~%")
(format t " Run a string of Python code: (~S \"for i in range(4): print i\")~%"
(find-symbol* '#:run :clpython))
(format t " Run a Python file: (~S #p\"~~/example/foo.py\")~%"
(find-symbol* '#:run :clpython))
(format t " Start the Python \"interpreter\" (REPL): (~S)~%"
(find-symbol* '#:repl :clpython.app.repl))
(format t " To start mixed Python/Lisp input mode: (~S)~%"
(find-symbol* '#:enter-mixed-lisp-python-syntax :clpython))
(format t " Run the test suite: ~S~%~%"
'(asdf:test-system "clpython")))
;;; The main system
(defsystem "clpython"
:description "CLPython - an implementation of Python in Common Lisp"
:author "Willem Broekema <[email protected]>"
:license "LLGPL (Lisp Lesser GNU Public License)"
:depends-on ("clpython/basic" "clpython/parser" "clpython/runtime" "clpython/compiler" "clpython/lib" "clpython/contrib")
:in-order-to ((test-op (test-op "clpython/test")))
:perform (load-op :after (o c) (show-clpython-quick-start)))
;;; Unit test, linked to asdf operation "test-op" on the CL-Python system
(defsystem "clpython/test"
:description "CLPython tests"
:depends-on ("clpython" #-allegro "ptester")
:components ((:module "test"
:serial t
:components ((:file "tsetup")
(:file "parser-test")
(:file "compiler-test")
(:file "lang-test")
(:file "function-test")
(:file "mod-builtins-test")
(:file "mod-string-test")
(:file "mod-math-test")
(:file "mod-operator-test"))))
:perform (test-op (o c) (symbol-call :clpython.test :run-tests)))