-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.py
56 lines (49 loc) · 1.84 KB
/
build.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os
import sys
joinp = os.path.join
sys.path.insert(0, 'whitgl')
sys.path.insert(0, joinp('whitgl', 'input'))
import build
import platform
import ninja_syntax
def main():
target = 'zunus'
srcdir = 'src'
inputdir = joinp('whitgl', 'input')
builddir = 'build'
targetdir = joinp(builddir, 'out')
if build.plat == 'Darwin':
packagedir = joinp(targetdir, 'Zunus.app', 'Contents')
executabledir = joinp(packagedir, 'MacOS')
data_out = joinp(packagedir, 'Resources', 'data')
else:
executabledir = targetdir
data_out = joinp(targetdir, 'data')
objdir = joinp(builddir, 'obj')
libdir = joinp(builddir, 'lib')
data_in = 'data'
buildfile = open('build.ninja', 'w')
n = ninja_syntax.Writer(buildfile)
cflags = build.cflags + ' -Iwhitgl/inc -Isrc -g -O2'
build.rules(n, cflags, build.ldflags)
if build.plat == 'Windows':
n.rule('windres', command='windres $in -O coff -o $out', description='windres $out')
obj = build.walk_src(n, srcdir, objdir)
if build.plat == 'Windows':
obj += n.build(joinp(objdir, 'icon.res'), 'windres', joinp(data_in, 'win', 'Zunus.rc'))
whitgl = [joinp('whitgl','build','lib','whitgl.a')]
targets = []
targets += n.build(joinp(executabledir, target), 'link', obj+whitgl)
n.newline()
data = build.walk_data(n, data_in, data_out, ['png','ogg','lvl','wav'])
targets += n.build('data', 'phony', data)
n.newline()
targets += build.copy_libs(n, inputdir, executabledir)
if build.plat == 'Darwin':
targets += n.build(joinp(packagedir, 'Info.plist'), 'cp', joinp(data_in, 'osx', 'Info.plist'))
targets += n.build(joinp(packagedir, 'Resources', 'Zunus.icns'), 'cp', joinp(data_in, 'osx', 'Zunus.icns'))
targets += n.build(joinp(targetdir, 'README.txt'), 'cp', joinp(data_in, 'README.txt'))
n.build('all', 'phony', targets)
n.default('all')
if __name__ == '__main__':
main()