-
Notifications
You must be signed in to change notification settings - Fork 1
/
buildvar.scm
95 lines (84 loc) · 1.82 KB
/
buildvar.scm
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
(require-extension srfi-1)
(require-extension filepath)
(require-extension files)
(use posix)
(define-syntax defvar
(syntax-rules ()
((defvar var params ...)
(define var `(params ...)))))
(define-syntax appendvar
(syntax-rules ()
((appendvar var params ...)
(set! var (append! var `(params ...))))))
(define (command . x)
(system
(apply
string-append
(intersperse
(map ->string
(concatenate
(map (lambda (x)
(if (list? x)
x
(list x)))
x)))
" "))))
(define (command-rslt . x)
(with-input-from-pipe
(apply
(string-append
(intersperse
(map ->string
(concatenate
(map (lambda (x)
(if (list? x)
x
(list x)))
x)))
" ")))
read-lines))
(define OBJECT_FILES '())
(defvar CC gcc)
(defvar CXX g++)
(defvar LINK g++)
(defvar CSC csc)
(defvar MOC moc)
(defvar CSI csi)
(defvar UIC uic)
(define (build file)
(command CSI file))
(define (build-moc MOCHEADERS)
(for-each
(lambda (file)
(let ((outfile
(string-append
"moc_"
(pathname-strip-extension (->string file))
".cpp")))
(command MOC file '-o outfile)
(append! SOURCES (list outfile))))
MOCHEADERS))
(define (build-cxx SOURCES)
(for-each
(lambda (file)
(command CXX '-c CXXFLAGS INCPATH file)
(set!
OBJECT_FILES
(cons
(string-append
(pathname-strip-extension (->string file))
".o")
OBJECT_FILES)))
SOURCES))
(define (build-c SOURCES)
(for-each
(lambda (file)
(command CC '-c CFLAGS INCPATH file)
(set!
OBJECT_FILES
(cons
(string-append
(pathname-strip-extension (->string file))
".o")
OBJECT_FILES)))
SOURCES))