diff options
author | Samuli Seppänen <samuli@openvpn.net> | 2011-04-14 17:18:47 +0300 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2011-04-14 16:38:45 +0200 |
commit | f05b6d3302b3f204ebccb606ab52244316f08d09 (patch) | |
tree | 4203a7a14434cbcceb5de60286e4c5d7b7d8b4c9 /msvc/config.py | |
parent | Add man page entry for --redirect-private (diff) | |
download | openvpn-f05b6d3302b3f204ebccb606ab52244316f08d09.tar.xz |
Change all CRLF linefeeds to LF linefeeds
Signed-off-by: Samuli Seppänen <samuli@openvpn.net>
Acked-by: David Sommerseth <davids@redhat.com>
Signed-off-by: David Sommerseth <davids@redhat.com>
(cherry picked from commit 6b2883a637fe73492f09816ee95b00c1b88d5fcb)
Diffstat (limited to '')
-rw-r--r-- | msvc/config.py | 186 |
1 files changed, 93 insertions, 93 deletions
diff --git a/msvc/config.py b/msvc/config.py index 04ea4c5..9915cd0 100644 --- a/msvc/config.py +++ b/msvc/config.py @@ -1,93 +1,93 @@ -# build autodefs.h and
-
-import re
-
-autogen = "Automatically generated by config.py"
-
-def parse_version_m4(kv, version_m4):
- r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
- f = open(version_m4)
- for line in f:
- line = line.rstrip()
- m = re.match(r, line)
- if m:
- g = m.groups()
- kv[g[0]] = g[1]
- f.close()
-
-def parse_settings_in(kv, settings_in):
- r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)$')
- f = open(settings_in)
- for line in f:
- line = line.rstrip()
- m = re.match(r, line)
- if m:
- g = m.groups()
- kv[g[0]] = g[1] or ''
- f.close()
-
-def build_autodefs(kv, autodefs_in, autodefs_out):
- def repfn(m):
- var, = m.groups()
- return kv.get(var, '')
-
- r = re.compile(r'@(\w+)@')
- fin = open(autodefs_in)
- fout = open(autodefs_out, 'w')
- fout.write("/* %s */\n\n" % autogen)
- for line in fin:
- newline = re.sub(r, repfn, line)
- fout.write(newline)
- fin.close()
- fout.close()
-
-def print_key_values(kv):
- for k, v in sorted(kv.items()):
- print "%s%s%s" % (k, ' '*(32-len(k)), repr(v))
-
-def get_sources(makefile_am):
- c = set()
- h = set()
- f = open(makefile_am)
- state = False
- for line in f:
- line = line.rstrip()
- if line == 'openvpn_SOURCES = \\':
- state = True
- elif not line:
- state = False
- elif state:
- for sf in line.split():
- if sf.endswith('.c'):
- c.add(sf[:-2])
- elif sf.endswith('.h'):
- h.add(sf[:-2])
- elif sf == '\\':
- pass
- else:
- print >>sys.stderr, "Unrecognized filename:", sf
- f.close()
- return [ sorted(list(s)) for s in (c, h) ]
-
-def output_mak_list(out, title, srclist, ext):
- out.write("%s =" % (title,))
- for x in srclist:
- out.write(" \\\n\t%s.%s" % (x, ext))
- out.write('\n\n')
-
-def output_mak(makefile_am, outfile):
- c, h = get_sources(makefile_am)
- out = open(outfile, 'w')
- out.write("# %s\n\n" % autogen)
- output_mak_list(out, 'HEADERS', h, 'h')
- output_mak_list(out, 'OBJS', c, 'obj')
- out.close()
-
-def main():
- kv = {}
- parse_version_m4(kv, 'version.m4')
- parse_settings_in(kv, 'install-win32/settings.in')
- build_autodefs(kv, 'msvc/autodefs.h.in', 'autodefs.h')
- output_mak('Makefile.am', 'head_obj.mak')
-
-main()
+# build autodefs.h and + +import re + +autogen = "Automatically generated by config.py" + +def parse_version_m4(kv, version_m4): + r = re.compile(r'^define\((\w+),\[(.*)\]\)$') + f = open(version_m4) + for line in f: + line = line.rstrip() + m = re.match(r, line) + if m: + g = m.groups() + kv[g[0]] = g[1] + f.close() + +def parse_settings_in(kv, settings_in): + r = re.compile(r'^!define\s+(\w+)(?:\s+"?(.*?)"?)$') + f = open(settings_in) + for line in f: + line = line.rstrip() + m = re.match(r, line) + if m: + g = m.groups() + kv[g[0]] = g[1] or '' + f.close() + +def build_autodefs(kv, autodefs_in, autodefs_out): + def repfn(m): + var, = m.groups() + return kv.get(var, '') + + r = re.compile(r'@(\w+)@') + fin = open(autodefs_in) + fout = open(autodefs_out, 'w') + fout.write("/* %s */\n\n" % autogen) + for line in fin: + newline = re.sub(r, repfn, line) + fout.write(newline) + fin.close() + fout.close() + +def print_key_values(kv): + for k, v in sorted(kv.items()): + print "%s%s%s" % (k, ' '*(32-len(k)), repr(v)) + +def get_sources(makefile_am): + c = set() + h = set() + f = open(makefile_am) + state = False + for line in f: + line = line.rstrip() + if line == 'openvpn_SOURCES = \\': + state = True + elif not line: + state = False + elif state: + for sf in line.split(): + if sf.endswith('.c'): + c.add(sf[:-2]) + elif sf.endswith('.h'): + h.add(sf[:-2]) + elif sf == '\\': + pass + else: + print >>sys.stderr, "Unrecognized filename:", sf + f.close() + return [ sorted(list(s)) for s in (c, h) ] + +def output_mak_list(out, title, srclist, ext): + out.write("%s =" % (title,)) + for x in srclist: + out.write(" \\\n\t%s.%s" % (x, ext)) + out.write('\n\n') + +def output_mak(makefile_am, outfile): + c, h = get_sources(makefile_am) + out = open(outfile, 'w') + out.write("# %s\n\n" % autogen) + output_mak_list(out, 'HEADERS', h, 'h') + output_mak_list(out, 'OBJS', c, 'obj') + out.close() + +def main(): + kv = {} + parse_version_m4(kv, 'version.m4') + parse_settings_in(kv, 'install-win32/settings.in') + build_autodefs(kv, 'msvc/autodefs.h.in', 'autodefs.h') + output_mak('Makefile.am', 'head_obj.mak') + +main() |