def _build_openssl(self, file_name): cc.n('prepare OpenSSL pre-built package ... ', end='') if os.path.exists(self.OPENSSL_PATH_SRC): cc.w('already exists, skip.') return cc.v('') _alt_ver = '_'.join(env.ver_ossl.split('.')) file_name = 'Win32OpenSSL-{}.msi'.format(_alt_ver) installer = os.path.join(PATH_DOWNLOAD, file_name) if not os.path.exists(installer): if not utils.download_file( 'openssl installer', 'http://slproweb.com/download/{}'.format(filename), PATH_DOWNLOAD, file_name): cc.e('can not download pre-built installer of OpenSSL.') return utils.ensure_file_exists(installer) cc.w('On Windows, we use pre-built package of OpenSSL.') cc.w('The installer have been downloaded at "{}".'.format(installer)) cc.w('please install OpenSSL into "{}".'.format(self.OPENSSL_PATH_SRC)) cc.w( '\nOnce the OpenSSL installed, press Enter to continue or Q to quit...', end='') try: x = env.input() except EOFError: x = 'q' if x == 'q': return
def _build_zlib(self, file_name): if not self._download_zlib(file_name): return cc.n('build zlib library from source code... ', end='') if not os.path.exists(self.ZLIB_PATH_SRC): cc.v('') utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL) os.rename( os.path.join(PATH_EXTERNAL, 'zlib-{}'.format(env.ver_zlib)), self.ZLIB_PATH_SRC) if ctx.target_path == 'debug': olib = 'zlibd.lib' odll = 'zlibd.dll' else: olib = 'zlib.lib' odll = 'zlib.dll' out_file_lib = os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path, olib) out_file_dll = os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path, odll) if os.path.exists(out_file_lib) and os.path.exists(out_file_dll): cc.w('already exists, skip.') return cc.v('') cc.w( 'On Windows, when build zlib, need you use cmake-gui.exe to generate solution file' ) cc.w( 'for Visual Studio 2017. Visit https://docs.tp4a.com for more details.' ) cc.w( '\nOnce the zlib.sln generated, press Enter to continue or Q to quit...', end='') try: x = env.input() except EOFError: x = 'q' if x == 'q': return cc.i('build zlib...') sln_file = os.path.join(self.ZLIB_PATH_SRC, 'build', 'zlib.sln') utils.msvc_build(sln_file, 'zlib', ctx.target_path, 'win32', False) # utils.ensure_file_exists(os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path, 'zlib.lib')) # utils.ensure_file_exists(os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path, 'zlib.dll')) # utils.copy_file(os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path), os.path.join(self.ZLIB_PATH_SRC, 'lib', ctx.target_path), 'zlib.lib') # utils.copy_file(os.path.join(self.ZLIB_PATH_SRC, 'build', ctx.target_path), os.path.join(self.ZLIB_PATH_SRC, 'lib', ctx.target_path), 'zlib.dll') utils.ensure_file_exists(out_file_lib) utils.ensure_file_exists(out_file_dll)
def _build_libssh(self, file_name): cc.n('build libssh static library from source code... ', end='') if not os.path.exists(self.LIBSSH_PATH_SRC): cc.v('') utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL) os.rename(os.path.join(PATH_EXTERNAL, 'libssh-{}'.format(env.ver_libssh)), self.LIBSSH_PATH_SRC) # cc.n('fix libssh source code... ', end='') # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src', 'sftp.c')) # utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'sftp.c') cc.n('fix libssh source code... ', end='') s_name = 'libssh-{}'.format(env.ver_libssh) utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'session.c')) utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto.c')) utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto-compat.c')) utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'session.c') utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto.c') utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto-compat.c') out_file_lib = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.lib') out_file_dll = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.dll') if os.path.exists(out_file_lib) and os.path.exists(out_file_dll): cc.w('already exists, skip.') return cc.v('') cc.w('On Windows, when build libssh, need you use cmake-gui.exe to generate solution file') cc.w('for Visual Studio 2017. Visit https://docs.tp4a.com for more details.') cc.w('\nOnce the libssh.sln generated, press Enter to continue or Q to quit...', end='') try: x = env.input() except EOFError: x = 'q' if x == 'q': return cc.i('build libssh...') sln_file = os.path.join(self.LIBSSH_PATH_SRC, 'build', 'libssh.sln') utils.msvc_build(sln_file, 'ssh_shared', ctx.target_path, 'win32', False) utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.lib')) utils.ensure_file_exists(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.dll')) utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.lib') utils.copy_file(os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.dll') utils.ensure_file_exists(out_file_lib) utils.ensure_file_exists(out_file_dll)
def _build_libssh(self, file_name): cc.n('build libssh static library from source code... ', end='') if not os.path.exists(self.LIBSSH_PATH_SRC): cc.v('') utils.unzip(os.path.join(PATH_DOWNLOAD, file_name), PATH_EXTERNAL) os.rename( os.path.join(PATH_EXTERNAL, 'libssh-{}'.format(env.ver_libssh)), self.LIBSSH_PATH_SRC) # cc.n('fix libssh source code... ', end='') # utils.ensure_file_exists(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src', 'sftp.c')) # utils.copy_file(os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'sftp.c') cc.n('fix libssh source code... ', end='') s_name = 'libssh-{}'.format(env.ver_libssh) utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'session.c')) utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto.c')) utils.ensure_file_exists( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src', 'libcrypto-compat.c')) utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'session.c') utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto.c') utils.copy_file( os.path.join(PATH_EXTERNAL, 'fix-external', 'libssh', s_name, 'src'), os.path.join(self.LIBSSH_PATH_SRC, 'src'), 'libcrypto-compat.c') out_file_lib = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.lib') out_file_dll = os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path, 'ssh.dll') if os.path.exists(out_file_lib) and os.path.exists(out_file_dll): cc.w('already exists, skip.') return cc.v('') cc.w( 'On Windows, when build libssh, need you use cmake-gui.exe to generate solution file' ) cc.w( 'for Visual Studio 2017. Visit https://docs.tp4a.com for more details.' ) cc.w( '\nOnce the libssh.sln generated, press Enter to continue or Q to quit...', end='') try: x = env.input() except EOFError: x = 'q' if x == 'q': return cc.i('build libssh...') sln_file = os.path.join(self.LIBSSH_PATH_SRC, 'build', 'libssh.sln') utils.msvc_build(sln_file, 'ssh_shared', ctx.target_path, 'win32', False) utils.ensure_file_exists( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.lib')) utils.ensure_file_exists( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path, 'ssh.dll')) utils.copy_file( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.lib') utils.copy_file( os.path.join(self.LIBSSH_PATH_SRC, 'build', 'src', ctx.target_path), os.path.join(self.LIBSSH_PATH_SRC, 'lib', ctx.target_path), 'ssh.dll') utils.ensure_file_exists(out_file_lib) utils.ensure_file_exists(out_file_dll)