def process_sub(export_file, renewal, langinfo): print('') # 确认当前的版本号 version = Common.get_pandas_ver(os.path.abspath(project_slndir), 'v') Message.ShowStatus('正在准备生成 {model} - {lang} 的打包目录...'.format( model = '复兴后(RE)' if renewal else '复兴前(PRE)', lang = langinfo['name'] )) # 构建解压的打包目录 packagedir = '../Release/Pandas/{version}/Pandas_{version}_{timestamp}_{model}_{lang}'.format( version = version, model = 'RE' if renewal else 'PRE', timestamp = Common.timefmt(True), lang = langinfo['dirname'] ) # 获取压缩文件的保存路径 zipfilename = os.path.abspath(project_slndir + packagedir) + '.zip' # 获取打包的绝对路径 packagedir = os.path.abspath(project_slndir + packagedir) + os.path.sep # 确保目标文件夹存在 os.makedirs(os.path.dirname(packagedir), exist_ok = True) # 若之前目录已经存在, 先删掉 if os.path.exists(packagedir) and os.path.isdir(packagedir): shutil.rmtree(packagedir) # 将 zip 文件解压到指定的目录中去 Message.ShowStatus('正在解压归档文件到: %s' % os.path.relpath( packagedir, os.path.abspath(os.path.join(packagedir, r'../../')) )) if not zip_unpack(export_file, packagedir): clean(export_file) Message.ShowError('很抱歉, 解压归档文件失败, 程序终止.') Common.exit_with_pause(-1) # 进行文本的翻译工作 trans.process(packagedir, langinfo['trans'], True) # 进行后期处理 Message.ShowStatus('正在对打包源目录进行后期处理...') if renewal: arrange_renewal(packagedir) else: arrange_pre_renewal(packagedir) Message.ShowStatus('后期处理完毕, 即将把打包源压缩成 ZIP 文件...') # 执行打包操作 if not zip_pack(packagedir, zipfilename): clean(export_file) Message.ShowError('打包成 zip 文件时失败了, 请联系开发者协助定位问题, 程序终止.') Common.exit_with_pause(-1) Message.ShowStatus('已成功构建 {model} - {lang} 的压缩文件.'.format( model = '复兴后(RE)' if renewal else '复兴前(PRE)', lang = langinfo['name'] ))
def main(): os.chdir(os.path.split(os.path.realpath(__file__))[0]) Common.welcome('版本号修改辅助脚本') print('') # 读取当前的 Pandas 主程序版本号 pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir), origin=True) Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver) print('') # 询问获取升级后的目标版本 newver = Inputer().requireText( {'tips': '请输入新的版本号 (四段式: 1.0.0.1, 最后一段为 1 则表示为开发版)'}) if not isVersionFormatValid(newver): Message.ShowError('你输入的版本号: %s 不符合四段式规则, 请重试...' % newver) Common.exit_with_pause(-1) # 执行更新操作 ver = VersionUpdater(options) ver.updateDirectory(slndir('src'), newver) Common.exit_with_pause()
def make_commit(): try: repo = git.Repo(project_symstoredir) if not repo.is_dirty() and not repo.untracked_files: Message.ShowWarning('工作区很干净, 没有任何变化文件, 无需提交.') return False repo.git.add('.') repo.git.commit('-m', '归档 Pandas {version} 版本的符号文件和编译产物, 代码源自 PandasWS/Pandas@{githash} 仓库'.format( version = Common.get_pandas_ver(project_slndir, 'v'), githash = Common.get_pandas_hash(project_slndir) )) except git.GitError as _err: Message.ShowWarning('提交失败, 原因: %s' % _err) return False else: return True
def make_commit(): try: repo = git.Repo(project_symstoredir) if not repo.is_dirty() and not repo.untracked_files: Message.ShowWarning('工作区很干净, 没有任何变化文件, 无需提交.') return False repo.git.add('.') repo.git.commit( '-m', '归档 {project_name} {version} 版本的符号文件和编译产物, 代码源自 {symbols_source}@{githash} 仓库' .format(project_name=os.getenv('DEFINE_PROJECT_NAME'), symbols_source=os.getenv('DEFINE_SYMBOLS_SOURCE'), version=Common.get_pandas_ver(project_slndir, 'v'), githash=Common.get_pandas_hash(project_slndir))) except git.GitError as _err: Message.ShowWarning('提交失败, 原因: %s' % _err) return False else: return True
def main(): ''' 主入口函数 ''' # 显示欢迎信息 Common.welcome('打包流程辅助脚本') print('') pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir)) Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver) # 检查是否已经完成了编译 if not Common.is_compiled(project_slndir): Message.ShowWarning('检测到打包需要的编译产物不完整, 请重新编译. 程序终止.') print('') Common.exit_with_pause(-1) # 导出当前仓库, 变成一个归档压缩文件 Message.ShowInfo('正在将当前分支的 HEAD 内容导出成归档文件...') export_file = export() if not export_file: Message.ShowError('很抱歉, 导出归档文件失败, 程序终止.') Common.exit_with_pause(-1) Message.ShowInfo('归档文件导出完成, 此文件将在程序结束时被删除.') # 基于归档压缩文件, 进行打包处理 process(export_file, renewal=True) process(export_file, renewal=False) # 执行一些清理工作 clean(export_file) print('') Message.ShowInfo('已经成功打包相关文件, 请进行人工核验.') # 友好退出, 主要是在 Windows 环境里给予暂停 Common.exit_with_pause()
def main(): ''' 主入口函数 ''' # 加载 .env 中的配置信息 load_dotenv(dotenv_path='.config.env', encoding='UTF-8') # 若无配置信息则自动复制一份文件出来 if not Common.is_file_exists('.config.env'): shutil.copyfile('.config.env.sample', '.config.env') # 显示欢迎信息 Common.welcome('编译流程辅助脚本') # 只能在 Windows 环境运行 if platform.system() != 'Windows': Message.ShowError('很抱歉, 此脚本只能在 Windows 环境上运行') Common.exit_with_pause(-1) # 判断本机是否安装了支持的 Visual Studio detected_vs, vs_name = detect_vs() if not detected_vs: Message.ShowError('无法检测到合适的 Visual Studio 版本 (2015 或 2017)') Common.exit_with_pause(-1) else: Message.ShowStatus('检测到已安装: %s 应可正常编译' % vs_name) print('') # 读取当前的 Pandas 主程序版本号 pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir)) Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver) # 判断是否已经写入了对应的更新日志, 若没有则要给予提示再继续 if (has_changelog(pandas_ver)): Message.ShowStatus('已经在更新日志中找到了 %s 的版本信息.' % pandas_ver) else: Message.ShowWarning('没有在更新日志中找到 %s 版本的信息, 请注意完善!' % pandas_ver) # 判断当前 git 工作区是否干净, 若工作区不干净要给予提示 if git.Repo(project_slndir).is_dirty(): if not Inputer().requireBool({ 'tips': '当前模拟器代码仓库的工作区不干净, 要继续编译吗?', 'default': False }): Message.ShowStatus('您主动放弃了继续操作') Common.exit_with_pause(-1) else: Message.ShowStatus('当前模拟器代码仓库的工作区是干净的.') # 检查 Crashrpt 使用的信息是否都设置好了, 若没有且企图编译正式版, 则给与提示 if Common.is_pandas_release(os.path.abspath(project_slndir)): if not os.getenv("DEFINE_CRASHRPT_APPID"): Message.ShowWarning('当前并未设置 AppID, 且企图编译正式版.') Common.exit_with_pause(-1) if Common.md5(os.getenv("DEFINE_CRASHRPT_APPID") ) != '952648de2d8f063a07331ae3827bc406': Message.ShowWarning('当前已设置了 AppID, 但并非正式版使用的 AppID.') Common.exit_with_pause(-1) if not os.getenv("DEFINE_CRASHRPT_PUBLICKEY"): Message.ShowWarning('当前并未设置 PublicKey, 且企图编译正式版.') Common.exit_with_pause(-1) Message.ShowStatus('即将开始编译, 编译速度取决于电脑性能, 请耐心...') # 清理目前的工作目录, 把一些可明确移除的删掉 clean_environment() # 编译 Pandas 的复兴前版本 compile_prere(pandas_ver) # 编译 Pandas 的复兴后版本 compile_renewal(pandas_ver) Message.ShowStatus('编译工作已经全部结束, 请归档符号并执行打包流程.') # 友好退出, 主要是在 Windows 环境里给予暂停 Common.exit_with_pause()
def main(): ''' 主入口函数 ''' # 加载 .env 中的配置信息 load_dotenv(dotenv_path='.config.env', encoding='UTF-8') # 若无配置信息则自动复制一份文件出来 if not Common.is_file_exists('.config.env'): shutil.copyfile('.config.env.sample', '.config.env') # 显示欢迎信息 Common.welcome('打包流程辅助脚本') print('') pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir)) Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver) # 若环境变量为空则设置个默认值 if not os.getenv('DEFINE_PROJECT_NAME'): os.environ["DEFINE_PROJECT_NAME"] = "Pandas" if not os.getenv('DEFINE_COMPILE_MODE'): os.environ["DEFINE_COMPILE_MODE"] = "re,pre" Message.ShowInfo('当前输出的项目名称为: %s' % os.getenv('DEFINE_PROJECT_NAME')) # 检查是否已经完成了编译 if 're' in os.getenv('DEFINE_COMPILE_MODE').split(','): if not Common.is_compiled(project_slndir, checkmodel='re'): Message.ShowWarning('检测到打包需要的编译产物不完整, 请重新编译. 程序终止.') print('') Common.exit_with_pause(-1) if 'pre' in os.getenv('DEFINE_COMPILE_MODE').split(','): if not Common.is_compiled(project_slndir, checkmodel='pre'): Message.ShowWarning('检测到打包需要的编译产物不完整, 请重新编译. 程序终止.') print('') Common.exit_with_pause(-1) # 导出当前仓库, 变成一个归档压缩文件 Message.ShowInfo('正在将当前分支的 HEAD 内容导出成归档文件...') export_file = export() if not export_file: Message.ShowError('很抱歉, 导出归档文件失败, 程序终止.') Common.exit_with_pause(-1) Message.ShowInfo('归档文件导出完成, 此文件将在程序结束时被删除.') # 基于归档压缩文件, 进行打包处理 if 're' in os.getenv('DEFINE_COMPILE_MODE').split(','): process(export_file, renewal=True) if 'pre' in os.getenv('DEFINE_COMPILE_MODE').split(','): process(export_file, renewal=False) # 执行一些清理工作 clean(export_file) print('') Message.ShowInfo('已经成功打包相关文件, 请进行人工核验.') # 友好退出, 主要是在 Windows 环境里给予暂停 Common.exit_with_pause()
def main(): ''' 主入口函数 ''' # 加载 .env 中的配置信息 load_dotenv(dotenv_path='pyhelp.conf', encoding='UTF-8-SIG') # 若无配置信息则自动复制一份文件出来 if not Common.is_file_exists('pyhelp.conf'): shutil.copyfile('pyhelp.conf.sample', 'pyhelp.conf') # 显示欢迎信息 Common.welcome('编译流程辅助脚本') # 只能在 Windows 环境运行 if platform.system() != 'Windows': Message.ShowError('很抱歉, 此脚本只能在 Windows 环境上运行') Common.exit_with_pause(-1) # 判断本机是否安装了支持的 Visual Studio detected_vs, vs_name = detect_vs() if not detected_vs: Message.ShowError('无法检测到合适的 Visual Studio 版本 (2015 或 2017)') Common.exit_with_pause(-1) else: Message.ShowStatus('检测到已安装: %s 应可正常编译' % vs_name) print('') # 读取当前的 Pandas 主程序版本号 pandas_ver = Common.get_pandas_ver(os.path.abspath(project_slndir)) Message.ShowInfo('当前模拟器的主版本是 %s' % pandas_ver) # 判断是否已经写入了对应的更新日志, 若没有则要给予提示再继续 if (has_changelog(pandas_ver)): Message.ShowStatus('已经在更新日志中找到了 %s 的版本信息.' % pandas_ver) else: Message.ShowWarning('没有在更新日志中找到 %s 版本的信息, 请注意完善!' % pandas_ver) # 判断当前 git 工作区是否干净, 若工作区不干净要给予提示 if git.Repo(project_slndir).is_dirty(): if not Inputer().requireBool({ 'tips': '当前模拟器代码仓库的工作区不干净, 要继续编译吗?', 'default': False }): Message.ShowStatus('您主动放弃了继续操作') Common.exit_with_pause(-1) else: Message.ShowStatus('当前模拟器代码仓库的工作区是干净的.') Message.ShowStatus('即将开始编译, 编译速度取决于电脑性能, 请耐心...') # 清理目前的工作目录, 把一些可明确移除的删掉 clean_environment() # 编译 Pandas 的复兴前版本 compile_prere(pandas_ver) # 编译 Pandas 的复兴后版本 compile_renewal(pandas_ver) Message.ShowStatus('编译工作已经全部结束, 请归档符号并执行打包流程.') # 友好退出, 主要是在 Windows 环境里给予暂停 Common.exit_with_pause()