aboutsummaryrefslogtreecommitdiff
path: root/win
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--win/build.py36
-rw-r--r--win/build_all.py13
-rw-r--r--win/make_dist.py109
-rw-r--r--win/settings.in3
-rw-r--r--win/tap_span.py14
-rw-r--r--win/wb.py15
6 files changed, 111 insertions, 79 deletions
diff --git a/win/build.py b/win/build.py
index fdec7cf..25f70c4 100644
--- a/win/build.py
+++ b/win/build.py
@@ -1,28 +1,22 @@
-import os, sys
-from wb import system, config, home_fn, cd_home, cd_service_win32
-
-os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
-
-def build_vc(cmd):
- """Make sure environment variables are setup before build"""
- system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
-
-def main():
+import os, sys
+from wb import system, config, home_fn, cd_home, cd_service_win32, run_in_vs_shell
+
+def main():
"""Build openvpn.exe and openvpnserv.exe"""
- cd_home()
- build_vc("nmake /f %s" % (home_fn('msvc.mak'),))
+ cd_home()
+ run_in_vs_shell("nmake /f %s" % (home_fn('msvc.mak'),))
cd_service_win32()
- build_vc("nmake /f %s" % ('msvc.mak'))
-
-def clean():
+ run_in_vs_shell("nmake /f %s" % ('msvc.mak'))
+
+def clean():
"""Clean up after openvpn.exe and openvpnserv.exe build"""
- cd_home()
- build_vc("nmake /f %s clean" % (home_fn('msvc.mak'),))
+ cd_home()
+ run_in_vs_shell("nmake /f %s clean" % (home_fn('msvc.mak'),))
os.chdir("service-win32")
- build_vc("nmake /f %s clean" % ('msvc.mak'))
-
-# if we are run directly, and not loaded as a module
-if __name__ == "__main__":
+ run_in_vs_shell("nmake /f %s clean" % ('msvc.mak'))
+
+# 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:
diff --git a/win/build_all.py b/win/build_all.py
index 2c4d1aa..47716a1 100644
--- a/win/build_all.py
+++ b/win/build_all.py
@@ -54,13 +54,14 @@ def main(config):
if tap:
build_ddk(config, 'tap', 'all')
build_ddk(config, 'tapinstall', 'all')
- else:
- print "Not building the TAP driver"
-
- if signedBuild:
- sign(config, 'all')
+ if signedBuild:
+ sign(config, 'all')
+ make_dist(config,tap=True)
- make_dist(config)
+ else:
+ if 'TAP_PREBUILT' in config:
+ print "Using prebuilt TAP driver"
+ make_dist(config,tap=False)
# if we are run directly, and not loaded as a module
if __name__ == "__main__":
diff --git a/win/make_dist.py b/win/make_dist.py
index 70aaa60..730ccb7 100644
--- a/win/make_dist.py
+++ b/win/make_dist.py
@@ -1,8 +1,8 @@
-import os
-from wb import home_fn, rm_rf, mkdir, cp_a, cp, rename
-
-def main(config, tap=True):
- dist = config['DIST']
+import os
+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')
@@ -11,14 +11,13 @@ def main(config, tap=True):
samples = os.path.join(dist, 'samples')
# build dist and subdirectories
- rm_rf(dist)
- mkdir(dist)
- mkdir(bin)
- if tap:
- mkdir(i386)
- mkdir(amd64)
+ rm_rf(dist)
+ mkdir(dist)
+ mkdir(bin)
+ mkdir(i386)
+ mkdir(amd64)
mkdir(samples)
-
+
# copy openvpn.exe, openvpnserv.exe and their manifests
cp(home_fn('openvpn.exe'), bin)
cp(home_fn('openvpn.exe.manifest'), bin)
@@ -45,34 +44,64 @@ def main(config, tap=True):
cp(home_fn('sample-config-files/server.conf'), samples)
rename(os.path.join(samples,'client.conf'), os.path.join(samples, 'client.ovpn'))
rename(os.path.join(samples,'server.conf'), os.path.join(samples, 'server.ovpn'))
-
- # copy MSVC CRT
- cp_a(home_fn(config['MSVC_CRT']), bin)
-
- if tap:
- # copy TAP drivers
- for dir_name, dest in (('amd64', amd64), ('i386', i386)):
- dir = home_fn(os.path.join('tap-win32', dir_name))
- 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
-
- # Copy tapinstall.exe (usually known as devcon.exe)
- dest = {'amd64' : amd64, 'i386' : i386}
- for dirpath, dirnames, filenames in os.walk(home_fn('tapinstall')):
- for f in filenames:
- if f == 'tapinstall.exe':
- # dir_name is either i386 or amd64
- dir_name = os.path.basename(dirpath)
- src = os.path.join(dirpath, f)
- if dir_name in dest:
- cp(src, dest[dir_name])
-
-# if we are run directly, and not loaded as a module
-if __name__ == "__main__":
+ # embed manifests to executables and DLLs
+ for f in [ "openvpn.exe", "openvpnserv.exe", "lzo2.dll", "libpkcs11-helper-1.dll" ]:
+
+ outputresource = os.path.join(bin,f)
+ manifest = outputresource+".manifest"
+
+ # EXEs and DLLs require slightly different treatment
+ if f.endswith(".exe"):
+ type = "1"
+ elif f.endswith(".dll"):
+ type = "2"
+ else:
+ print "ERROR: Could not embed manifest to "+outputresouce+", bailing out."
+ sys.exit(1)
+
+ # Embed the manifest
+ run_in_vs_shell('mt.exe -manifest %s -outputresource:%s;%s' % (manifest, outputresource, type))
+
+ # copy MSVC CRT
+ cp_a(home_fn(config['MSVC_CRT']), bin)
+
+ # TAP-driver and tapinstall.exe were built, so copy those over
+ if tap:
+ drv_dir = 'tap-win32'
+ ti_dir = 'tapinstall'
+
+ # we're using prebuilt TAP-driver and tapinstall.exe
+ elif 'TAP_PREBUILT' in config:
+ drv_dir = config['TAP_PREBUILT']
+ ti_dir = config['TAP_PREBUILT']
+
+ else:
+ print "ERROR: Could not find prebuilt TAP-drivers or tapinstall.exe. Please check win/settings.in"
+ sys.exit(1)
+
+ # copy TAP drivers
+ for dir_name, dest in (('amd64', amd64), ('i386', i386)):
+ dir = home_fn(os.path.join(drv_dir, dir_name))
+ 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
+
+ # Copy tapinstall.exe (usually known as devcon.exe)
+ dest = {'amd64' : amd64, 'i386' : i386}
+ for dirpath, dirnames, filenames in os.walk(home_fn(ti_dir)):
+ for f in filenames:
+ if f == 'devcon.exe':
+ dir_name = os.path.basename(dirpath)
+ src = os.path.join(dirpath, f)
+ dst = os.path.join(dest[dir_name],'tapinstall.exe')
+ if dir_name in dest:
+ cp(src, dst, dest_is_dir=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/settings.in b/win/settings.in
index 25109e2..6dded79 100644
--- a/win/settings.in
+++ b/win/settings.in
@@ -69,6 +69,9 @@
!define SIGNTOOL "../signtool"
!define PRODUCT_SIGN_CN "openvpn"
+# Directory with prebuilt TAP drivers and tapinstall.exes
+!define TAP_PREBUILT "../tap-prebuilt"
+
; DEBUGGING -- set to something like "-DBG2"
!define OUTFILE_LABEL ""
diff --git a/win/tap_span.py b/win/tap_span.py
index 9cd127b..82c60d3 100644
--- a/win/tap_span.py
+++ b/win/tap_span.py
@@ -23,13 +23,13 @@ def copy_tap(src, dest, x64):
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:
- if f == 'tapinstall.exe':
- dir_name = os.path.basename(dirpath)
- s = os.path.join(dirpath, f)
- if dir_name == base:
+ mkdir_silent(dest)
+ for dirpath, dirnames, filenames in os.walk(home_fn(src)):
+ for f in filenames:
+ if f == 'devcon.exe':
+ dir_name = os.path.basename(dirpath)
+ s = os.path.join(dirpath, f)
+ if dir_name == base:
cp(s, dest)
def main():
diff --git a/win/wb.py b/win/wb.py
index d1b0b3e..33eefbd 100644
--- a/win/wb.py
+++ b/win/wb.py
@@ -41,12 +41,17 @@ def cd_service_win32():
os.chdir(os.path.join(os.path.dirname(__file__), '../service-win32'))
def system(cmd):
- print "RUN:", cmd
- os.system(cmd)
-
-def parse_version_m4(kv, version_m4):
+ print "RUN:", cmd
+ os.system(cmd)
+
+def run_in_vs_shell(cmd):
+ """Make sure environment variables are setup before running command"""
+ os.environ['PATH'] += ";%s\\VC" % (os.path.normpath(config['MSVC']),)
+ system('cmd /c "vcvarsall.bat x86 && %s"' % (cmd,))
+
+def parse_version_m4(kv, version_m4):
'''Parse define lines in version.m4'''
- r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
+ r = re.compile(r'^define\((\w+),\[(.*)\]\)$')
f = open(version_m4)
for line in f:
line = line.rstrip()