0
0
mirror of https://github.com/OpenVPN/openvpn3.git synced 2024-09-20 20:13:05 +02:00
openvpn3/win/buildep.py

89 lines
3.4 KiB
Python
Raw Normal View History

import os, re
from utils import *
from parms import PARMS
2015-06-09 19:21:41 +02:00
def compile_one_file(srcfile, incdirs):
if PARMS['DEBUG']:
dbg_rel_flags = "/Zi"
else:
dbg_rel_flags = "/O2"
paths = {
"srcfile" : srcfile,
"incdirs" : ' '.join([r"/I %s" % (x,) for x in incdirs]),
"dbg_rel_flags" : dbg_rel_flags,
}
vc_cmd(PARMS, r"cl /c /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS %(incdirs)s /EHsc /MD /W3 %(dbg_rel_flags)s /nologo %(srcfile)s" % paths, arch=os.environ.get("ARCH"))
2015-06-09 19:21:41 +02:00
def build_asio():
2015-06-09 19:21:41 +02:00
print "**************** ASIO"
with Cd(build_dir(PARMS)) as cd:
with ModEnv('PATH', "%s\\bin;%s" % (PARMS.get('GIT'), os.environ['PATH'])):
d = expand('asio', PARMS['DEP'], PARMS.get('LIB_VERSIONS'))
2015-06-09 19:21:41 +02:00
def build_polarssl():
2015-06-09 19:21:41 +02:00
print "**************** PolarSSL"
with Cd(build_dir(PARMS)) as cd:
with ModEnv('PATH', "%s\\bin;%s" % (PARMS.get('GIT'), os.environ['PATH'])):
2015-06-09 19:21:41 +02:00
dist = os.path.realpath('polarssl')
rmtree(dist)
d = expand('polarssl', PARMS['DEP'], PARMS.get('LIB_VERSIONS'))
2015-06-09 19:21:41 +02:00
if d.endswith("-gpl"):
d = d[:-4]
os.rename(d, dist)
# copy our custom config.h
cp(os.path.join(PARMS['OVPN3'], 'core', 'deps', 'polarssl', 'config.h'),
2015-06-09 19:21:41 +02:00
os.path.join(dist, 'include', 'polarssl', 'config.h'))
with open(os.path.join(dist, 'include', 'polarssl', 'openvpn-polarssl.h'), 'w') as f:
f.write("// automatically generated by buildep.py\n#define POLARSSL_SELF_TEST\n")
#f.write("#define POLARSSL_SSL_SRV_C\n") # needed to build test proto.cpp
# compile the source files
os.chdir(os.path.join(dist, "library"))
obj = []
for dirpath, dirnames, filenames in os.walk("."):
for f in filenames:
if f.endswith(".c"):
compile_one_file(f, (r"..\include",))
obj.append(f[:-2]+".obj")
break
# collect object files into polarssl.lib
vc_cmd(PARMS, r"lib /OUT:polarssl.lib " + ' '.join(obj))
def build_lz4():
2015-06-09 19:21:41 +02:00
print "**************** LZ4"
with Cd(build_dir(PARMS)) as cd:
with ModEnv('PATH', "%s\\bin;%s" % (PARMS.get('GIT'), os.environ['PATH'])):
2015-06-09 19:21:41 +02:00
dist = os.path.realpath('lz4')
rmtree(dist)
d = expand('lz4', PARMS['DEP'], PARMS.get('LIB_VERSIONS'))
2015-06-09 19:21:41 +02:00
os.rename(d, dist)
os.chdir(dist)
compile_one_file("lz4.c", ())
vc_cmd(PARMS, r"lib /OUT:lz4.lib lz4.obj")
def build_jsoncpp():
if 'jsoncpp' in PARMS['LIB_VERSIONS']:
print "**************** JSONCPP"
with Cd(build_dir(PARMS)) as cd:
with ModEnv('PATH', "%s\\bin;%s" % (PARMS.get('GIT'), os.environ['PATH'])):
dist = os.path.realpath('jsoncpp')
rmtree(dist)
d = expand('jsoncpp', PARMS['DEP'], PARMS.get('LIB_VERSIONS'))
os.rename(d, dist)
os.chdir(dist)
call(["python", "amalgamate.py"])
os.chdir(os.path.join(dist, "dist"))
compile_one_file("jsoncpp.cpp", (".",))
vc_cmd(PARMS, r"lib /OUT:jsoncpp.lib jsoncpp.obj")
wipetree(build_dir(PARMS))
build_asio()
build_polarssl()
build_lz4()
build_jsoncpp()