Browse code
Add compilation stuff to .asd
Fernando Borretti authored on 26/10/2013 02:15:02
Showing 1 changed files
Showing 1 changed files
... | ... |
@@ -1,3 +1,42 @@ |
1 |
+(in-package :cl-user) |
|
2 |
+(defpackage cl-yaml-asd |
|
3 |
+ (:use :cl :asdf)) |
|
4 |
+(in-package :cl-yaml-asd) |
|
5 |
+ |
|
6 |
+(defclass c->so (source-file) ()) |
|
7 |
+ |
|
8 |
+(defmethod source-file-type ((c c->so) (s module)) "c") |
|
9 |
+ |
|
10 |
+(defmethod output-files ((operation compile-op) (f c->so)) |
|
11 |
+ (values |
|
12 |
+ (list |
|
13 |
+ (make-pathname :name "yaml_wrapper" |
|
14 |
+ :type #+unix "so" #+darwin "dylib" #+windows "dll" |
|
15 |
+ :defaults (component-pathname f))) t)) |
|
16 |
+ |
|
17 |
+(defmethod perform ((o load-op) (c c->so)) t) |
|
18 |
+ |
|
19 |
+(defparameter +c-flags+ "-Wall -Wextra -c -fPIC -O3 -ansi") |
|
20 |
+(defparameter +linker-flags+ "-lyaml") |
|
21 |
+ |
|
22 |
+(defun comp (file out) |
|
23 |
+ (format t "clang ~A -o out.o ~A; clang out.o -shared -o ~A ~A" |
|
24 |
+ (namestring file) +c-flags+ (namestring out) +linker-flags+) |
|
25 |
+ (format nil "clang ~A -o out.o ~A && clang out.o -shared -o ~A ~A && rm out.o" |
|
26 |
+ (namestring file) +c-flags+ (namestring out) +linker-flags+)) |
|
27 |
+ |
|
28 |
+(defmethod perform ((o compile-op) (c c->so)) |
|
29 |
+ (if (not (zerop (run-shell-command |
|
30 |
+ (comp (make-pathname :name "yaml" |
|
31 |
+ :type "c" |
|
32 |
+ :defaults |
|
33 |
+ (merge-pathnames |
|
34 |
+ "src" |
|
35 |
+ (component-pathname c))) |
|
36 |
+ (namestring (car (output-files o c))))))) |
|
37 |
+ (error 'operation-error :component c :operation o) |
|
38 |
+ t)) |
|
39 |
+ |
|
1 | 40 |
(defsystem cl-yaml |
2 | 41 |
:version "0.1" |
3 | 42 |
:author "Fernando Borretti" |
... | ... |
@@ -9,8 +48,9 @@ |
9 | 48 |
:components ((:module "src" |
10 | 49 |
:serial t |
11 | 50 |
:components |
12 |
- ((:file "yaml") |
|
13 |
- (:file "cl-yaml"))) |
|
51 |
+ ((:static-file "yaml.h") |
|
52 |
+ (c->so "yaml" :depends-on ("yaml.h")) |
|
53 |
+ (:file "ffi"))) |
|
14 | 54 |
(:module "spec")) |
15 | 55 |
:description "" |
16 | 56 |
:long-description |