2012-01-25 00:05:44 +01:00
|
|
|
import os, re
|
|
|
|
|
|
|
|
from utils import *
|
2014-02-08 07:08:08 +01:00
|
|
|
from parms import PARMS
|
2012-01-25 00:05:44 +01:00
|
|
|
|
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,
|
|
|
|
}
|
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
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
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
def build_asio():
|
2015-06-09 19:21:41 +02:00
|
|
|
print "**************** ASIO"
|
2015-10-28 00:46:31 +01:00
|
|
|
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
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
def build_polarssl():
|
2015-06-09 19:21:41 +02:00
|
|
|
print "**************** PolarSSL"
|
2015-10-28 00:46:31 +01:00
|
|
|
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')
|
2014-02-08 07:08:08 +01:00
|
|
|
rmtree(dist)
|
2015-10-28 00:46:31 +01:00
|
|
|
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
|
2015-10-28 00:46:31 +01:00
|
|
|
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))
|
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
def build_lz4():
|
2015-06-09 19:21:41 +02:00
|
|
|
print "**************** LZ4"
|
2015-10-28 00:46:31 +01:00
|
|
|
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)
|
2015-10-28 00:46:31 +01:00
|
|
|
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")
|
2014-02-08 07:08:08 +01:00
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
def build_jsoncpp():
|
2015-09-25 04:31:48 +02:00
|
|
|
if 'jsoncpp' in PARMS['LIB_VERSIONS']:
|
|
|
|
print "**************** JSONCPP"
|
2015-10-28 00:46:31 +01:00
|
|
|
with Cd(build_dir(PARMS)) as cd:
|
|
|
|
with ModEnv('PATH', "%s\\bin;%s" % (PARMS.get('GIT'), os.environ['PATH'])):
|
2015-09-25 04:31:48 +02:00
|
|
|
dist = os.path.realpath('jsoncpp')
|
|
|
|
rmtree(dist)
|
2015-10-28 00:46:31 +01:00
|
|
|
d = expand('jsoncpp', PARMS['DEP'], PARMS.get('LIB_VERSIONS'))
|
2015-09-25 04:31:48 +02:00
|
|
|
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")
|
|
|
|
|
2015-10-28 00:46:31 +01:00
|
|
|
wipetree(build_dir(PARMS))
|
|
|
|
build_asio()
|
|
|
|
build_polarssl()
|
|
|
|
build_lz4()
|
|
|
|
build_jsoncpp()
|