Belle II Software  release-08-01-10
manipulate_SConstruct.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import sys
12 from basf2 import find_file
13 sconstruct_path = find_file('site_scons/SConstruct')
14 # sconstruct_path = '../site_scons/SConstruct'
15 
16 fobj = open(sconstruct_path)
17 
18 optionlist = [' global_env.Append(CCFLAGS = [\'-Wextra\'])\n',
19  ' global_env.Append(CCFLAGS = [\'-Wextra\',\'-O3\'])\n',
20  ' global_env.Append(CCFLAGS = [\'-Wextra\',\'-O3\', \'-native\'])\n'
21  ]
22 option = optionlist[int(sys.argv[1])]
23 a = False
24 output = []
25 input_data = []
26 for line in fobj:
27  input_data.append(line)
28 for 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])
41 fobj.close()
42 fobj = open(sconstruct_path, 'w')
43 for i in output:
44  fobj.write(i)