chiark / gitweb /
Initial commit.
[collect-bench] / bench.asd
1 ;;; -*-lisp-*-
2
3 (cl:defpackage #:bench-defsystem
4   (:use #:common-lisp))
5 (cl:in-package #:bench-defsystem)
6
7 (defclass c-source-file (asdf:source-file)
8   ((type :initform "c")))
9
10 (defmethod asdf:output-files ((o asdf:compile-op) (c c-source-file))
11   (mapcar (lambda (f)
12             (make-pathname :type "O" :case :common :defaults f))
13           (asdf:input-files o c)))
14
15 (defmethod asdf:perform ((o asdf:load-op) (c c-source-file))
16   #| nothing to do |#)
17
18 (defmethod asdf:perform ((o asdf:compile-op) (c c-source-file))
19   (mapc (lambda (in out)
20           (uiop:run-program (list "gcc" "-c" "-O2" "-g" "-Wall" "-fPIC"
21                                   #+cmu "-m32"
22                                   "-o" (uiop:native-namestring out)
23                                   (uiop:native-namestring in))))
24         (asdf:input-files o c)
25         (asdf:output-files o c)))
26
27 (defclass c-shared-lib (asdf:module)
28   ((soname :initarg :soname :initform nil)))
29
30 (defmethod asdf:output-files ((o asdf:compile-op) (c c-shared-lib))
31   (list (make-pathname :name (or (slot-value c 'soname)
32                                  (asdf:component-name c))
33                        :type "so")))
34
35 (defmethod asdf:perform ((o asdf:compile-op) (c c-shared-lib))
36   (let ((out (asdf:output-files o c)))
37     (assert (and out (null (cdr out))))
38     (uiop:run-program (list* "gcc"
39                              #+cmu "-m32"
40                              "-o" (uiop:native-namestring (car out))
41                              "-shared"
42                              (mapcan (lambda (kid)
43                                        (mapcar #'uiop:native-namestring
44                                                (asdf:output-files o kid)))
45                                      (asdf:component-children c))))))
46
47 (asdf:defsystem "bench"
48   :version "0.1.0"
49   :pathname "/home/mdw/src/bench/"
50   :depends-on ("cffi")
51   :components
52     ((c-shared-lib "benchspt"
53        :soname "libbenchspt"
54        :pathname ""
55        :components
56          ((c-source-file "benchspt")))
57      (:file "bench" :depends-on ("benchspt"))))