-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.py
60 lines (41 loc) · 1.78 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
57
58
59
60
#!/usr/bin/python3
import base64
import shutil
import sys
import os
FIFT_LIBS_LIST = 'Fift Asm AsmTests TonUtil Lists Color'.split(' ')
CONTRACTS_LIST = 'contract'.split(' ')
ap = os.path.abspath
base_path = ap(__file__ + '/../')
fift_path = os.environ['FIFTPATH']
print('====== Starting build ====================')
os.system('cls') # clears screen + enables escape sequences
for fift_lib in FIFT_LIBS_LIST:
shutil.copy(ap(f'{fift_path}toncli/lib/fift-libs/{fift_lib}.fif'),
ap(f'{base_path}/{fift_lib}.fif'))
print('====== Loaded libs for toncli ============')
with open(ap(base_path + '/fift/exotic.fif')) as f:
exotic_patch = f.read()
with open(ap(base_path + '/Asm.fif'), 'a') as f: f.write(exotic_patch)
with open(ap(base_path + '/AsmTests.fif'), 'a') as f: f.write(exotic_patch)
print('====== Patched Fift libraries ============')
os.chdir(base_path)
os.system('toncli run_tests >toncli.log 2>toncli.err')
os.system('python show-log.py')
print('====== Ran tests =========================')
os.system('toncli build >nul 2>nul')
print('====== Built contract in prod mode =======')
for contract in CONTRACTS_LIST:
with open(ap(base_path + f'/build/{contract}.fif'), 'a') as f:
f.write(f'\nboc>B "build/boc/{contract}.boc" B>file')
os.system(f'toncli fift run build/{contract}.fif')
with open(ap(f'build/boc/{contract}.boc'), 'rb') as rf:
boc = rf.read()
print(f'====== BOC of {repr(contract)} is {len(boc)} B')
with open(ap(f'build/boc/{contract}.hex'), 'wb') as wf:
wf.write(base64.b16encode(boc))
print(f'====== Saved {repr(contract)} in BOC and HEX representation')
if '--noclean' not in sys.argv:
for fift_lib in FIFT_LIBS_LIST:
os.remove(ap(f'{base_path}/{fift_lib}.fif'))
print('====== Deleted Fift libs =================')