1#!/usr/bin/env python 2 3# 4# specialize_node_d.py output_file src/node.d flavor arch 5# 6# Specialize node.d for given flavor (`freebsd`) and arch (`x64` or `ia32`) 7# 8 9from __future__ import print_function 10import re 11import sys 12 13if len(sys.argv) != 5: 14 print("usage: specialize_node_d.py outfile src/node.d flavor arch") 15 sys.exit(2) 16 17outfile = open(sys.argv[1], 'w') 18infile = open(sys.argv[2], 'r') 19flavor = sys.argv[3] 20arch = sys.argv[4] 21 22model = r'curpsinfo->pr_dmodel == PR_MODEL_ILP32' 23 24for line in infile: 25 if flavor == 'freebsd': 26 line = re.sub('procfs.d', 'psinfo.d', line) 27 if arch == 'x64': 28 line = re.sub(model, '0', line) 29 else: 30 line = re.sub(model, '1', line) 31 outfile.write(line) 32