mirror of https://github.com/tp4a/teleport
temp.
parent
35569651a3
commit
be218571c2
|
@ -2,7 +2,7 @@
|
||||||
<module type="PYTHON_MODULE" version="4">
|
<module type="PYTHON_MODULE" version="4">
|
||||||
<component name="NewModuleRootManager">
|
<component name="NewModuleRootManager">
|
||||||
<content url="file://$MODULE_DIR$/builder" />
|
<content url="file://$MODULE_DIR$/builder" />
|
||||||
<orderEntry type="jdk" jdkName="py34-x86" jdkType="Python SDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
<component name="TestRunnerService">
|
<component name="TestRunnerService">
|
||||||
|
|
|
@ -24,7 +24,7 @@ ctx = BuildContext()
|
||||||
def main():
|
def main():
|
||||||
cc.set_default(sep='', end='\n')
|
cc.set_default(sep='', end='\n')
|
||||||
|
|
||||||
if not env.init():
|
if not env.init(warn_miss_tool=True):
|
||||||
return
|
return
|
||||||
|
|
||||||
action = None
|
action = None
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
import codecs
|
# import codecs
|
||||||
import shutil
|
# import shutil
|
||||||
import time
|
# import time
|
||||||
from core import colorconsole as cc
|
from core import colorconsole as cc
|
||||||
from core import utils
|
from core import utils
|
||||||
from core.context import *
|
from core.context import *
|
||||||
|
@ -11,17 +11,17 @@ from core.env import env
|
||||||
|
|
||||||
ctx = BuildContext()
|
ctx = BuildContext()
|
||||||
|
|
||||||
ROOT_PATH = utils.cfg.ROOT_PATH
|
# ROOT_PATH = utils.cfg.ROOT_PATH
|
||||||
PATH_EXTERNAL = os.path.join(ROOT_PATH, 'external')
|
PATH_EXTERNAL = os.path.join(env.root_path, 'external')
|
||||||
PATH_DOWNLOAD = os.path.join(PATH_EXTERNAL, '_download_')
|
PATH_DOWNLOAD = os.path.join(PATH_EXTERNAL, '_download_')
|
||||||
|
|
||||||
OPENSSL_VER = utils.cfg.ver.openssl
|
# OPENSSL_VER = env.ver_openssl
|
||||||
LIBUV_VER = utils.cfg.ver.libuv
|
# LIBUV_VER = utils.cfg.ver.libuv
|
||||||
MBEDTLS_VER = utils.cfg.ver.mbedtls
|
# MBEDTLS_VER = utils.cfg.ver.mbedtls
|
||||||
SQLITE_VER = utils.cfg.ver.sqlite
|
# SQLITE_VER = utils.cfg.ver.sqlite
|
||||||
LIBSSH_VER = utils.cfg.ver.libssh
|
# LIBSSH_VER = utils.cfg.ver.libssh
|
||||||
JSONCPP_VER = utils.cfg.ver.jsoncpp
|
# JSONCPP_VER = utils.cfg.ver.jsoncpp
|
||||||
MONGOOSE_VER = utils.cfg.ver.mongoose
|
# MONGOOSE_VER = utils.cfg.ver.mongoose
|
||||||
|
|
||||||
|
|
||||||
class BuilderBase:
|
class BuilderBase:
|
||||||
|
@ -36,8 +36,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_jsoncpp(self):
|
def build_jsoncpp(self):
|
||||||
file_name = 'jsoncpp-{}.zip'.format(JSONCPP_VER)
|
file_name = 'jsoncpp-{}.zip'.format(env.ver_jsoncpp)
|
||||||
if not utils.download_file('jsoncpp source tarball', 'https://github.com/open-source-parsers/jsoncpp/archive/{}.zip'.format(JSONCPP_VER), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('jsoncpp source tarball', 'https://github.com/open-source-parsers/jsoncpp/archive/{}.zip'.format(env.ver_jsoncpp), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_jsoncpp(file_name)
|
self._build_jsoncpp(file_name)
|
||||||
|
|
||||||
|
@ -45,8 +45,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_mongoose(self):
|
def build_mongoose(self):
|
||||||
file_name = 'mongoose-{}.zip'.format(MONGOOSE_VER)
|
file_name = 'mongoose-{}.zip'.format(env.ver_mongoose)
|
||||||
if not utils.download_file('mongoose source tarball', 'https://github.com/cesanta/mongoose/archive/{}.zip'.format(MONGOOSE_VER), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('mongoose source tarball', 'https://github.com/cesanta/mongoose/archive/{}.zip'.format(env.ver_mongoose), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_mongoose(file_name)
|
self._build_mongoose(file_name)
|
||||||
|
|
||||||
|
@ -54,10 +54,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_openssl(self):
|
def build_openssl(self):
|
||||||
file_name = 'openssl-{}.zip'.format(OPENSSL_VER)
|
file_name = 'openssl-{}.zip'.format(env.ver_openssl)
|
||||||
_alt_ver = '_'.join(OPENSSL_VER.split('.'))
|
_alt_ver = '_'.join(env.ver_openssl.split('.'))
|
||||||
#https://github.com/openssl/openssl/archive/OpenSSL_1_1_0e.zip
|
|
||||||
# if not utils.download_file('openssl source tarball', 'https://www.openssl.org/source/{}'.format(file_name), PATH_DOWNLOAD, file_name):
|
|
||||||
if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('openssl source tarball', 'https://github.com/openssl/openssl/archive/OpenSSL_{}.zip'.format(_alt_ver), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_openssl(file_name)
|
self._build_openssl(file_name)
|
||||||
|
@ -66,8 +64,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_libuv(self):
|
def build_libuv(self):
|
||||||
file_name = 'libuv-{}.zip'.format(LIBUV_VER)
|
file_name = 'libuv-{}.zip'.format(env.ver_libuv)
|
||||||
if not utils.download_file('libuv source tarball', 'https://github.com/libuv/libuv/archive/v{}.zip'.format(LIBUV_VER), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('libuv source tarball', 'https://github.com/libuv/libuv/archive/v{}.zip'.format(env.ver_libuv), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_libuv(file_name)
|
self._build_libuv(file_name)
|
||||||
|
|
||||||
|
@ -75,8 +73,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_mbedtls(self):
|
def build_mbedtls(self):
|
||||||
file_name = 'mbedtls-mbedtls-{}.zip'.format(MBEDTLS_VER)
|
file_name = 'mbedtls-mbedtls-{}.zip'.format(env.ver_mbedtls)
|
||||||
if not utils.download_file('mbedtls source tarball', 'https://github.com/ARMmbed/mbedtls/archive/mbedtls-{}.zip'.format(MBEDTLS_VER), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('mbedtls source tarball', 'https://github.com/ARMmbed/mbedtls/archive/mbedtls-{}.zip'.format(env.ver_mbedtls), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_mbedtls(file_name)
|
self._build_mbedtls(file_name)
|
||||||
|
|
||||||
|
@ -84,8 +82,8 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_libssh(self):
|
def build_libssh(self):
|
||||||
file_name = 'libssh-{}.zip'.format(LIBSSH_VER)
|
file_name = 'libssh-{}.zip'.format(env.ver_libssh)
|
||||||
if not utils.download_file('libssh source tarball', 'https://git.libssh.org/projects/libssh.git/snapshot/libssh-{}.zip'.format(LIBSSH_VER), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('libssh source tarball', 'https://git.libssh.org/projects/libssh.git/snapshot/libssh-{}.zip'.format(env.ver_libssh), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_libssh(file_name)
|
self._build_libssh(file_name)
|
||||||
|
|
||||||
|
@ -93,7 +91,7 @@ class BuilderBase:
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
def build_sqlite(self):
|
def build_sqlite(self):
|
||||||
file_name = 'sqlite-autoconf-{}.tar.gz'.format(SQLITE_VER)
|
file_name = 'sqlite-autoconf-{}.tar.gz'.format(env.ver_sqlite)
|
||||||
if not utils.download_file('sqlite source tarball', 'http://sqlite.org/2016/{}'.format(file_name), PATH_DOWNLOAD, file_name):
|
if not utils.download_file('sqlite source tarball', 'http://sqlite.org/2016/{}'.format(file_name), PATH_DOWNLOAD, file_name):
|
||||||
return
|
return
|
||||||
self._build_sqlite(file_name)
|
self._build_sqlite(file_name)
|
||||||
|
@ -101,20 +99,6 @@ class BuilderBase:
|
||||||
def _build_sqlite(self, file_name):
|
def _build_sqlite(self, file_name):
|
||||||
cc.e("this is a pure-virtual function.")
|
cc.e("this is a pure-virtual function.")
|
||||||
|
|
||||||
# def _download_file(self, desc, url, file_name):
|
|
||||||
# cc.n('downloading {} ...'.format(desc))
|
|
||||||
# if os.path.exists(os.path.join(PATH_DOWNLOAD, file_name)):
|
|
||||||
# cc.w('already exists, skip.')
|
|
||||||
# return True
|
|
||||||
#
|
|
||||||
# os.system('wget --no-check-certificate {} -O "{}/{}"'.format(url, PATH_DOWNLOAD, file_name))
|
|
||||||
#
|
|
||||||
# if not os.path.exists(os.path.join(PATH_DOWNLOAD, file_name)):
|
|
||||||
# cc.e('downloading {} from {} failed.'.format(desc, url))
|
|
||||||
# return True
|
|
||||||
#
|
|
||||||
# return True
|
|
||||||
|
|
||||||
def fix_output(self):
|
def fix_output(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -124,10 +108,72 @@ class BuilderWin(BuilderBase):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
|
|
||||||
def _init_path(self):
|
def _init_path(self):
|
||||||
cc.e("build external not works for Windows yet.")
|
self.OPENSSL_PATH_SRC = os.path.join(PATH_EXTERNAL, 'openssl')
|
||||||
|
self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp')
|
||||||
|
self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose')
|
||||||
|
self.MBEDTLS_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mbedtls')
|
||||||
|
|
||||||
def _build_openssl(self, file_name):
|
def _build_openssl(self, file_name):
|
||||||
cc.e('build openssl-static for Windows...not supported yet.')
|
cc.n('build openssl static library from source code... ', end='')
|
||||||
|
_chk_output = [
|
||||||
|
os.path.join(self.OPENSSL_PATH_SRC, 'out32', 'libeay32.lib'),
|
||||||
|
os.path.join(self.OPENSSL_PATH_SRC, 'out32', 'ssleay32.lib'),
|
||||||
|
os.path.join(self.OPENSSL_PATH_SRC, 'inc32', 'openssl', 'opensslconf.h'),
|
||||||
|
]
|
||||||
|
|
||||||
|
need_build = False
|
||||||
|
for f in _chk_output:
|
||||||
|
if not os.path.exists(f):
|
||||||
|
need_build = True
|
||||||
|
break
|
||||||
|
|
||||||
|
if not need_build:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
return
|
||||||
|
|
||||||
|
cc.v('')
|
||||||
|
cc.n('prepare openssl source code...')
|
||||||
|
_alt_ver = '_'.join(env.ver_openssl.split('.'))
|
||||||
|
if not os.path.exists(self.OPENSSL_PATH_SRC):
|
||||||
|
utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
|
||||||
|
os.rename(os.path.join(PATH_EXTERNAL, 'openssl-OpenSSL_{}'.format(_alt_ver)), self.OPENSSL_PATH_SRC)
|
||||||
|
if not os.path.exists(self.OPENSSL_PATH_SRC):
|
||||||
|
raise RuntimeError('can not prepare openssl source code.')
|
||||||
|
else:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
|
os.chdir(self.OPENSSL_PATH_SRC)
|
||||||
|
os.system('""{}" Configure VC-WIN32"'.format(env.perl))
|
||||||
|
os.system(r'ms\do_nasm')
|
||||||
|
os.system(r'"{}\VC\bin\vcvars32.bat" && nmake -f ms\nt.mak'.format(env.visual_studio_path))
|
||||||
|
|
||||||
|
for f in _chk_output:
|
||||||
|
if not os.path.exists(f):
|
||||||
|
raise RuntimeError('build openssl static library from source code failed.')
|
||||||
|
|
||||||
|
def _build_jsoncpp(self, file_name):
|
||||||
|
cc.n('prepare jsoncpp source code...')
|
||||||
|
if not os.path.exists(self.JSONCPP_PATH_SRC):
|
||||||
|
utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
|
||||||
|
os.rename(os.path.join(PATH_EXTERNAL, 'jsoncpp-{}'.format(env.ver_jsoncpp)), self.JSONCPP_PATH_SRC)
|
||||||
|
else:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
|
def _build_mongoose(self, file_name):
|
||||||
|
cc.n('prepare mongoose source code...')
|
||||||
|
if not os.path.exists(self.MONGOOSE_PATH_SRC):
|
||||||
|
utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
|
||||||
|
os.rename(os.path.join(PATH_EXTERNAL, 'mongoose-{}'.format(env.ver_mongoose)), self.MONGOOSE_PATH_SRC)
|
||||||
|
else:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
|
def _build_mbedtls(self, file_name):
|
||||||
|
cc.n('prepare mbedtls source code...')
|
||||||
|
if not os.path.exists(self.MBEDTLS_PATH_SRC):
|
||||||
|
utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL)
|
||||||
|
os.rename(os.path.join(PATH_EXTERNAL, 'mbedtls-mbedtls-{}'.format(env.ver_mbedtls)), self.MBEDTLS_PATH_SRC)
|
||||||
|
else:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
def build_sqlite(self):
|
def build_sqlite(self):
|
||||||
cc.w('sqlite not need for Windows, skip.')
|
cc.w('sqlite not need for Windows, skip.')
|
||||||
|
@ -144,11 +190,11 @@ class BuilderLinux(BuilderBase):
|
||||||
def _init_path(self):
|
def _init_path(self):
|
||||||
self.PATH_TMP = os.path.join(PATH_EXTERNAL, 'linux', 'tmp')
|
self.PATH_TMP = os.path.join(PATH_EXTERNAL, 'linux', 'tmp')
|
||||||
self.PATH_RELEASE = os.path.join(PATH_EXTERNAL, 'linux', 'release')
|
self.PATH_RELEASE = os.path.join(PATH_EXTERNAL, 'linux', 'release')
|
||||||
self.OPENSSL_PATH_SRC = os.path.join(self.PATH_TMP, 'openssl-{}'.format(OPENSSL_VER))
|
self.OPENSSL_PATH_SRC = os.path.join(self.PATH_TMP, 'openssl-{}'.format(env.ver_openssl))
|
||||||
self.LIBUV_PATH_SRC = os.path.join(self.PATH_TMP, 'libuv-{}'.format(LIBUV_VER))
|
self.LIBUV_PATH_SRC = os.path.join(self.PATH_TMP, 'libuv-{}'.format(env.ver_libuv))
|
||||||
self.MBEDTLS_PATH_SRC = os.path.join(self.PATH_TMP, 'mbedtls-mbedtls-{}'.format(MBEDTLS_VER))
|
self.MBEDTLS_PATH_SRC = os.path.join(self.PATH_TMP, 'mbedtls-mbedtls-{}'.format(env.ver_mbedtls))
|
||||||
self.LIBSSH_PATH_SRC = os.path.join(self.PATH_TMP, 'libssh-{}'.format(LIBSSH_VER))
|
self.LIBSSH_PATH_SRC = os.path.join(self.PATH_TMP, 'libssh-{}'.format(env.ver_libssh))
|
||||||
self.SQLITE_PATH_SRC = os.path.join(self.PATH_TMP, 'sqlite-autoconf-{}'.format(SQLITE_VER))
|
self.SQLITE_PATH_SRC = os.path.join(self.PATH_TMP, 'sqlite-autoconf-{}'.format(env.ver_sqlite))
|
||||||
|
|
||||||
self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp')
|
self.JSONCPP_PATH_SRC = os.path.join(PATH_EXTERNAL, 'jsoncpp')
|
||||||
self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose')
|
self.MONGOOSE_PATH_SRC = os.path.join(PATH_EXTERNAL, 'mongoose')
|
||||||
|
@ -160,7 +206,7 @@ class BuilderLinux(BuilderBase):
|
||||||
cc.n('prepare jsoncpp source code...')
|
cc.n('prepare jsoncpp source code...')
|
||||||
if not os.path.exists(self.JSONCPP_PATH_SRC):
|
if not os.path.exists(self.JSONCPP_PATH_SRC):
|
||||||
os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, PATH_EXTERNAL))
|
os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, PATH_EXTERNAL))
|
||||||
os.rename(os.path.join(PATH_EXTERNAL, 'jsoncpp-{}'.format(JSONCPP_VER)), self.JSONCPP_PATH_SRC)
|
os.rename(os.path.join(PATH_EXTERNAL, 'jsoncpp-{}'.format(env.ver_jsoncpp)), self.JSONCPP_PATH_SRC)
|
||||||
else:
|
else:
|
||||||
cc.w('already exists, skip.')
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
|
@ -168,7 +214,7 @@ class BuilderLinux(BuilderBase):
|
||||||
cc.n('prepare mongoose source code...')
|
cc.n('prepare mongoose source code...')
|
||||||
if not os.path.exists(self.MONGOOSE_PATH_SRC):
|
if not os.path.exists(self.MONGOOSE_PATH_SRC):
|
||||||
os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, PATH_EXTERNAL))
|
os.system('unzip "{}/{}" -d "{}"'.format(PATH_DOWNLOAD, file_name, PATH_EXTERNAL))
|
||||||
os.rename(os.path.join(PATH_EXTERNAL, 'mongoose-{}'.format(MONGOOSE_VER)), self.MONGOOSE_PATH_SRC)
|
os.rename(os.path.join(PATH_EXTERNAL, 'mongoose-{}'.format(env.ver_mongoose)), self.MONGOOSE_PATH_SRC)
|
||||||
else:
|
else:
|
||||||
cc.w('already exists, skip.')
|
cc.w('already exists, skip.')
|
||||||
|
|
||||||
|
@ -349,7 +395,7 @@ class BuilderLinux(BuilderBase):
|
||||||
' -DWITH_EXAMPLES=OFF' \
|
' -DWITH_EXAMPLES=OFF' \
|
||||||
' -DWITH_BENCHMARKS=OFF' \
|
' -DWITH_BENCHMARKS=OFF' \
|
||||||
' -DWITH_NACL=OFF' \
|
' -DWITH_NACL=OFF' \
|
||||||
' ..'.format(self.PATH_RELEASE, OPENSSL_VER, self.PATH_RELEASE, self.PATH_RELEASE)
|
' ..'.format(self.PATH_RELEASE, env.ver_openssl_number, self.PATH_RELEASE, self.PATH_RELEASE)
|
||||||
|
|
||||||
utils.cmake(build_path, 'Release', False, cmake_define)
|
utils.cmake(build_path, 'Release', False, cmake_define)
|
||||||
|
|
||||||
|
@ -419,14 +465,13 @@ def main():
|
||||||
|
|
||||||
builder.build_jsoncpp()
|
builder.build_jsoncpp()
|
||||||
builder.build_mongoose()
|
builder.build_mongoose()
|
||||||
|
|
||||||
builder.build_openssl()
|
builder.build_openssl()
|
||||||
####builder.build_libuv()
|
####builder.build_libuv()
|
||||||
builder.build_mbedtls()
|
builder.build_mbedtls()
|
||||||
builder.build_libssh()
|
# builder.build_libssh()
|
||||||
builder.build_sqlite()
|
builder.build_sqlite()
|
||||||
|
#
|
||||||
builder.fix_output()
|
# builder.fix_output()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
|
@ -7,6 +7,12 @@ import configparser
|
||||||
|
|
||||||
from . import colorconsole as cc
|
from . import colorconsole as cc
|
||||||
|
|
||||||
|
if platform.system().lower() == 'windows':
|
||||||
|
try:
|
||||||
|
import winreg
|
||||||
|
except ImportError:
|
||||||
|
cc.e('Can not load module `winreg`, so I can not locate toolchain for you.')
|
||||||
|
|
||||||
|
|
||||||
class Env(object):
|
class Env(object):
|
||||||
BITS_32 = 32
|
BITS_32 = 32
|
||||||
|
@ -53,13 +59,13 @@ class Env(object):
|
||||||
self.is_macos = True
|
self.is_macos = True
|
||||||
self.plat = 'macos'
|
self.plat = 'macos'
|
||||||
|
|
||||||
def init(self):
|
def init(self, warn_miss_tool=False):
|
||||||
if not self._load_config():
|
if not self._load_config(warn_miss_tool):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def _load_config(self):
|
def _load_config(self, warn_miss_tool):
|
||||||
_cfg_file = os.path.join(self.root_path, 'config.ini')
|
_cfg_file = os.path.join(self.root_path, 'config.ini')
|
||||||
if not os.path.exists(_cfg_file):
|
if not os.path.exists(_cfg_file):
|
||||||
cc.e('can not load configuration.\n\nplease copy `config.ini.in` into `config.ini` and modify it to fit your condition and try again.')
|
cc.e('can not load configuration.\n\nplease copy `config.ini.in` into `config.ini` and modify it to fit your condition and try again.')
|
||||||
|
@ -73,14 +79,17 @@ class Env(object):
|
||||||
|
|
||||||
_tmp = _cfg['external_ver']
|
_tmp = _cfg['external_ver']
|
||||||
try:
|
try:
|
||||||
self.ver_openssl = _tmp['openssl']
|
_v_openssl = _tmp['openssl'].split(',')
|
||||||
|
self.ver_openssl = _v_openssl[0].strip()
|
||||||
|
self.ver_openssl_number = _v_openssl[1].strip()
|
||||||
|
|
||||||
self.ver_libuv = _tmp['libuv']
|
self.ver_libuv = _tmp['libuv']
|
||||||
self.ver_mbedtls = _tmp['mbedtls']
|
self.ver_mbedtls = _tmp['mbedtls']
|
||||||
self.ver_sqlite = _tmp['sqlite']
|
self.ver_sqlite = _tmp['sqlite']
|
||||||
self.ver_libssh = _tmp['libssh']
|
self.ver_libssh = _tmp['libssh']
|
||||||
self.ver_jsoncpp = _tmp['jsoncpp']
|
self.ver_jsoncpp = _tmp['jsoncpp']
|
||||||
self.ver_mongoose = _tmp['mongoose']
|
self.ver_mongoose = _tmp['mongoose']
|
||||||
except IndexError:
|
except KeyError:
|
||||||
cc.e('invalid configuration file: not all necessary external version are set.')
|
cc.e('invalid configuration file: not all necessary external version are set.')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -90,15 +99,41 @@ class Env(object):
|
||||||
self.wget = _tmp['wget']
|
self.wget = _tmp['wget']
|
||||||
else:
|
else:
|
||||||
self.wget = None
|
self.wget = None
|
||||||
|
|
||||||
if self.wget is None or not os.path.exists(self.wget):
|
if self.wget is None or not os.path.exists(self.wget):
|
||||||
cc.w(' - can not find `wget.exe`, you can get it at https://eternallybored.org/misc/wget/')
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not find `wget.exe`, you can get it at https://eternallybored.org/misc/wget/')
|
||||||
|
|
||||||
if '7z' in _tmp:
|
if '7z' in _tmp:
|
||||||
self.zip7 = _tmp['7z']
|
self.zip7 = _tmp['7z']
|
||||||
else:
|
else:
|
||||||
self.zip7 = None
|
self.zip7 = None
|
||||||
if self.zip7 is None or not os.path.exists(self.zip7):
|
if self.zip7 is None or not os.path.exists(self.zip7):
|
||||||
cc.w(' - can not find `7z.exe`, you can get it at http://www.7-zip.org')
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not find `7z.exe`, you can get it at http://www.7-zip.org')
|
||||||
|
|
||||||
|
if 'nasm' in _tmp:
|
||||||
|
self.nasm = _tmp['nasm']
|
||||||
|
else:
|
||||||
|
self.nasm = self._get_nasm()
|
||||||
|
|
||||||
|
if self.nasm is None or not os.path.exists(self.nasm):
|
||||||
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not locate `nasm`, so I can build openssl.')
|
||||||
|
|
||||||
|
if 'perl' in _tmp:
|
||||||
|
self.perl = _tmp['perl']
|
||||||
|
else:
|
||||||
|
self.perl = self._get_perl()
|
||||||
|
|
||||||
|
if self.perl is None or not os.path.exists(self.perl):
|
||||||
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not locate `perl`, so I can build openssl.')
|
||||||
|
|
||||||
|
self.visual_studio_path = self._get_visual_studio_path()
|
||||||
|
if self.visual_studio_path is None or not os.path.exists(self.visual_studio_path):
|
||||||
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not locate Visual Studio installation, so I can build openssl.')
|
||||||
|
|
||||||
if 'msbuild' in _tmp:
|
if 'msbuild' in _tmp:
|
||||||
self.msbuild = _tmp['msbuild']
|
self.msbuild = _tmp['msbuild']
|
||||||
|
@ -106,7 +141,8 @@ class Env(object):
|
||||||
self.msbuild = self._get_msbuild()
|
self.msbuild = self._get_msbuild()
|
||||||
|
|
||||||
if self.msbuild is None or not os.path.exists(self.msbuild):
|
if self.msbuild is None or not os.path.exists(self.msbuild):
|
||||||
cc.w(' - can not locate `MSBuild`, so I can build nothing.')
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not locate `MSBuild`, so I can build nothing.')
|
||||||
|
|
||||||
if 'nsis' in _tmp:
|
if 'nsis' in _tmp:
|
||||||
self.nsis = _tmp['nsis']
|
self.nsis = _tmp['nsis']
|
||||||
|
@ -114,7 +150,8 @@ class Env(object):
|
||||||
self.nsis = self._get_nsis()
|
self.nsis = self._get_nsis()
|
||||||
|
|
||||||
if self.nsis is None or not os.path.exists(self.nsis):
|
if self.nsis is None or not os.path.exists(self.nsis):
|
||||||
cc.w(' - can not locate `nsis`, so I can not make installer.')
|
if warn_miss_tool:
|
||||||
|
cc.w(' - can not locate `nsis`, so I can not make installer.')
|
||||||
|
|
||||||
elif self.is_linux:
|
elif self.is_linux:
|
||||||
if 'cmake' in _tmp:
|
if 'cmake' in _tmp:
|
||||||
|
@ -123,8 +160,8 @@ class Env(object):
|
||||||
self.cmake = '/usr/bin/cmake'
|
self.cmake = '/usr/bin/cmake'
|
||||||
|
|
||||||
if not os.path.exists(self.cmake):
|
if not os.path.exists(self.cmake):
|
||||||
cc.e(' - can not locate `cmake`, so I can not build binary from source.')
|
if warn_miss_tool:
|
||||||
return False
|
cc.e(' - can not locate `cmake`, so I can not build binary from source.')
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -132,41 +169,48 @@ class Env(object):
|
||||||
# 14.0 = VS2015
|
# 14.0 = VS2015
|
||||||
# 12.0 = VS2012
|
# 12.0 = VS2012
|
||||||
# 4.0 = VS2008
|
# 4.0 = VS2008
|
||||||
chk = ['14.0', '4.0', '12.0']
|
chk = ['14.0', '12.0', '4.0']
|
||||||
|
|
||||||
msp = None
|
p = None
|
||||||
for c in chk:
|
for c in chk:
|
||||||
msp = self._winreg_read("SOFTWARE\\Microsoft\\MSBuild\\ToolsVersions\\{}".format(c), 'MSBuildToolsPath')
|
p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\MSBuild\ToolsVersions\{}'.format(c), r'MSBuildToolsPath')
|
||||||
if msp is not None:
|
if p is not None:
|
||||||
break
|
break
|
||||||
|
|
||||||
if msp is None:
|
return os.path.join(p[0], 'MSBuild.exe') if p is not None else None
|
||||||
return None
|
|
||||||
|
|
||||||
return os.path.join(msp[0], 'MSBuild.exe')
|
def _get_visual_studio_path(self):
|
||||||
|
chk = ['14.0', '12.0', '4.0']
|
||||||
|
p = None
|
||||||
|
for c in chk:
|
||||||
|
p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\Microsoft\VisualStudio\{}'.format(c), r'ShellFolder')
|
||||||
|
if p is not None:
|
||||||
|
break
|
||||||
|
|
||||||
|
return p[0] if p is not None else None
|
||||||
|
|
||||||
|
def _get_perl(self):
|
||||||
|
p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\perl', 'BinDir')
|
||||||
|
return p[0] if p is not None else None
|
||||||
|
|
||||||
|
def _get_nasm(self):
|
||||||
|
p = self._winreg_read(winreg.HKEY_CURRENT_USER, r'SOFTWARE\nasm', '')
|
||||||
|
return os.path.join(p[0], 'nasm.exe') if p is not None else None
|
||||||
|
|
||||||
def _get_nsis(self):
|
def _get_nsis(self):
|
||||||
p = self._winreg_read_wow64_32(r'SOFTWARE\NSIS\Unicode', '')
|
p = self._winreg_read(winreg.HKEY_LOCAL_MACHINE, r'SOFTWARE\NSIS\Unicode', '')
|
||||||
if p is None:
|
return os.path.join(p[0], 'makensis.exe') if p is not None else None
|
||||||
return None
|
|
||||||
|
|
||||||
return os.path.join(p[0], 'makensis.exe')
|
def _winreg_read(self, base, path, key):
|
||||||
|
|
||||||
def _winreg_read(self, path, key):
|
|
||||||
try:
|
try:
|
||||||
import winreg
|
if self.is_win_x64:
|
||||||
hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, path, 0, winreg.KEY_READ)
|
hkey = winreg.CreateKeyEx(base, path, 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
|
||||||
|
else:
|
||||||
|
hkey = winreg.CreateKeyEx(base, path, 0, winreg.KEY_READ)
|
||||||
|
|
||||||
value = winreg.QueryValueEx(hkey, key)
|
value = winreg.QueryValueEx(hkey, key)
|
||||||
return value
|
return value
|
||||||
except OSError:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def _winreg_read_wow64_32(self, path, key):
|
|
||||||
try:
|
|
||||||
import winreg
|
|
||||||
hkey = winreg.CreateKeyEx(winreg.HKEY_LOCAL_MACHINE, path, 0, winreg.KEY_READ | winreg.KEY_WOW64_32KEY)
|
|
||||||
value = winreg.QueryValueEx(hkey, key)
|
|
||||||
return value
|
|
||||||
except OSError:
|
except OSError:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@ import time
|
||||||
from . import colorconsole as cc
|
from . import colorconsole as cc
|
||||||
from .env import env
|
from .env import env
|
||||||
|
|
||||||
|
|
||||||
from .configs import cfg
|
from .configs import cfg
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -34,23 +33,39 @@ THIS_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||||
ROOT_PATH = os.path.abspath(os.path.join(THIS_PATH, '..'))
|
ROOT_PATH = os.path.abspath(os.path.join(THIS_PATH, '..'))
|
||||||
|
|
||||||
|
|
||||||
|
def _check_download_file(file_name):
|
||||||
|
if env.is_win:
|
||||||
|
# use 7z to test integrity of downloaded
|
||||||
|
ret, output = sys_exec('"{}" t "{}"'.format(env.zip7, file_name), False)
|
||||||
|
if 'Everything is Ok' in output:
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
cc.e('fixme.')
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def download_file(desc, url, target_path, file_name):
|
def download_file(desc, url, target_path, file_name):
|
||||||
cc.n('downloading {} ...'.format(desc))
|
cc.n('download {} ... '.format(desc), end='')
|
||||||
|
|
||||||
local_file_name = os.path.join(target_path, file_name)
|
local_file_name = os.path.join(target_path, file_name)
|
||||||
if os.path.exists(local_file_name):
|
if os.path.exists(local_file_name):
|
||||||
cc.w('already exists, skip.')
|
if not _check_download_file(local_file_name):
|
||||||
return True
|
cc.w('already exists but broken, download it again...')
|
||||||
|
else:
|
||||||
|
cc.w('already exists, skip.')
|
||||||
|
return True
|
||||||
|
|
||||||
|
cc.v('')
|
||||||
|
# 因为下载过程会在命令行显示进度,所以不能使用subprocess.Popen()的方式捕获输出,会很难看!
|
||||||
if env.is_win:
|
if env.is_win:
|
||||||
cmd = '"{}" --no-check-certificate {} -O "{}"'.format(env.wget, url, local_file_name)
|
cmd = '""{}" --no-check-certificate {} -O "{}""'.format(env.wget, url, local_file_name)
|
||||||
sys_exec(cmd, True)
|
os.system(cmd)
|
||||||
elif env.is_linux:
|
elif env.is_linux:
|
||||||
os.system('wget --no-check-certificate {} -O "{}"'.format(url, local_file_name))
|
os.system('wget --no-check-certificate {} -O "{}"'.format(url, local_file_name))
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if not os.path.exists(local_file_name):
|
if not os.path.exists(local_file_name) or not _check_download_file(local_file_name):
|
||||||
cc.e('downloading {} from {} failed.'.format(desc, url))
|
cc.e('downloading {} from {} failed.'.format(desc, url))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -308,8 +323,6 @@ def winreg_read_wow64_32(path, key):
|
||||||
|
|
||||||
|
|
||||||
def sys_exec(cmd, direct_output=False, output_codec=None):
|
def sys_exec(cmd, direct_output=False, output_codec=None):
|
||||||
cc.v(cmd)
|
|
||||||
# _os = platform.system().lower()
|
|
||||||
if output_codec is None:
|
if output_codec is None:
|
||||||
if env.is_win:
|
if env.is_win:
|
||||||
output_codec = 'gb2312'
|
output_codec = 'gb2312'
|
||||||
|
@ -323,17 +336,19 @@ def sys_exec(cmd, direct_output=False, output_codec=None):
|
||||||
else:
|
else:
|
||||||
p = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
|
p = subprocess.Popen(cmd, close_fds=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True, shell=True)
|
||||||
|
|
||||||
output = ''
|
output = list()
|
||||||
f = p.stdout
|
f = p.stdout
|
||||||
while True:
|
while True:
|
||||||
line = f.readline()
|
line = f.readline()
|
||||||
if 0 == len(line):
|
if 0 == len(line):
|
||||||
break
|
break
|
||||||
|
|
||||||
if direct_output:
|
line = line.rstrip('\r\n')
|
||||||
cc.o((cc.CR_GRAY, line), end='')
|
|
||||||
|
|
||||||
output += line
|
if direct_output:
|
||||||
|
cc.o((cc.CR_GRAY, line), end='\n')
|
||||||
|
|
||||||
|
output.append(line)
|
||||||
|
|
||||||
ret = p.wait()
|
ret = p.wait()
|
||||||
|
|
||||||
|
@ -418,6 +433,15 @@ def make_zip(src_path, to_file):
|
||||||
ensure_file_exists(to_file)
|
ensure_file_exists(to_file)
|
||||||
|
|
||||||
|
|
||||||
|
def unzip(file_name, to_path):
|
||||||
|
if env.is_win:
|
||||||
|
cmd = '""{}" x "{}" -o"{}""'.format(env.zip7, file_name, to_path)
|
||||||
|
print(cmd)
|
||||||
|
os.system(cmd)
|
||||||
|
elif env.is_linux:
|
||||||
|
os.system('unzip "{}" -d "{}"'.format(file_name, to_path))
|
||||||
|
|
||||||
|
|
||||||
def make_targz(work_path, folder, to_file):
|
def make_targz(work_path, folder, to_file):
|
||||||
cc.v('compress folder into .tar.gz...')
|
cc.v('compress folder into .tar.gz...')
|
||||||
old_p = os.getcwd()
|
old_p = os.getcwd()
|
||||||
|
|
|
@ -9,6 +9,13 @@ wget = C:\Program Files (x86)\wget\wget.exe
|
||||||
# Need 7z to unzip downloaded files.
|
# Need 7z to unzip downloaded files.
|
||||||
7z = C:\Program Files (x86)\7zip\7z.exe
|
7z = C:\Program Files (x86)\7zip\7z.exe
|
||||||
|
|
||||||
|
# need perl to build openssl on Windows, if not set, default to get it from register.
|
||||||
|
# suggest install ActivePerl.
|
||||||
|
#perl = C:\Perl\bin\perl.exe
|
||||||
|
|
||||||
|
# need nasm to build openssl on Windows, if not set, default to locate it from register.
|
||||||
|
#nasm = C:\Users\username\AppData\Local\NASM\nasm.exe
|
||||||
|
|
||||||
# if not set nsis path, default to get it by register.
|
# if not set nsis path, default to get it by register.
|
||||||
#nsis = C:\Program Files (x86)\NSIS\Unicode\makensis.exe
|
#nsis = C:\Program Files (x86)\NSIS\Unicode\makensis.exe
|
||||||
|
|
||||||
|
@ -25,7 +32,7 @@ cmake = /opt/cmake/bin/cmake
|
||||||
|
|
||||||
|
|
||||||
[external_ver]
|
[external_ver]
|
||||||
openssl = 1.0.2h
|
openssl = 1.0.2h,1000208f
|
||||||
libuv = 1.9.1
|
libuv = 1.9.1
|
||||||
mbedtls = 2.3.0
|
mbedtls = 2.3.0
|
||||||
sqlite = 3160200
|
sqlite = 3160200
|
||||||
|
|
Loading…
Reference in New Issue