forked from philogb/jit
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
executable file
·43 lines (32 loc) · 1.36 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
import sys, json
#build model
class Build():
def __init__(self):
self.sources = 'Source/'
self.included = []
self.script = ''
self.build_model = json.load(open('build.json', 'r'))
self.build_paths = {}
for group in self.build_model:
for script in self.build_model[group]:
self.build_paths[script] = {
'path': self.sources + group + '/' + script + '.js',
'deps': self.build_model[group][script]
}
def build(self, args=[]):
if not args: args = [viz for viz in self.build_model['Visualizations']]
self.script = ''.join([self.load_script(viz) for viz in args if viz in self.build_model['Visualizations']])
return '(function () { \n\n' + self.script + '\n\n })();'
def load_script(self, script=None):
ans = ''
if script and not (script in self.included):
self.included.append(script)
ans = ''.join([self.load_script(s) for s in self.build_paths[script]['deps']])
f = open(self.build_paths[script]['path'])
ans += f.read() + '\n\n'
f.close()
return ans
def main():
ans = Build().build(sys.argv[1:])
print open('LICENSE').read() + ans
if __name__ == "__main__": main()