From 6b2883a637fe73492f09816ee95b00c1b88d5fcb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuli=20Sepp=C3=A4nen?= Date: Thu, 14 Apr 2011 17:18:47 +0300 Subject: Change all CRLF linefeeds to LF linefeeds MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Samuli Seppänen Acked-by: David Sommerseth Signed-off-by: David Sommerseth --- win/autodefs.h.in | 62 ++++----- win/build.py | 8 +- win/build_ddk.py | 108 +++++++-------- win/build_exe.py | 30 ++--- win/config_all.py | 26 ++-- win/config_tap.py | 70 +++++----- win/config_ti.py | 36 ++--- win/js.py | 20 +-- win/make_dist.py | 32 ++--- win/msvc.mak.in | 84 ++++++------ win/show.py | 14 +- win/sign.py | 38 +++--- win/tap_span.py | 244 +++++++++++++++++----------------- win/wb.py | 388 +++++++++++++++++++++++++++--------------------------- 14 files changed, 580 insertions(+), 580 deletions(-) (limited to 'win') diff --git a/win/autodefs.h.in b/win/autodefs.h.in index 2edd9b6..ad0af19 100644 --- a/win/autodefs.h.in +++ b/win/autodefs.h.in @@ -1,31 +1,31 @@ -#ifndef AUTODEFS_H -#define AUTODEFS_H - -/* - * Minimum TAP-Win32 version number expected by userspace - * - * The TAP-Win32 version number is defined in tap-win32/SOURCES - */ -#define TAP_ID "@PRODUCT_TAP_ID@" -#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@ -#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@ - -/* Friendly name for TAP driver */ -#define PRODUCT_TAP_DEVICE_DESCRIPTION "@PRODUCT_TAP_DEVICE_DESCRIPTION@" - -/* Version number of DDK/WDK used to build TAP driver */ -#define DDKVER_MAJOR @DDKVER_MAJOR@ - -/* Name of package */ -#define PACKAGE "@PRODUCT_UNIX_NAME@" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "@PRODUCT_NAME@" - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "@PRODUCT_VERSION@" - -#endif +#ifndef AUTODEFS_H +#define AUTODEFS_H + +/* + * Minimum TAP-Win32 version number expected by userspace + * + * The TAP-Win32 version number is defined in tap-win32/SOURCES + */ +#define TAP_ID "@PRODUCT_TAP_ID@" +#define TAP_WIN32_MIN_MAJOR @PRODUCT_TAP_WIN32_MIN_MAJOR@ +#define TAP_WIN32_MIN_MINOR @PRODUCT_TAP_WIN32_MIN_MINOR@ + +/* Friendly name for TAP driver */ +#define PRODUCT_TAP_DEVICE_DESCRIPTION "@PRODUCT_TAP_DEVICE_DESCRIPTION@" + +/* Version number of DDK/WDK used to build TAP driver */ +#define DDKVER_MAJOR @DDKVER_MAJOR@ + +/* Name of package */ +#define PACKAGE "@PRODUCT_UNIX_NAME@" + +/* Define to the full name of this package. */ +#define PACKAGE_NAME "@PRODUCT_NAME@" + +/* Define to the one symbol short name of this package. */ +#define PACKAGE_TARNAME "@PRODUCT_UNIX_NAME@" + +/* Define to the version of this package. */ +#define PACKAGE_VERSION "@PRODUCT_VERSION@" + +#endif diff --git a/win/build.py b/win/build.py index 25f70c4..69137f2 100644 --- a/win/build.py +++ b/win/build.py @@ -17,7 +17,7 @@ def clean(): # if we are run directly, and not loaded as a module if __name__ == "__main__": - if len(sys.argv) == 2 and sys.argv[1] == 'clean': - clean() - else: - main() + if len(sys.argv) == 2 and sys.argv[1] == 'clean': + clean() + else: + main() diff --git a/win/build_ddk.py b/win/build_ddk.py index 3be7252..a197bf5 100644 --- a/win/build_ddk.py +++ b/win/build_ddk.py @@ -1,55 +1,55 @@ -import os -from wb import system, home_fn, choose_arch - -def build_ddk(config, dir, x64): - ddk_path = config['DDK_PATH'] - ddk_major = int(config['DDKVER_MAJOR']) - debug = 'PRODUCT_TAP_DEBUG' in config - return build_tap(ddk_path, ddk_major, debug, dir, x64) - -def build_tap(ddk_path, ddk_major, debug, dir, x64): +import os +from wb import system, home_fn, choose_arch + +def build_ddk(config, dir, x64): + ddk_path = config['DDK_PATH'] + ddk_major = int(config['DDKVER_MAJOR']) + debug = 'PRODUCT_TAP_DEBUG' in config + return build_tap(ddk_path, ddk_major, debug, dir, x64) + +def build_tap(ddk_path, ddk_major, debug, dir, x64): """Build drivers using WinDDK tools""" - setenv_bat = os.path.realpath(os.path.join(ddk_path, 'bin/setenv.bat')) - target = 'chk' if debug else 'fre' - if x64: - target += ' x64' - else: - target += ' x86' - if ddk_major >= 7600: - if x64: - target += ' wlh' # vista - else: - target += ' wnet' # server 2003 - else: - if x64: - target += ' wnet' # server 2003 - else: - target += ' w2k' # 2000 - - system('cmd /c "%s %s %s && cd %s && build -cef"' % ( - setenv_bat, - os.path.realpath(ddk_path), - target, - dir - )) - -def main(config, proj, arch): - if proj == 'tap': - dir = home_fn('tap-win32') - elif proj == 'tapinstall': - dir = home_fn('tapinstall') - else: - raise ValueError("unknown project: %s" % (proj,)) - - for x64 in choose_arch(arch): - build_ddk(config, dir, x64) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - import sys - from wb import config - if len(sys.argv) >= 3: - main(config, sys.argv[1], sys.argv[2]) - else: - print "usage: build " - sys.exit(2) + setenv_bat = os.path.realpath(os.path.join(ddk_path, 'bin/setenv.bat')) + target = 'chk' if debug else 'fre' + if x64: + target += ' x64' + else: + target += ' x86' + if ddk_major >= 7600: + if x64: + target += ' wlh' # vista + else: + target += ' wnet' # server 2003 + else: + if x64: + target += ' wnet' # server 2003 + else: + target += ' w2k' # 2000 + + system('cmd /c "%s %s %s && cd %s && build -cef"' % ( + setenv_bat, + os.path.realpath(ddk_path), + target, + dir + )) + +def main(config, proj, arch): + if proj == 'tap': + dir = home_fn('tap-win32') + elif proj == 'tapinstall': + dir = home_fn('tapinstall') + else: + raise ValueError("unknown project: %s" % (proj,)) + + for x64 in choose_arch(arch): + build_ddk(config, dir, x64) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + import sys + from wb import config + if len(sys.argv) >= 3: + main(config, sys.argv[1], sys.argv[2]) + else: + print "usage: build " + sys.exit(2) diff --git a/win/build_exe.py b/win/build_exe.py index 087f9a3..dae4825 100644 --- a/win/build_exe.py +++ b/win/build_exe.py @@ -1,15 +1,15 @@ -from config import main as config_main -from build import main as build_openvpn -from build_ddk import main as build_ddk -from sign import main as sign -from make_dist import main as make_dist - -def main(config): - config_main(config) - build_openvpn() - make_dist(config, tap=False) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - from wb import config - main(config) +from config import main as config_main +from build import main as build_openvpn +from build_ddk import main as build_ddk +from sign import main as sign +from make_dist import main as make_dist + +def main(config): + config_main(config) + build_openvpn() + make_dist(config, tap=False) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + from wb import config + main(config) diff --git a/win/config_all.py b/win/config_all.py index 2686780..ba6affe 100644 --- a/win/config_all.py +++ b/win/config_all.py @@ -1,13 +1,13 @@ -from config import main as config_main -from config_tap import main as config_tap -from config_ti import main as config_ti - -def main(config): - config_main(config) - config_tap(config) - config_ti(config) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - from wb import config - main(config) +from config import main as config_main +from config_tap import main as config_tap +from config_ti import main as config_ti + +def main(config): + config_main(config) + config_tap(config) + config_ti(config) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + from wb import config + main(config) diff --git a/win/config_tap.py b/win/config_tap.py index e69ee9b..a5b1d6c 100644 --- a/win/config_tap.py +++ b/win/config_tap.py @@ -1,35 +1,35 @@ -import os -from wb import preprocess, home_fn, autogen, dict_def - -def main(config): - preprocess(config, - in_fn=home_fn('tap-win32/SOURCES.in'), - out_fn=home_fn('tap-win32/SOURCES'), - quote_begin='@@', - quote_end='@@', - head_comment='# %s\n\n' % autogen) - - preprocess(config, - in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'), - out_fn=home_fn('tap-win32/i386/OemWin2k.inf'), - quote_begin='@@', - quote_end='@@', - if_prefix='!', - head_comment='; %s\n\n' % autogen) - - try: - os.mkdir(home_fn('tap-win32/amd64')) - except: - pass - preprocess(dict_def(config, [('AMD64', '1')]), - in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'), - out_fn=home_fn('tap-win32/amd64/OemWin2k.inf'), - quote_begin='@@', - quote_end='@@', - if_prefix='!', - head_comment='; %s\n\n' % autogen) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - from wb import config - main(config) +import os +from wb import preprocess, home_fn, autogen, dict_def + +def main(config): + preprocess(config, + in_fn=home_fn('tap-win32/SOURCES.in'), + out_fn=home_fn('tap-win32/SOURCES'), + quote_begin='@@', + quote_end='@@', + head_comment='# %s\n\n' % autogen) + + preprocess(config, + in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'), + out_fn=home_fn('tap-win32/i386/OemWin2k.inf'), + quote_begin='@@', + quote_end='@@', + if_prefix='!', + head_comment='; %s\n\n' % autogen) + + try: + os.mkdir(home_fn('tap-win32/amd64')) + except: + pass + preprocess(dict_def(config, [('AMD64', '1')]), + in_fn=home_fn('tap-win32/i386/OemWin2k.inf.in'), + out_fn=home_fn('tap-win32/amd64/OemWin2k.inf'), + quote_begin='@@', + quote_end='@@', + if_prefix='!', + head_comment='; %s\n\n' % autogen) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + from wb import config + main(config) diff --git a/win/config_ti.py b/win/config_ti.py index 4facaff..b495bb1 100644 --- a/win/config_ti.py +++ b/win/config_ti.py @@ -1,18 +1,18 @@ -import os, shutil -from wb import preprocess, home_fn, autogen - -def main(config): - src = os.path.join(home_fn(config['TISRC']), config['DDKVER_MAJOR']) - dest = home_fn('tapinstall') - shutil.rmtree(dest, ignore_errors=True) - shutil.copytree(src, dest) - preprocess(config, - in_fn=os.path.join(dest, 'sources.in'), - out_fn=os.path.join(dest, 'sources'), - if_prefix='!', - head_comment='# %s\n\n' % autogen) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - from wb import config - main(config) +import os, shutil +from wb import preprocess, home_fn, autogen + +def main(config): + src = os.path.join(home_fn(config['TISRC']), config['DDKVER_MAJOR']) + dest = home_fn('tapinstall') + shutil.rmtree(dest, ignore_errors=True) + shutil.copytree(src, dest) + preprocess(config, + in_fn=os.path.join(dest, 'sources.in'), + out_fn=os.path.join(dest, 'sources'), + if_prefix='!', + head_comment='# %s\n\n' % autogen) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + from wb import config + main(config) diff --git a/win/js.py b/win/js.py index c515824..d1d4db3 100644 --- a/win/js.py +++ b/win/js.py @@ -1,10 +1,10 @@ -import json - -# usage: -# print JSON().encode(kv) - -class JSON(json.JSONEncoder): - def __init__(self, **kwargs): - args = dict(sort_keys=True, indent=2) - args.update(kwargs) - json.JSONEncoder.__init__(self, **args) +import json + +# usage: +# print JSON().encode(kv) + +class JSON(json.JSONEncoder): + def __init__(self, **kwargs): + args = dict(sort_keys=True, indent=2) + args.update(kwargs) + json.JSONEncoder.__init__(self, **args) diff --git a/win/make_dist.py b/win/make_dist.py index 730ccb7..29eb2d2 100644 --- a/win/make_dist.py +++ b/win/make_dist.py @@ -3,14 +3,14 @@ from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename, run_in_vs_shell def main(config, tap=True): dist = config['DIST'] - assert dist - dist = home_fn(dist) - bin = os.path.join(dist, 'bin') - i386 = os.path.join(dist, 'i386') - amd64 = os.path.join(dist, 'amd64') + assert dist + dist = home_fn(dist) + bin = os.path.join(dist, 'bin') + i386 = os.path.join(dist, 'i386') + amd64 = os.path.join(dist, 'amd64') samples = os.path.join(dist, 'samples') - - # build dist and subdirectories + + # build dist and subdirectories rm_rf(dist) mkdir(dist) mkdir(bin) @@ -19,19 +19,19 @@ def main(config, tap=True): mkdir(samples) # copy openvpn.exe, openvpnserv.exe and their manifests - cp(home_fn('openvpn.exe'), bin) - cp(home_fn('openvpn.exe.manifest'), bin) + cp(home_fn('openvpn.exe'), bin) + cp(home_fn('openvpn.exe.manifest'), bin) cp(home_fn('service-win32/openvpnserv.exe'), bin) cp(home_fn('service-win32/openvpnserv.exe.manifest'), bin) # copy openvpn-gui cp(home_fn(config['OPENVPN_GUI_DIR']+"/"+config['OPENVPN_GUI']), bin) - - # copy DLL dependencies - cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin) + + # copy DLL dependencies + cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll'), bin) cp(home_fn(config['LZO_DIR']+'/bin/lzo2.dll.manifest'), bin) - cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin) - cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin) + cp(home_fn(config['OPENSSL_DIR']+'/bin/libeay32.dll'), bin) + cp(home_fn(config['OPENSSL_DIR']+'/bin/ssleay32.dll'), bin) cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll'), bin) cp(home_fn(config['PKCS11_HELPER_DIR']+'/lib/libpkcs11-helper-1.dll.manifest'), bin) @@ -103,5 +103,5 @@ def main(config, tap=True): # if we are run directly, and not loaded as a module if __name__ == "__main__": - from wb import config - main(config) + from wb import config + main(config) diff --git a/win/msvc.mak.in b/win/msvc.mak.in index 6c7558f..ac17ae9 100644 --- a/win/msvc.mak.in +++ b/win/msvc.mak.in @@ -7,51 +7,51 @@ # # - Everything between @<< and << is inserted into a s.c. "in-line file". This # file drives the linker (link.exe). -# - HEADERS_OBJS is expanded to all all header and source files listed in +# - HEADERS_OBJS is expanded to all all header and source files listed in # ..\Makefile.am # - OPENSSL_DIR and LZO_DIR are dynamically created from settings.in - -OPENSSL = @OPENSSL_DIR@ -OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib - -LZO = @LZO_DIR@ -LZO_DYNAMIC = lzo2.lib - -INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include - -LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib - -LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib - -EXE = openvpn.exe - -CPP=cl.exe -CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c - -LINK32=link.exe - -!ifdef PRODUCT_OPENVPN_DEBUG -# debug: -CPP_PROJ=$(CPP_ARG_COMMON) /MD /Z7 + +OPENSSL = @OPENSSL_DIR@ +OPENSSL_DYNAMIC = libeay32.lib ssleay32.lib + +LZO = @LZO_DIR@ +LZO_DYNAMIC = lzo2.lib + +INCLUDE_DIRS = -I$(OPENSSL)/include -I$(LZO)/include + +LIBS = $(OPENSSL_DYNAMIC) $(LZO_DYNAMIC) ws2_32.lib crypt32.lib iphlpapi.lib winmm.lib user32.lib gdi32.lib advapi32.lib wininet.lib + +LIB_DIRS = -LIBPATH:$(OPENSSL)\lib -LIBPATH:$(LZO)\lib + +EXE = openvpn.exe + +CPP=cl.exe +CPP_ARG_COMMON=/nologo /W3 -DWIN32 -DWIN32_LEAN_AND_MEAN -D_CONSOLE -D_MBCS -D_CRT_SECURE_NO_DEPRECATE $(INCLUDE_DIRS) /FD /c + +LINK32=link.exe + +!ifdef PRODUCT_OPENVPN_DEBUG +# debug: +CPP_PROJ=$(CPP_ARG_COMMON) /MD /Z7 LINK32_FLAGS=/nologo /subsystem:console /incremental:no /opt:ref /opt:icf /debug -!else -# release: -CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG +!else +# release: +CPP_PROJ=$(CPP_ARG_COMMON) /O2 /MD -DNDEBUG LINK32_FLAGS=/nologo /subsystem:console /incremental:no -!endif - +!endif + # HEADERS and OBJS definitions, automatically generated from ../Makefile.am -@HEADERS_OBJS@ - -openvpn : $(OBJS) - $(LINK32) @<< +@HEADERS_OBJS@ + +openvpn : $(OBJS) + $(LINK32) @<< $(LINK32_FLAGS) "/out:$(EXE)" $(LIB_DIRS) $(LIBS) $(OBJS) -<< - -clean : - del /Q $(OBJS) $(EXE) *.idb *.pdb - -.c.obj:: - $(CPP) @<< - $(CPP_PROJ) $< -<< +<< + +clean : + del /Q $(OBJS) $(EXE) *.idb *.pdb + +.c.obj:: + $(CPP) @<< + $(CPP_PROJ) $< +<< diff --git a/win/show.py b/win/show.py index cc41715..ac56e98 100644 --- a/win/show.py +++ b/win/show.py @@ -1,9 +1,9 @@ from wb import get_config -from js import JSON - -def main(): +from js import JSON + +def main(): print JSON().encode(get_config()) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - main() + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + main() diff --git a/win/sign.py b/win/sign.py index ee4ae72..67d1cbc 100644 --- a/win/sign.py +++ b/win/sign.py @@ -1,19 +1,19 @@ -import sys -from wb import config, choose_arch, home_fn - -if 'SIGNTOOL' in config: - sys.path.append(home_fn(config['SIGNTOOL'])) - -def main(conf, arch): - from signtool import SignTool - st = SignTool(conf) - for x64 in choose_arch(arch): - st.sign_verify(x64=x64) - -# if we are run directly, and not loaded as a module -if __name__ == "__main__": - if len(sys.argv) >= 2: - main(config, sys.argv[1]) - else: - print "usage: sign " - sys.exit(2) +import sys +from wb import config, choose_arch, home_fn + +if 'SIGNTOOL' in config: + sys.path.append(home_fn(config['SIGNTOOL'])) + +def main(conf, arch): + from signtool import SignTool + st = SignTool(conf) + for x64 in choose_arch(arch): + st.sign_verify(x64=x64) + +# if we are run directly, and not loaded as a module +if __name__ == "__main__": + if len(sys.argv) >= 2: + main(config, sys.argv[1]) + else: + print "usage: sign " + sys.exit(2) diff --git a/win/tap_span.py b/win/tap_span.py index 82c60d3..749f6f3 100644 --- a/win/tap_span.py +++ b/win/tap_span.py @@ -1,28 +1,28 @@ -import sys, os, shutil -from wb import config, home_fn, mod_fn, preprocess, autogen, dict_def, build_autodefs, rm_rf, mkdir_silent, cp -if 'SIGNTOOL' in config: - sys.path.append(home_fn(config['SIGNTOOL'])) -from signtool import SignTool -from build_ddk import build_tap - -ti_dir = "c:/src/tapinstall" -hi = ("c:/winddk/7600.16385.1", 7600, 7600, ("i386", "amd64")) -low = ("c:/winddk/6001.18002", 6001, 5600, ("win2k",)) -dest_top = home_fn('tap_build') -dist = home_fn(config['TAP_DIST']) - -def copy_tap(src, dest, x64): - dir = os.path.join(src, { False : 'i386', True: 'amd64' }[x64]) - mkdir_silent(dest) - for dirpath, dirnames, filenames in os.walk(dir): - for f in filenames: - root, ext = os.path.splitext(f) - if ext in ('.inf', '.cat', '.sys'): - cp(os.path.join(dir, f), dest) - break - -def copy_tapinstall(src, dest, x64): - base = { False : 'i386', True: 'amd64' }[x64] +import sys, os, shutil +from wb import config, home_fn, mod_fn, preprocess, autogen, dict_def, build_autodefs, rm_rf, mkdir_silent, cp +if 'SIGNTOOL' in config: + sys.path.append(home_fn(config['SIGNTOOL'])) +from signtool import SignTool +from build_ddk import build_tap + +ti_dir = "c:/src/tapinstall" +hi = ("c:/winddk/7600.16385.1", 7600, 7600, ("i386", "amd64")) +low = ("c:/winddk/6001.18002", 6001, 5600, ("win2k",)) +dest_top = home_fn('tap_build') +dist = home_fn(config['TAP_DIST']) + +def copy_tap(src, dest, x64): + dir = os.path.join(src, { False : 'i386', True: 'amd64' }[x64]) + mkdir_silent(dest) + for dirpath, dirnames, filenames in os.walk(dir): + for f in filenames: + root, ext = os.path.splitext(f) + if ext in ('.inf', '.cat', '.sys'): + cp(os.path.join(dir, f), dest) + break + +def copy_tapinstall(src, dest, x64): + base = { False : 'i386', True: 'amd64' }[x64] mkdir_silent(dest) for dirpath, dirnames, filenames in os.walk(home_fn(src)): for f in filenames: @@ -30,100 +30,100 @@ def copy_tapinstall(src, dest, x64): dir_name = os.path.basename(dirpath) s = os.path.join(dirpath, f) if dir_name == base: - cp(s, dest) - -def main(): - rm_rf(dest_top) - os.mkdir(dest_top) - - rm_rf(dist) - os.mkdir(dist) - - for ver in hi, low: - top = os.path.join(dest_top, str(ver[1])) - os.mkdir(top) - tap_dest = os.path.join(top, "tap-win32") - ti_dest = os.path.join(top, "tapinstall") - ti_src = os.path.join(ti_dir, str(ver[2])) - shutil.copytree(home_fn("tap-win32"), tap_dest) - shutil.copytree(ti_src, ti_dest) - - i386 = os.path.join(tap_dest, "i386") - amd64 = os.path.join(tap_dest, "amd64") - - build_amd64 = (len(ver[3]) >= 2) - - build_autodefs(config, mod_fn('autodefs.h.in'), os.path.join(top, 'autodefs.h')) - - st = SignTool(config, tap_dest) - - preprocess(config, - in_fn=os.path.join(tap_dest, 'SOURCES.in'), - out_fn=os.path.join(tap_dest, 'SOURCES'), - quote_begin='@@', - quote_end='@@', - head_comment='# %s\n\n' % autogen) - - preprocess(config, - in_fn=os.path.join(i386, 'OemWin2k.inf.in'), - out_fn=os.path.join(i386, 'OemWin2k.inf'), - quote_begin='@@', - quote_end='@@', - if_prefix='!', - head_comment='; %s\n\n' % autogen) - - preprocess(config, - in_fn=os.path.join(ti_dest, 'sources.in'), - out_fn=os.path.join(ti_dest, 'sources'), - if_prefix='!', - head_comment='# %s\n\n' % autogen) - - build_tap(ddk_path=ver[0], - ddk_major=ver[1], - debug=False, - dir=tap_dest, - x64=False) - - st.sign_verify(x64=False) - - build_tap(ddk_path=ver[0], - ddk_major=ver[1], - debug=False, - dir=ti_dest, - x64=False) - - tap_dist = os.path.join(dist, ver[3][0]) - - copy_tap(tap_dest, tap_dist, x64=False) - copy_tapinstall(ti_dest, tap_dist, x64=False) - - if build_amd64: - os.mkdir(amd64) - preprocess(dict_def(config, [('AMD64', '1')]), - in_fn=os.path.join(i386, 'OemWin2k.inf.in'), - out_fn=os.path.join(amd64, 'OemWin2k.inf'), - quote_begin='@@', - quote_end='@@', - if_prefix='!', - head_comment='; %s\n\n' % autogen) - - build_tap(ddk_path=ver[0], - ddk_major=ver[1], - debug=False, - dir=tap_dest, - x64=True) - - build_tap(ddk_path=ver[0], - ddk_major=ver[1], - debug=False, - dir=ti_dest, - x64=True) - - st.sign_verify(x64=True) - - tap_dist_x64 = os.path.join(dist, ver[3][1]) - - copy_tap(tap_dest, tap_dist_x64, x64=True) - copy_tapinstall(ti_dest, tap_dist_x64, x64=True) - -main() + cp(s, dest) + +def main(): + rm_rf(dest_top) + os.mkdir(dest_top) + + rm_rf(dist) + os.mkdir(dist) + + for ver in hi, low: + top = os.path.join(dest_top, str(ver[1])) + os.mkdir(top) + tap_dest = os.path.join(top, "tap-win32") + ti_dest = os.path.join(top, "tapinstall") + ti_src = os.path.join(ti_dir, str(ver[2])) + shutil.copytree(home_fn("tap-win32"), tap_dest) + shutil.copytree(ti_src, ti_dest) + + i386 = os.path.join(tap_dest, "i386") + amd64 = os.path.join(tap_dest, "amd64") + + build_amd64 = (len(ver[3]) >= 2) + + build_autodefs(config, mod_fn('autodefs.h.in'), os.path.join(top, 'autodefs.h')) + + st = SignTool(config, tap_dest) + + preprocess(config, + in_fn=os.path.join(tap_dest, 'SOURCES.in'), + out_fn=os.path.join(tap_dest, 'SOURCES'), + quote_begin='@@', + quote_end='@@', + head_comment='# %s\n\n' % autogen) + + preprocess(config, + in_fn=os.path.join(i386, 'OemWin2k.inf.in'), + out_fn=os.path.join(i386, 'OemWin2k.inf'), + quote_begin='@@', + quote_end='@@', + if_prefix='!', + head_comment='; %s\n\n' % autogen) + + preprocess(config, + in_fn=os.path.join(ti_dest, 'sources.in'), + out_fn=os.path.join(ti_dest, 'sources'), + if_prefix='!', + head_comment='# %s\n\n' % autogen) + + build_tap(ddk_path=ver[0], + ddk_major=ver[1], + debug=False, + dir=tap_dest, + x64=False) + + st.sign_verify(x64=False) + + build_tap(ddk_path=ver[0], + ddk_major=ver[1], + debug=False, + dir=ti_dest, + x64=False) + + tap_dist = os.path.join(dist, ver[3][0]) + + copy_tap(tap_dest, tap_dist, x64=False) + copy_tapinstall(ti_dest, tap_dist, x64=False) + + if build_amd64: + os.mkdir(amd64) + preprocess(dict_def(config, [('AMD64', '1')]), + in_fn=os.path.join(i386, 'OemWin2k.inf.in'), + out_fn=os.path.join(amd64, 'OemWin2k.inf'), + quote_begin='@@', + quote_end='@@', + if_prefix='!', + head_comment='; %s\n\n' % autogen) + + build_tap(ddk_path=ver[0], + ddk_major=ver[1], + debug=False, + dir=tap_dest, + x64=True) + + build_tap(ddk_path=ver[0], + ddk_major=ver[1], + debug=False, + dir=ti_dest, + x64=True) + + st.sign_verify(x64=True) + + tap_dist_x64 = os.path.join(dist, ver[3][1]) + + copy_tap(tap_dest, tap_dist_x64, x64=True) + copy_tapinstall(ti_dest, tap_dist_x64, x64=True) + +main() diff --git a/win/wb.py b/win/wb.py index 1dacc9b..39eadec 100644 --- a/win/wb.py +++ b/win/wb.py @@ -1,46 +1,46 @@ -# Python module containing general build functions -# for OpenVPN on Windows - -import os, re, shutil, stat - -autogen = "Automatically generated by OpenVPN Windows build system" - -def get_config(): - kv = {} - parse_version_m4(kv, home_fn('version.m4')) - parse_settings_in(kv, mod_fn('settings.in')) - - # config fixups - kv['DDKVER'] = os.path.basename(kv['DDK_PATH']) - kv['DDKVER_MAJOR'] = re.match(r'^(\d+)\.', kv['DDKVER']).groups()[0] - - if 'VERSION_SUFFIX' in kv: - kv['PRODUCT_VERSION'] += kv['VERSION_SUFFIX'] - - return kv - +# Python module containing general build functions +# for OpenVPN on Windows + +import os, re, shutil, stat + +autogen = "Automatically generated by OpenVPN Windows build system" + +def get_config(): + kv = {} + parse_version_m4(kv, home_fn('version.m4')) + parse_settings_in(kv, mod_fn('settings.in')) + + # config fixups + kv['DDKVER'] = os.path.basename(kv['DDK_PATH']) + kv['DDKVER_MAJOR'] = re.match(r'^(\d+)\.', kv['DDKVER']).groups()[0] + + if 'VERSION_SUFFIX' in kv: + kv['PRODUCT_VERSION'] += kv['VERSION_SUFFIX'] + + return kv + def get_build_params(): kv = {} parse_build_params(kv,mod_fn('settings.in')) return kv -def mod_fn(fn, src=__file__, real=True): - p = os.path.join(os.path.dirname(src), os.path.normpath(fn)) - if real: - p = os.path.realpath(p) - return p - -def home_fn(fn, real=True): - return mod_fn(os.path.join('..', fn), real=real) - -def cd_home(): - os.chdir(os.path.join(os.path.dirname(__file__), '..')) - +def mod_fn(fn, src=__file__, real=True): + p = os.path.join(os.path.dirname(src), os.path.normpath(fn)) + if real: + p = os.path.realpath(p) + return p + +def home_fn(fn, real=True): + return mod_fn(os.path.join('..', fn), real=real) + +def cd_home(): + os.chdir(os.path.join(os.path.dirname(__file__), '..')) + def cd_service_win32(): os.chdir(os.path.join(os.path.dirname(__file__), '../service-win32')) -def system(cmd): +def system(cmd): print "RUN:", cmd os.system(cmd) @@ -52,16 +52,16 @@ def run_in_vs_shell(cmd): def parse_version_m4(kv, version_m4): '''Parse define lines in version.m4''' r = re.compile(r'^define\((\w+),\[(.*)\]\)$') - f = open(version_m4) - for line in f: - line = line.rstrip() - m = re.match(r, line) + f = open(version_m4) + for line in f: + line = line.rstrip() + m = re.match(r, line) - if m: - g = m.groups() + if m: + g = m.groups() - # If we encounter PRODUCT_TAP_WIN32_MIN_MAJOR or - # PRODUCT_TAP_WIN32_MIN_MAJOR then we need to generate extra + # If we encounter PRODUCT_TAP_WIN32_MIN_MAJOR or + # PRODUCT_TAP_WIN32_MIN_MAJOR then we need to generate extra # variables, PRODUCT_TAP_MAJOR_VER and PRODUCT_TAP_MINOR_VER with # the same contents. This is necessary because tap-win32/tapdrv.c # build depends on those. @@ -71,20 +71,20 @@ def parse_version_m4(kv, version_m4): kv['PRODUCT_TAP_MINOR_VER'] = g[1] # Add the variable to build configuration - 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() - + 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 parse_build_params(kv, settings_in): r = re.compile(r'^!define\s+(ENABLE_\w+)\s+(\w+)') @@ -107,7 +107,7 @@ def dict_def(dict, newdefs): return ret def build_autodefs(kv, autodefs_in, autodefs_out): - preprocess(kv, + preprocess(kv, in_fn=autodefs_in, out_fn=autodefs_out, quote_begin='@', @@ -177,146 +177,146 @@ def preprocess(kv, in_fn, out_fn, quote_begin=None, quote_end=None, if_prefix=No return kv.get(var, '') re_macro = re_ifdef = None - - if quote_begin and quote_end: - re_macro = re.compile(r'%s(\w+)%s' % (re.escape(quote_begin), re.escape(quote_end))) - - if if_prefix: - re_ifdef = re.compile(r'^\s*%sifdef\s+(\w+)\b' % (re.escape(if_prefix),)) - re_else = re.compile(r'^\s*%selse\b' % (re.escape(if_prefix),)) - re_endif = re.compile(r'^\s*%sendif\b' % (re.escape(if_prefix),)) - - if_stack = [] - fin = open(in_fn) - fout = open(out_fn, 'w') - if head_comment: - fout.write(head_comment) - for line in fin: - if re_ifdef: - m = re.match(re_ifdef, line) - if m: - var, = m.groups() - if_stack.append(int(var in kv)) - continue - elif re.match(re_else, line): - if_stack[-1] ^= 1 - continue - elif re.match(re_endif, line): - if_stack.pop() - continue - if not if_stack or min(if_stack): - if re_macro: - line = re.sub(re_macro, repfn, line) - fout.write(line) - assert not if_stack - 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): + + if quote_begin and quote_end: + re_macro = re.compile(r'%s(\w+)%s' % (re.escape(quote_begin), re.escape(quote_end))) + + if if_prefix: + re_ifdef = re.compile(r'^\s*%sifdef\s+(\w+)\b' % (re.escape(if_prefix),)) + re_else = re.compile(r'^\s*%selse\b' % (re.escape(if_prefix),)) + re_endif = re.compile(r'^\s*%sendif\b' % (re.escape(if_prefix),)) + + if_stack = [] + fin = open(in_fn) + fout = open(out_fn, 'w') + if head_comment: + fout.write(head_comment) + for line in fin: + if re_ifdef: + m = re.match(re_ifdef, line) + if m: + var, = m.groups() + if_stack.append(int(var in kv)) + continue + elif re.match(re_else, line): + if_stack[-1] ^= 1 + continue + elif re.match(re_endif, line): + if_stack.pop() + continue + if not if_stack or min(if_stack): + if re_macro: + line = re.sub(re_macro, repfn, line) + fout.write(line) + assert not if_stack + 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): """Parse ../Makefile.am to obtain a list of .h and .c files""" - 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(title, srclist, ext): - ret = "%s =" % (title,) - for x in srclist: - ret += " \\\n\t%s.%s" % (x, ext) - ret += '\n\n' - return ret - -def make_headers_objs(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(title, srclist, ext): + ret = "%s =" % (title,) + for x in srclist: + ret += " \\\n\t%s.%s" % (x, ext) + ret += '\n\n' + return ret + +def make_headers_objs(makefile_am): """Generate HEADER and OBJS entries dynamically from ../Makefile.am""" - c, h = get_sources(makefile_am) - ret = output_mak_list('HEADERS', h, 'h') - ret += output_mak_list('OBJS', c, 'obj') - return ret - -def choose_arch(arch_name): - if arch_name == 'x64': - return (True,) - elif arch_name == 'x86': - return (False,) - elif arch_name == 'all': - return (True, False) - else: - raise ValueError("architecture ('%s') must be x86, x64, or all" % (arch_name,)) - -def rm_rf(dir): - print "REMOVE", dir - shutil.rmtree(dir, ignore_errors=True) - -def mkdir(dir): - print "MKDIR", dir - os.mkdir(dir) - -def cp_a(src, dest, dest_is_dir=True): - if dest_is_dir: - dest = os.path.join(dest, os.path.basename(src)) - print "COPY_DIR %s %s" % (src, dest) - shutil.copytree(src, dest) - -def cp(src, dest, dest_is_dir=True): - if dest_is_dir: - dest = os.path.join(dest, os.path.basename(src)) - print "COPY %s %s" % (src, dest) - shutil.copyfile(src, dest) - + c, h = get_sources(makefile_am) + ret = output_mak_list('HEADERS', h, 'h') + ret += output_mak_list('OBJS', c, 'obj') + return ret + +def choose_arch(arch_name): + if arch_name == 'x64': + return (True,) + elif arch_name == 'x86': + return (False,) + elif arch_name == 'all': + return (True, False) + else: + raise ValueError("architecture ('%s') must be x86, x64, or all" % (arch_name,)) + +def rm_rf(dir): + print "REMOVE", dir + shutil.rmtree(dir, ignore_errors=True) + +def mkdir(dir): + print "MKDIR", dir + os.mkdir(dir) + +def cp_a(src, dest, dest_is_dir=True): + if dest_is_dir: + dest = os.path.join(dest, os.path.basename(src)) + print "COPY_DIR %s %s" % (src, dest) + shutil.copytree(src, dest) + +def cp(src, dest, dest_is_dir=True): + if dest_is_dir: + dest = os.path.join(dest, os.path.basename(src)) + print "COPY %s %s" % (src, dest) + shutil.copyfile(src, dest) + def rename(src, dest): print "RENAME %s %s" % (src, dest) shutil.move(src, dest) -def rm_rf(path): - try: - shutil.rmtree(path, onerror=onerror) - except: - pass - -def onerror(func, path, exc_info): - """ - Error handler for ``shutil.rmtree``. - - If the error is due to an access error (read only file) - it attempts to add write permission and then retries. - - If the error is for another reason it re-raises the error. - - Usage : ``shutil.rmtree(path, onerror=onerror)`` - """ - if not os.access(path, os.W_OK): - # Is the error an access error ? - os.chmod(path, stat.S_IWUSR) - func(path) - else: - raise - -def mkdir_silent(dir): - try: - os.mkdir(dir) - except: - pass - -config = get_config() +def rm_rf(path): + try: + shutil.rmtree(path, onerror=onerror) + except: + pass + +def onerror(func, path, exc_info): + """ + Error handler for ``shutil.rmtree``. + + If the error is due to an access error (read only file) + it attempts to add write permission and then retries. + + If the error is for another reason it re-raises the error. + + Usage : ``shutil.rmtree(path, onerror=onerror)`` + """ + if not os.access(path, os.W_OK): + # Is the error an access error ? + os.chmod(path, stat.S_IWUSR) + func(path) + else: + raise + +def mkdir_silent(dir): + try: + os.mkdir(dir) + except: + pass + +config = get_config() -- cgit v1.2.3