-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_scene_include.py
executable file
·53 lines (40 loc) · 1.26 KB
/
update_scene_include.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
#!/usr/bin/env python
import os
dir_root = 'scenes/'
file_include = dir_root+'scenes.hpp'
assert(os.path.isdir(dir_root))
# Get files to include in walking through the root directory
files_to_include = []
for root,dirs,files in os.walk(dir_root):
for f in files:
if f.endswith(".hpp"):
path = root+'/'+f
fid = open(path)
content = fid.read()
if content.find("struct scene_model")!=-1:
files_to_include.append(path)
fid.close()
# Create the header file
content = '''
#pragma once
// All scenes must be included in this file
// If you add a new scene: its corresponding header file must be included
// This can be done manually or using the automatic script
'''
for f in sorted(files_to_include):
content += '#include "'+f+'"\n'
N = len(files_to_include)
if N<=0:
print('No scenes files have been found, something doesn\'t look correct.')
exit()
# Debug message
print('The following '+str(N)+' scene files have been found')
for f in sorted(files_to_include):
print(' - '+f.replace(dir_root+'/',""))
# Write the file
fid = open(file_include,'w')
fid.write(content)
fid.close()
assert(os.path.isfile(file_include))
# Debug message
print('\nFile "'+file_include+'" updated\n')