-
Notifications
You must be signed in to change notification settings - Fork 23
/
ninja.py
36 lines (26 loc) · 1013 Bytes
/
ninja.py
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
#!/usr/bin/env python
# PYTHONPATH=../../src/ninja/misc python ninja.py && ninja
import glob
import os
import ninja_syntax
if not os.path.isdir('ninjaout'): os.mkdir('ninjaout')
n = ninja_syntax.Writer(open('build.ninja', 'w'))
n.rule(name='cc',
command='clang -fcolor-diagnostics -O2 -c $in -o $out -MMD -MF $out.d $cflags',
depfile='$out.d',
deps='gcc',
)
n.rule(name='arlink', command='libtool -static $in -o $out')
n.variable('cflags', '-fcolor-diagnostics -arch i386 -arch x86_64')
outs = []
for f in glob.glob('zlib-1.2.8/*.c'):
outs.append('ninjaout/' + os.path.splitext(f)[0] + '.o')
n.build(outs[-1], 'cc', inputs=f)
n.build('ninjaout/libz.a', 'arlink', inputs=outs)
outs = []
for f in glob.glob('jpeg-6b/j*.c'):
if 'jpegtran' in f or (
'jmem' in f and not 'jmemmgr' in f and not 'jmemnobs' in f): continue
outs.append('ninjaout/' + os.path.splitext(f)[0] + '.o')
n.build(outs[-1], 'cc', inputs=f)
n.build('ninjaout/libjpeg.a', 'arlink', inputs=outs)