2012-01-25 00:05:44 +01:00
|
|
|
import os, re
|
|
|
|
|
|
|
|
from utils import *
|
|
|
|
|
2015-11-01 07:46:55 +01:00
|
|
|
def compile_one_file(parms, srcfile, incdirs):
|
2015-11-03 21:11:16 +01:00
|
|
|
extra = {
|
2015-06-09 19:21:41 +02:00
|
|
|
"srcfile" : srcfile,
|
|
|
|
"incdirs" : ' '.join([r"/I %s" % (x,) for x in incdirs]),
|
|
|
|
}
|
|
|
|
|
2015-11-03 21:11:16 +01:00
|
|
|
vc_parms(parms, extra)
|
|
|
|
|
|
|
|
vc_cmd(parms, r"cl /c /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS %(incdirs)s /EHsc %(link_static_dynamic_flags)s /W3 %(dbg_rel_flags)s /nologo %(srcfile)s" % extra, arch=os.environ.get("ARCH"))
|
2015-06-09 19:21:41 +02:00
|
|
|
|
2015-11-01 07:46:55 +01:00
|
|
|
def build_asio(parms):
|
2015-06-09 19:21:41 +02:00
|
|
|
print "**************** ASIO"
|
2015-11-01 07:46:55 +01:00
|
|
|
with Cd(build_dir(parms)) as cd:
|
|
|
|
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
2015-12-29 08:07:22 +01:00
|
|
|
dist = os.path.realpath('asio')
|
|
|
|
rmtree(dist)
|
2015-11-01 07:46:55 +01:00
|
|
|
d = expand('asio', parms['DEP'], parms.get('LIB_VERSIONS'))
|
2015-12-29 08:07:22 +01:00
|
|
|
os.rename(d, dist)
|
2015-06-09 19:21:41 +02:00
|
|
|
|
2017-03-01 20:52:53 +01:00
|
|
|
def build_mbedtls(parms):
|
|
|
|
print "**************** MBEDTLS"
|
2015-11-01 07:46:55 +01:00
|
|
|
with Cd(build_dir(parms)) as cd:
|
|
|
|
with ModEnv('PATH', "%s\\bin;%s" % (parms.get('GIT'), os.environ['PATH'])):
|
2017-03-01 20:52:53 +01:00
|
|
|
dist = os.path.realpath('mbedtls')
|
2014-02-08 07:08:08 +01:00
|
|
|
rmtree(dist)
|
2017-03-01 20:52:53 +01:00
|
|
|
d = expand('mbedtls', parms['DEP'], parms.get('LIB_VERSIONS'))
|
|
|
|
if d.endswith("-apache"):
|
|
|
|
d = d[:-7]
|
2017-08-01 16:11:17 +02:00
|
|
|
elif d.endswith("-gpl"):
|
|
|
|
d = d[:-4]
|
|
|
|
|
2015-06-09 19:21:41 +02:00
|
|
|
os.rename(d, dist)
|
|
|
|
|
2017-03-01 20:52:53 +01:00
|
|
|
# edit mbedTLS config.h
|
|
|
|
conf_fn = os.path.join(dist, 'include', 'mbedtls', 'config.h')
|
|
|
|
with open(conf_fn) as f:
|
|
|
|
conf = f.read()
|
|
|
|
conf = re.sub(r"^//(?=#define MBEDTLS_MD4_C)", "", conf, flags=re.M);
|
|
|
|
with open(conf_fn, 'w') as f:
|
|
|
|
f.write(conf)
|
2015-06-09 19:21:41 +02:00
|
|
|
|
|
|
|
# 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"):
|
2015-11-01 07:46:55 +01:00
|
|
|
compile_one_file(parms, f, (r"..\include",))
|
2015-06-09 19:21:41 +02:00
|
|
|
obj.append(f[:-2]+".obj")
|
|
|
|
break
|
|
|
|
|
2017-03-01 20:52:53 +01:00
|
|
|
# collect object files into mbedtls.lib
|
|
|
|
vc_cmd(parms, r"lib /OUT:mbedtls.lib " + ' '.join(obj))
|
2015-06-09 19:21:41 +02:00
|
|
|
|
2015-11-01 07:46:55 +01:00
|
|
|
def build_lz4(parms):
|
2015-06-09 19:21:41 +02:00
|
|
|
print "**************** LZ4"
|
2015-11-01 07:46:55 +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-11-01 07:46:55 +01:00
|
|
|
d = expand('lz4', parms['DEP'], parms.get('LIB_VERSIONS'))
|
2015-06-09 19:21:41 +02:00
|
|
|
os.rename(d, dist)
|
2015-12-29 08:07:22 +01:00
|
|
|
os.chdir(os.path.join(dist, "lib"))
|
2015-11-01 07:46:55 +01:00
|
|
|
compile_one_file(parms, "lz4.c", ())
|
|
|
|
vc_cmd(parms, r"lib /OUT:lz4.lib lz4.obj")
|
2014-02-08 07:08:08 +01:00
|
|
|
|
2015-11-01 07:46:55 +01:00
|
|
|
def build_jsoncpp(parms):
|
|
|
|
if 'jsoncpp' in parms['LIB_VERSIONS']:
|
2015-09-25 04:31:48 +02:00
|
|
|
print "**************** JSONCPP"
|
2015-11-01 07:46:55 +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-11-01 07:46:55 +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"))
|
2015-11-01 07:46:55 +01:00
|
|
|
compile_one_file(parms, "jsoncpp.cpp", (".",))
|
|
|
|
vc_cmd(parms, r"lib /OUT:jsoncpp.lib jsoncpp.obj")
|
2015-09-25 04:31:48 +02:00
|
|
|
|
2015-11-01 07:46:55 +01:00
|
|
|
def build_all(parms):
|
|
|
|
wipetree(build_dir(parms))
|
|
|
|
build_asio(parms)
|
2017-03-01 20:52:53 +01:00
|
|
|
build_mbedtls(parms)
|
2015-11-01 07:46:55 +01:00
|
|
|
build_lz4(parms)
|
|
|
|
build_jsoncpp(parms)
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
from parms import PARMS
|
|
|
|
build_all(PARMS)
|