def generate_common_define_sh_file(xls_head_, xls_row_grid, xls_col_grid, output_dir, install_prefix): file_path = os.path.join(output_dir, 'common_define.sh') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") content = '''#!/bin/bash ############################################################################### # author: BrentHuang ([email protected]) ############################################################################### ''' fp.write(content.encode('utf-8')) content = ['THIRD_PARTY_INSTALL_PREFIX=', install_prefix, '/${BUILD_TYPE}', os.linesep * 2] fp.write(''.join(content).encode('utf-8')) output_basenames(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_src_dirs(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_install_dirs(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_src_dir_list(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_libs_list(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_unzip_function(fp, xls_head_, xls_row_grid, xls_col_grid, '') fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_common_define_sh_file(xls_head_, xls_row_grid, xls_col_grid, output_dir): file_path = os.path.join(output_dir, 'common_define.sh') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") content = '''#!/bin/bash ############################################################################### # author: BrentHuang ([email protected]) ############################################################################### ''' fp.write(content.encode('utf-8')) output_basenames(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_src_dirs(fp, xls_head_, xls_row_grid, xls_col_grid, '') output_unzip_function(fp, xls_head_, xls_row_grid, xls_col_grid, '') fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_conf_mgr_h_file(xls_head_, xls_row_grid, xls_col_grid, output_dir): file_path = os.path.join(output_dir, 'xx_conf_mgr.h') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") output_file_header(fp, xls_head_, xls_row_grid, xls_col_grid, '') indent = ' ' * 4 # output_typedef(fp, xls_head_, xls_row_grid, xls_col_grid, indent) content = ''' ConfMgr(); virtual ~ConfMgr(); private: ///////////////////////// base::ConfMgrInterface ///////////////////////// int Load() override; public: ///////////////////////// ConfMgrInterface ///////////////////////// ''' fp.write(content.encode('utf-8')) output_get_functions(fp, xls_head_, xls_row_grid, xls_col_grid, indent) output_load_functions(fp, xls_head_, xls_row_grid, xls_col_grid, indent) output_variable_declare(fp, xls_head_, xls_row_grid, xls_col_grid, indent) content = '''}; } #endif // XX_CONF_MGR_H_ ''' fp.write(content.encode('utf-8')) fp.close() file_util.replace_content(file_path, [ "Tcp TCP", "Io IO", "Cpu CPU", "Udp UDP", "Http HTTP", "Tq TQ", "Ws WS", "Wss WSS", "WSs WSS", "Zk ZK" ]) print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def output_file(msg, output_dir, pkg_name): file_path = os.path.join(output_dir, msg + 'Handler.cs') file_util.del_file(file_path) file_util.make_dir(file_util.file_dir(file_path)) try: fp = open(file_path, 'wb') output_file_content(fp, msg, pkg_name) fp.close() print('=== generate %s done ===' % file_path) except Exception as e: print('exception: %s' % e) return -1 return 0
def output_header_file(msg, output_dir, namespace_list): for namespace in namespace_list: file_path = os.path.join(output_dir, namespace, name_style_util.camel_to_underline(msg).lower() + '_handler.h') file_util.del_file(file_path) file_util.make_dir(file_util.file_dir(file_path)) try: fp = open(file_path, 'wb') output_header_file_content(fp, msg, namespace) fp.close() print('=== generate %s done ===' % file_path) except Exception as e: print('exception: %s' % e) return -1 return 0
def generate_conf_xpath_file(xls_head_, xls_row_grid, xls_col_grid, output_dir): file_path = os.path.join(output_dir, 'xx_conf_xpath.h') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") output_content(fp, xls_head_, xls_row_grid, xls_col_grid, '') fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_msg_id_proto_file(msg_proto_file, msg_list_group, output_dir, base_idx, gap, pkg_name, namespace_list): file_name = file_util.base_filename(msg_proto_file) file_path = os.path.join( output_dir, file_name[:len(file_name) - len('_msg')] + '_msg_id.proto') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") output_content(fp, msg_list_group, base_idx, gap, pkg_name) fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_err_code_json_file(xls_head_, xls_row_grid, xls_col_grid, output_dir): file_path = os.path.join(output_dir, 'err_code.json') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") indent = ' ' * 4 output_content(fp, xls_head_, xls_row_grid, xls_col_grid, indent) fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_inc_dir_file(xls_head_, xls_row_grid, xls_col_grid, output_dir, install_prefix): file_path = os.path.join(output_dir, 'inc_dir.txt') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") content = ['THIRD_PARTY_INSTALL_PREFIX=', install_prefix, '/${BUILD_TYPE}', os.linesep] fp.write(''.join(content).encode('utf-8')) output_content(fp, xls_head_, xls_row_grid, xls_col_grid, '') fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def generate_common_define_cmake_file(xls_head_, xls_row_grid, xls_col_grid, output_dir, install_prefix): file_path = os.path.join(output_dir, 'common_define.cmake') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") content = '''############################################################################### # author: BrentHuang ([email protected]) ############################################################################### ''' fp.write(content.encode('utf-8')) content = [ 'string(TOLOWER ${CMAKE_BUILD_TYPE} BUILD_TYPE)', os.linesep ] fp.write(''.join(content).encode('utf-8')) content = [ 'set(THIRD_PARTY_INSTALL_PREFIX ', install_prefix, '/${BUILD_TYPE})', os.linesep ] fp.write(''.join(content).encode('utf-8')) output_content(fp, xls_head_, xls_row_grid, xls_col_grid, '') fp.close() print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1
def output_file(msg, output_dir, pkg_name, namespace_list): for namespace in namespace_list: if 'http' == namespace: continue file_path = os.path.join( output_dir, namespace, name_style_util.camel_to_underline(msg).lower().replace( '_req', '') + '_test.py') file_util.del_file(file_path) file_util.make_dir(file_util.file_dir(file_path)) try: fp = open(file_path, 'wb') output_file_content(fp, msg, pkg_name, namespace) fp.close() print('=== generate %s done ===' % file_path) except Exception as e: print('exception: %s' % e) return -1 return 0
def generate_conf_mgr_cpp_file(xls_head_, xls_row_grid, xls_col_grid, output_dir): file_path = os.path.join(output_dir, 'xx_conf_mgr.cpp') file_util.del_file(file_path) file_util.make_dir(output_dir) try: fp = open(file_path, "wb") indent = ' ' * 4 output_content(fp, xls_head_, xls_row_grid, xls_col_grid, indent) fp.close() file_util.replace_content(file_path, [ "Tcp TCP", "Io IO", "Cpu CPU", "Udp UDP", "Http HTTP", "Tq TQ", "Ws WS", "Wss WSS", "WSs WSS", "Zk ZK" ]) print('=== generate %s done ===' % file_path) return 0 except Exception as e: print('exception: %s' % e) return -1