def build_exe(self): cc.i('build tp_assist...') sln_file = os.path.join(env.root_path, 'client', 'tp_assist_win', 'tp_assist.vs2015.sln') out_file = os.path.join(env.root_path, 'out', 'client', ctx.bits_path, ctx.target_path, 'tp_assist.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_assist', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file)
def build_exe(self): cc.i('build tp_assist...') sln_file = os.path.join(env.root_path, 'client', 'tp_assist_win', 'tp_assist.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'client', ctx.bits_path, ctx.target_path, 'tp_assist.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_assist', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file)
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 = 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_server(self): cc.n('build web server ...') # notice: now we can not build debug version of tp_web.exe if ctx.target_path == 'debug': cc.w('cannot build debug version of tp_web, skip.') else: sln_file = os.path.join(env.root_path, 'server', 'tp_web', 'src', 'tp_web.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_web.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_web', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) cc.n('build core server ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'core', 'tp_core.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_core.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_core', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) cc.n('build SSH protocol ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tpssh.dll') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tpssh', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) utils.copy_file(os.path.join(env.root_path, 'external', 'libssh', 'lib', ctx.target_path), os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path), 'ssh.dll') cc.n('build TELNET protocol ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'telnet', 'tptelnet.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tptelnet.dll') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tptelnet', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) if with_rdp: cc.n('build RDP protocol ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'rdp', 'tprdp.vs2017.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tprdp.dll') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tprdp', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file)
def build_server(self): cc.n('build web server ...') # notice: now we can not build debug version of tp_web.exe if ctx.target_path == 'debug': cc.w('cannot build debug version of tp_web, skip.') else: sln_file = os.path.join(env.root_path, 'server', 'tp_web', 'src', 'tp_web.vs2015.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_web.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_web', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) cc.n('build core server ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'core', 'tp_core.vs2015.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tp_core.exe') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tp_core', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) cc.n('build SSH protocol ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2015.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tpssh.dll') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tpssh', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file) if os.path.exists( os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'ssh', 'tpssh.vs2015.sln')): cc.n('build RDP protocol ...') sln_file = os.path.join(env.root_path, 'server', 'tp_core', 'protocol', 'rdp', 'tprdp.vs2015.sln') out_file = os.path.join(env.root_path, 'out', 'server', ctx.bits_path, ctx.target_path, 'tprdp.dll') if os.path.exists(out_file): utils.remove(out_file) utils.msvc_build(sln_file, 'tprdp', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file)
def _build_libssh(self, file_name): cc.n('build libssh static library from source code... ', end='') out_file = os.path.join(self.LIBSSH_PATH_SRC, 'lib', 'libsshMT.lib') need_build = False if not os.path.exists(out_file): need_build = True if not need_build: cc.w('already exists, skip.') return cc.v('') cc.n('prepare libssh source code... ', end='') _include = os.path.join(self.LIBSSH_PATH_SRC, 'include', 'libssh') _src = os.path.join(self.LIBSSH_PATH_SRC, 'src') if not os.path.exists(_include) or not os.path.exists(_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) _unzipped_path = os.path.join(PATH_EXTERNAL, 'libssh-{}'.format(env.ver_libssh)) utils.copy_ex(os.path.join(_unzipped_path, 'include', 'libssh'), _include) utils.copy_ex(os.path.join(_unzipped_path, 'src'), _src) utils.remove(_unzipped_path) if not os.path.exists(_include) or not os.path.exists(_src): raise RuntimeError('\ncan not prepare libssh source code.') else: cc.w('already exists, skip.') cc.i('build libssh...') sln_file = os.path.join(self.LIBSSH_PATH_SRC, 'libssh.vs2015.sln') utils.msvc_build(sln_file, 'libssh', ctx.target_path, ctx.bits_path, False) utils.ensure_file_exists(out_file)
def _build_libssh(self, file_name): if not self._download_libssh(file_name): return cc.n('build libssh 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='') 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('') build_path = os.path.join(self.LIBSSH_PATH_SRC, 'build') if not os.path.exists(build_path): utils.makedirs(build_path) openssl_path = os.path.join(PATH_EXTERNAL, 'OpenSSL') cmake_define = ' -DOPENSSL_INCLUDE_DIR={path_release}\include' \ ' -DOPENSSL_LIBRARIES={path_release}\lib\VC\static' \ ' -DWITH_SFTP=ON' \ ' -DWITH_SERVER=ON' \ ' -DWITH_GSSAPI=OFF' \ ' -DWITH_ZLIB=OFF' \ ' -DWITH_PCAP=OFF' \ ' -DWITH_STATIC_LIB=ON' \ ' -DUNIT_TESTING=OFF' \ ' -DWITH_EXAMPLES=OFF' \ ' -DWITH_BENCHMARKS=OFF' \ ' -DWITH_NACL=OFF' \ ''.format(path_release=openssl_path) # ' -DCMAKE_INSTALL_PREFIX={path_release}' # ' -DWITH_STATIC_LIB=ON' # ' -DBUILD_SHARED_LIBS=OFF' old_p = os.getcwd() try: os.chdir(build_path) utils.cmake(build_path, 'Release', False, cmake_define=cmake_define) os.chdir(build_path) # utils.sys_exec('make install') except: cc.e('can not make') raise os.chdir(old_p) # 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)