Belle II Software light-2406-ragdoll
manipulate_SConstruct.py
1#!/usr/bin/env python3
2
3
10
11import sys
12from basf2 import find_file
13sconstruct_path = find_file('site_scons/SConstruct')
14# sconstruct_path = '../site_scons/SConstruct'
15
16fobj = open(sconstruct_path)
17
18optionlist = [' global_env.Append(CCFLAGS = [\'-Wextra\'])\n',
19 ' global_env.Append(CCFLAGS = [\'-Wextra\',\'-O3\'])\n',
20 ' global_env.Append(CCFLAGS = [\'-Wextra\',\'-O3\', \'-native\'])\n'
21 ]
22option = optionlist[int(sys.argv[1])]
23a = False
24output = []
25input_data = []
26for line in fobj:
27 input_data.append(line)
28for i in range(0, len(input_data)):
29 if input_data[i].startswith('elif option == \'opt\':'):
30 a = True
31 print('line found')
32 if a:
33 if input_data[i].startswith(' global_env.Append(CCFLAGS'):
34 output.append(option)
35 a = False
36 print('option changed')
37 else:
38 output.append(input_data[i])
39 else:
40 output.append(input_data[i])
41fobj.close()
42fobj = open(sconstruct_path, 'w')
43for i in output:
44 fobj.write(i)