forked from Deadrik/TFCraft
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.py
56 lines (47 loc) · 1.64 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, os.path, sys
import shutil, fnmatch
import logging
forge_dir = os.path.dirname(os.path.abspath(__file__))
mcp_dir = os.path.abspath('..')
src_dir = os.path.join(mcp_dir, 'src')
backup_dir = os.path.join(mcp_dir, 'src_backup')
sys.path.append(mcp_dir)
from runtime.recompile import recompile
from base import copytree, reset_logger
def main():
build_num = 0
if len(sys.argv) > 1:
try:
build_num = int(sys.argv[1])
except:
pass
sys.exit(build(build_num))
def build(major_num=0, build_num=0, revision_num=0):
print '============================= Build Start (%d.%d.%d) ============================' % (major_num, build_num, revision_num)
print '\nsrc -> backup'
copytree(src_dir, backup_dir, 0)
print '\nTFC_Shared -> minecraft'
copytree(os.path.join(forge_dir, 'TFC_Shared'), os.path.join(src_dir, 'minecraft'), 0)
print '\nTFC API -> minecraft'
copytree(os.path.join(forge_dir, 'TFC API'), os.path.join(src_dir, 'minecraft'), 0)
print
error_level = 0
try:
os.chdir(mcp_dir)
reset_logger()
recompile(None, False, False)
reset_logger()
os.chdir(forge_dir)
except SystemExit, e:
print 'Recompile Exception: %d ' % e.code
error_level = e.code
print '\nremove src'
shutil.rmtree(src_dir)
print '\nbackup -> src'
copytree(backup_dir, src_dir, 0)
print '\nremove backup'
shutil.rmtree(backup_dir)
print '============================= Build Finished %d ============================' % error_level
return error_level
if __name__ == '__main__':
main()