2014-02-20 17:52:26 +01:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
#
|
|
|
|
# specialize_node_d.py output_file src/node.d flavor arch
|
|
|
|
#
|
|
|
|
# Specialize node.d for given flavor (`freebsd`) and arch (`x64` or `ia32`)
|
|
|
|
#
|
|
|
|
|
2018-11-19 12:09:40 +01:00
|
|
|
from __future__ import print_function
|
2014-02-20 17:52:26 +01:00
|
|
|
import re
|
|
|
|
import sys
|
|
|
|
|
|
|
|
if len(sys.argv) != 5:
|
2018-11-19 12:09:40 +01:00
|
|
|
print("usage: specialize_node_d.py outfile src/node.d flavor arch")
|
2018-12-03 11:52:35 +01:00
|
|
|
sys.exit(2)
|
2014-02-20 17:52:26 +01:00
|
|
|
|
2018-12-03 11:52:35 +01:00
|
|
|
outfile = open(sys.argv[1], 'w')
|
|
|
|
infile = open(sys.argv[2], 'r')
|
|
|
|
flavor = sys.argv[3]
|
|
|
|
arch = sys.argv[4]
|
2014-02-20 17:52:26 +01:00
|
|
|
|
|
|
|
model = r'curpsinfo->pr_dmodel == PR_MODEL_ILP32'
|
|
|
|
|
|
|
|
for line in infile:
|
|
|
|
if flavor == 'freebsd':
|
2018-12-03 11:52:35 +01:00
|
|
|
line = re.sub('procfs.d', 'psinfo.d', line)
|
2014-02-20 17:52:26 +01:00
|
|
|
if arch == 'x64':
|
2018-12-03 11:52:35 +01:00
|
|
|
line = re.sub(model, '0', line)
|
2014-02-20 17:52:26 +01:00
|
|
|
else:
|
2018-12-03 11:52:35 +01:00
|
|
|
line = re.sub(model, '1', line)
|
|
|
|
outfile.write(line)
|