-
Notifications
You must be signed in to change notification settings - Fork 2
/
clorb-files.lisp
279 lines (247 loc) · 8.69 KB
/
clorb-files.lisp
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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
;;;-*- Mode: Lisp; Package: (NET.CDDR.CLORB.SYSTEM) -*-
(defpackage "NET.CDDR.CLORB.SYSTEM"
(:use "COMMON-LISP")
(:export "SET-LOAD-OPTS" "RELOAD"))
(in-package "NET.CDDR.CLORB.SYSTEM")
;;; Load options
(defmacro def-load-opts (setter tester &rest opts)
(let ((vars (loop for (key) in opts
collect (intern (symbol-name key) *package*))))
`(let ((opts (make-hash-table)))
(defun ,tester (key)
(if (eq key 'print-it)
(loop for (key nil comment) in ',opts do
(format t "~22S ~5S ~A~%" key (gethash key opts) comment))
(multiple-value-bind (val good) (gethash key opts)
(unless good (warn "Undefined load opt: ~S" key))
val)))
(defun ,setter (&key ,@(loop for (nil def) in opts for var in vars
collect `(,var ,def)))
,(format nil "Set load options~:{~%~A (~A) - ~A~}" opts)
,@(loop for (key) in opts for var in vars
collect `(setf (gethash ,key opts) ,var)))
(,setter))))
(def-load-opts set-load-opts load-opt
(:server t "Load the code needed to server objects")
(:idlcomp nil "Load the old IDL parser")
(:my-idlparser t "Load the new IDL parser")
(:portable-interceptor nil "Load support for Portable Interceptors")
(:support-test t "Load support code for test suite")
(:hello-world nil "Load hello world example"))
;;; Files
(defparameter *base-files*
'(("clorb-pkgdcl")
"clorb-options"
"clorb-supp"
("clorb-macros" t)
("clorb-queue" t)
#+openmcl "clorb-openmcl"
"clorb-sysdep"
"clorb-mt"
"clorb-basetypes"
"clorb-typecode-1"
("clorb-buffer" t)
"clorb-marshal"
"clorb-unmarshal"
"clorb-typecode-2"
("clorb-macros2" t)
"clorb-any"
"clorb-struct"
"clorb-union"
"clorb-exceptions"
"clorb-io"
"clorb-conn"
"clorb-object"
"clorb-request"
"clorb-iop"
"clorb-value"
"clorb-ifr-base"
"clorb-orb"
"clorb-codec"
"clorb-iiop"
"cosnaming-stub"
"clorb-util"
"clorb-misc"
"clorb-ifr"
"clorb-target"
"clorb-idl"
"clorb-idlcpp" ))
(defparameter *server-files*
'("clorb-objkey"
"clorb-servant"
"clorb-trie"
"clorb-aom"
"clorb-poa-base"
"clorb-poa"
"clorb-srv"
"clorb-ifr-info"))
(defparameter *redpas-files*
'("redpas;package"
"redpas;lexer"
"redpas;parsys"))
(defparameter *luna-files*
'("luna;package"
"luna;pattern"
"luna;testsuite"))
(defparameter *dev-post-files*
'("support-test"))
(defparameter *portable-interceptor-files*
'("clorb-pi-base"
"clorb-pi-impl"))
(defparameter *x-files*
'(;; Experimental
"idef-read"
"idef-write"
("idef-macros" t)
"clorb-ifr-export"
;; Services
;;"cosnaming-idl"
"cosnaming-skel"
"pns-server"))
(defparameter *idlcomp*
'( ;; IDL Compiler
"idlcomp;package"
"idlcomp;lisp-scanner;scanner-support"
"idlcomp;idl-compiler-support"
"idlcomp;idl-scanner-parser"
"idlcomp;idl-compiler" ))
(defparameter *my-idlparser*
'("clorb-idllexer"
"clorb-idlparser"))
(defparameter *hello-world*
'("examples;hello;idl"
"examples;hello;hello-server"
"examples;hello;hello-client"
"examples;hello;hello"))
(defvar *load-dates* (make-hash-table :test #'equal))
(defvar *source-pathname-defaults*
(make-pathname :name nil :type nil
:defaults
(if (eq :absolute
(first (pathname-directory *load-pathname*)))
*load-pathname*
(truename *load-pathname*))))
(defvar *binary-folder*
(format nil "~(~A_~A~A~)"
(or #+Digitool "mcl"
#+CMU "cmucl"
#+Allegro "acl"
(lisp-implementation-type))
(or #+clisp
(let ((string (lisp-implementation-version)))
(subseq string 0 (position #\Space string)))
#+CMU
(substitute-if #\_ (lambda (x) (find x " /"))
(lisp-implementation-version))
#+OpenMCL
(format nil "~A.~A" ccl::*openmcl-major-version*
ccl::*openmcl-minor-version*)
#+allegro excl::*common-lisp-version-number*
(lisp-implementation-version))
(or #+(and sbcl sb-thread) "_thread"
#+openmcl (format nil "_~a" ccl::fasl-version)
"")))
(defun dir-split (base)
(declare (string base))
(let ((dir-pos (position #\; base)))
(if dir-pos
(cons (subseq base 0 dir-pos)
(dir-split (subseq base (1+ dir-pos))))
(list base))))
(defun compile-changed (files)
(loop
with defs-date = 0
for x in files
for (base defs) = (if (consp x) x (list x nil))
do (let* ((names (dir-split base))
(name (car (last names)))
(dir (nbutlast names))
(sf (merge-pathnames
(make-pathname :name name :type "lisp"
:directory (if dir (cons :relative dir)))
*source-pathname-defaults*))
(cf (if *binary-folder*
(compile-file-pathname
(merge-pathnames
(make-pathname :name name :type "lisp"
:directory
(list* :relative "fasl"
*binary-folder* dir))
*source-pathname-defaults*))
(compile-file-pathname sf)))
(cf-tail (if *binary-folder*
(list :output-file cf))))
(when (or (not (probe-file cf))
(let ((dcf (file-write-date cf))
(dsf (file-write-date sf)))
(or (null dcf) (null dsf)
(progn
#+(or)
(format t "~&;; Exam comp ~A(~A):~A(~A)~%"
sf dsf cf dcf )
nil)
(> dsf dcf)
(> defs-date dcf))))
(format t "~&;;;; Compiling ~A ~%" sf )
(ensure-directories-exist cf)
(apply #'compile-file sf cf-tail))
(let ((dcf (file-write-date cf))
(last (gethash base *load-dates*)))
(when defs
(setq defs-date (max (or dcf 0) defs-date)))
(when (or (null last) (null dcf)
(> dcf last))
(format t "~&;;;; Loading ~A ~%" base)
(load cf)
(setf (gethash base *load-dates*) dcf))))))
(defun reload ()
#+clorb-packer-luna (packer:require-package :net.cddr.luna)
#+clorb-packer-redpas (packer:require-package :net.cddr.redpas)
(compile-changed
(append #-clorb-packer-luna *luna-files*
#-clorb-packer-redpas *redpas-files*
*base-files*
(if (load-opt :server) *server-files*)
*x-files*
(if (load-opt :portable-interceptor) *portable-interceptor-files*)
(if (load-opt :idlcomp) *idlcomp*)
(if (load-opt :my-idlparser) *my-idlparser*)
(if (load-opt :support-test) *dev-post-files*)
(if (load-opt :hello-world) *hello-world*)))
(let ((clorb (find-package "NET.CDDR.CLORB")))
(import 'reload clorb)
(export 'reload clorb)))
(defun acl-defsys ()
(format t "(defsystem :clorb ()~%")
(let ((groups '((base . *base-files*)
(server . *server-files*)
(x-files . *x-files*))))
(format t "~2t(:definitions (:serial . ~S)~%~8t(:serial . ~A))~%"
'("clorb-pkgdcl" "clorb-macros")
(mapcar 'car groups))
(loop
for (name . var) in groups
do (format t "~&~2t(:module-group ~A~%~4t(:serial ~{~14,1t~S~^~%~}))"
name
(mapcar (lambda (x)
(if (consp x)
(car x)
x))
(symbol-value var)))))
(format t ")~%"))
(defun asdf-defsys ()
(format t "(defsystem :clorb~%")
(format t " :depends-on ~S~%" '("redpas" "luna"))
(format t " :components (~%")
(loop for file in (append *base-files* *server-files*
*my-idlparser* *x-files*
*dev-post-files*)
with depend = nil
do (destructuring-bind (file &optional dep-flag)
(if (consp file)
file
(list file))
(format t " (:file ~s :depends-on ~S)~%"
file depend)
(when dep-flag (push file depend))))
(format t "))~%"))