forked from IBM/xmlservice
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·31 lines (25 loc) · 1.06 KB
/
configure
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
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from argparse import ArgumentParser, Action
class UppercaseAction(Action):
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values.upper())
parser = ArgumentParser(description='Configure script')
parser.add_argument('--library', default='XMLSERVICE', action=UppercaseAction, help='Output library')
parser.add_argument('--debug', default='*ALL', help='Debug option (DBGVIEW)')
parser.add_argument('--target-release', default='*CURRENT', help='Target release (TGTRLS)')
args = parser.parse_args()
# Map command line arguments to replacement variables
# ie. --foo -> '@FOO@': args.foo
mappings = { '@' + k.upper() + '@': v for k,v in vars(args).items() }
files_to_map = (
'src/plugconf.rpgle',
'src/xmlstoredp.sql',
'Makefile',
)
for f in files_to_map:
with open(f + ".in", "r") as _in, open(f, "w") as _out:
for line in _in:
for k,v in mappings.items():
line = line.replace(k, v)
print(line, end='', file=_out)