-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_tuttleofx.py
More file actions
134 lines (111 loc) · 3.01 KB
/
project_tuttleofx.py
File metadata and controls
134 lines (111 loc) · 3.01 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#! /usr/bin/env python
"""
NAME
{program_name} - {project_name} build actions script.
SYNOPSIS
{program_name} actions
DESCRIPTION
actions
{actions}
computed_env
{computed_env}
"""
import os, sys
import json
import pprint
import worktry
project_name = 'tuttleofx'
depends = {
'darwin': {
'formulae': [
'scons',
'boost',
'ffmpeg',
'fontconfig',
'freeglut',
'freetype',
'imagemagick',
'jpeg',
'jpeg-turbo',
'openexr',
'openjpeg',
'libraw',
'swig',
],
'projects': ['oiio']
}
}
envs = None
computed_env = {}
def clean():
"""
clean action.
"""
if sys.platform != 'darwin':
raise NotImplementedError(sys.platform)
worktry.exec_cmd('cd {project_dir};'
'TUTTLEOFX={project_dir} scons -c'.format(**computed_env), computed_env)
def configure():
"""
configure action.
"""
if sys.platform != 'darwin':
raise NotImplementedError(sys.platform)
pass
def distclean():
"""
distclean action.
"""
if sys.platform != 'darwin':
raise NotImplementedError(sys.platform)
worktry.exec_cmd('cd {project_dir};'
'rm -rf .dist'.format(**computed_env), computed_env)
def make(arg=''):
"""
make action.
"""
if sys.platform != 'darwin':
raise NotImplementedError(sys.platform)
worktry.exec_cmd('cd {project_dir};'
'TUTTLEOFX={project_dir} scons -j8'.format(**computed_env) +
" {}".format(arg),
computed_env)
def make_depends():
"""
make_depends action.
"""
if sys.platform != 'darwin':
raise NotImplementedError(sys.platform)
#Fixme naive implementation
#Todo topological sort on depends
if sys.platform == 'darwin':
worktry.make_depends(depends['darwin'], computed_env)
def materialize():
"""
"""
worktry.materialize(project_name, computed_env)
if sys.platform == 'darwin':
if 'formulae' in depends['darwin']:
worktry.exec_cmd('brew install --build-from-source {}'\
.format(" ".join(depends['darwin']['formulae'])),
computed_env)
computed_env.update(worktry.compute_project(project_name, depends, envs))
actions = {
'all': lambda: (configure(), make()),
'configure': configure,
'make': make,
'clean':clean,
'distclean':distclean,
'make_depends':make_depends,
}
computed_env['actions'] = sorted(actions.keys())
computed_env['program_name'] = __file__
__doc__ = __doc__.format(computed_env=pprint.pformat(computed_env), **computed_env)
if __name__ == "__main__":
if len(sys.argv) != 2 or '-h' in sys.argv:
print(__doc__)
sys.exit(0)
action = sys.argv[1]
if action not in actions:
raise NotImplementedError('Action {}'.format(action))
actions[action]()