def start(version, srcDir, dstDir, packArgs): #遍历当前目录 # removeClass('--------------,AndroidXiaomi:[function(t,e,i){}],--------------', 'AndroidXiaomi') # if True: # return print(srcDir) print(dstDir) if os.path.isdir(dstDir): time.sleep(0.01) shutil.rmtree(dstDir) time.sleep(0.01) global PngMap # creator 生成的png映射表 json_file = utils.flat_path( os.path.join(os.path.dirname(__file__), "PngMap.json")) print(json_file) try: f = open(json_file) PngMap = json.load(f) f.close() except: pass #拷贝src目录 copySrc(srcDir, dstDir) shortProjectJS.start( utils.flat_path(os.path.join(dstDir, "../project/src/project.js")), 'minigame', packArgs['currentChannel']) removeTextureJson( utils.flat_path(os.path.join(dstDir, "../project/internal/"))) #拷贝res if packArgs['mergeJson']: copyResRawAssets(srcDir, dstDir) mergeJson(srcDir, dstDir, dstDir + '/res/MergeJson.json') else: copyRes(srcDir, dstDir) #压缩png if packArgs['compressPng']: pngyu.start(dstDir) #copy渠道相关的CfgPackage.js if packArgs['cfgPackagePath']: dstPath = utils.flat_path(os.path.join(dstDir, "../project")) + '/' moveFileTo(packArgs['cfgPackagePath'], dstPath + 'src/assets/scripts/CfgPackage.js') zipDir = '' #生产远端资源包和更新包 createZip(zipDir, dstDir, version)
def start(version, srcDir, dstDir, packArgs): #遍历当前目录 print(srcDir) print(dstDir) global PngMap # creator 生成的png映射表 json_file = utils.flat_path( os.path.join(os.path.dirname(__file__), "PngMap.json")) #print(json_file) try: f = open(json_file) PngMap = json.load(f) f.close() except: pass #拷贝src目录 copySrc(srcDir, dstDir) shortProjectJS.start( utils.flat_path(os.path.join(dstDir, "src/project.js")), 'h5', packArgs['currentChannel']) #拷贝res if packArgs['mergeJson']: copyResRawAssets(srcDir, dstDir) mergeJson.start(srcDir, dstDir, dstDir + '/src/assets/scripts/MergeJson.js') else: copyRes(srcDir, dstDir) #压缩png if packArgs['compressPng']: pngyu.start(dstDir + '/') #copy渠道相关的CfgPackage.js native.js if packArgs['cfgPackagePath']: moveFileTo(packArgs['cfgPackagePath'], dstDir + '/src/assets/scripts/CfgPackage.js') createManifestJS(dstDir)
def start(version, srcDir, dstDir, packArgs): #遍历当前目录 print(srcDir) print(dstDir) global bExclude bExclude = packArgs['exclude'] print(bExclude) global bMiniGame bMiniGame = packArgs['minigame'] print('is minigame: ') print(bMiniGame) if os.path.isdir(dstDir): time.sleep(0.01) shutil.rmtree(dstDir) time.sleep(0.01) global PngMap # creator 生成的png映射表 json_file = utils.flat_path( os.path.join(os.path.dirname(__file__), "PngMap.json")) print(json_file) try: f = open(json_file) PngMap = json.load(f) f.close() except: pass copyRes(srcDir, dstDir) #压缩png if packArgs['compressPng']: pngyu.start(dstDir + '/mainPackage') if bExclude: pngyu.start(dstDir + '/exclude') #加密png if packArgs['encrytPng']: encrytPng.traverseDir(dstDir) #拷贝src目录 copySrc(srcDir, dstDir) #生成子包exclude md5信息集合到主包 if bExclude: createSubManifestJS(dstDir) #copy creator copyCreator(dstDir) #copy渠道相关的CfgPackage.js native.js if packArgs['cfgPackagePath']: moveFileTo(packArgs['cfgPackagePath'], dstDir + '/mainPackage/src/assets/scripts/CfgPackage.js') if packArgs['nativePath']: moveFileTo(packArgs['nativePath'], dstDir + '/mainPackage/native.js') #加密js jsc if packArgs['encrytJS']: encrytJS.traverseDir(dstDir + '/mainPackage') if packArgs['confuseResImport']: coufuseResImport.start(dstDir + '/mainPackage/res') #替换自定义key的cocos-jsb文件 scrJsbPath = utils.flat_path( os.path.join(os.path.dirname(__file__), "../../cocos/cocos2d-jsb.jsc")) moveFileTo(scrJsbPath, dstDir + '/mainPackage/src/cocos2d-jsb.jsc') #生成主包manifest.js if not bMiniGame: createManifestJS(dstDir + '/mainPackage') #加密manifest.js if packArgs['encrytJS']: encrytJS.traverseDir(dstDir + '/mainPackage') zipDir = '' if packArgs['zipDir']: zipDir = packArgs['zipDir'] #生产远端资源包和更新包 createZip(zipDir, dstDir, version)
def start(version, srcDir, dstDir, packArgs): # 遍历当前目录 global ConfigMap print("srcDir:%s" % srcDir) print("dstDir:%s" % dstDir) if os.path.isdir(dstDir): time.sleep(0.01) shutil.rmtree(dstDir) time.sleep(0.01) dst_project_path = utils.flat_path(os.path.join(dstDir, "../project")) + '/' if os.path.isdir(dst_project_path): shutil.rmtree(dst_project_path) os.makedirs(dst_project_path) # 拷贝src目录 copySrc( srcDir, dst_project_path, [".js"], # build\wechatgame\src >>>> packConfig\minigame\wx\project ['manifest', 'CfgPackage', 'SubManifest']) path_src_internal = os.path.join(srcDir, "assets/internal") path_dst_internal = os.path.join(dst_project_path, "assets/internal") copySrc(path_src_internal, path_dst_internal) path_src_main = os.path.join(srcDir, "assets/main") path_dst_main = os.path.join(dst_project_path, "assets/main") copySrc(path_src_main, path_dst_main, [r"config\..*json"]) # path = utils.flat_path(os.path.join(dstDir, "../project/src/project.js")) # shortProjectJS.start(path, 'minigame', packArgs['currentChannel']) flat_path = utils.flat_path(os.path.join(dstDir, "../project/internal/")) removeTextureJson(flat_path) # 拷贝res assetSrc = os.path.normpath(os.path.join(srcDir, "assets")) assetDst = os.path.normpath(os.path.join(dstDir, "assets")) mergeJsonMd5 = "" if 'mergeJson' in packArgs and packArgs['mergeJson']: copySrc( assetSrc, assetDst, None, [r".*\.js$", r".*\.js\.map$", r".*/import/[0-9a-f]{2}/.*\.json$"]) # copyResRawAssets(srcDir, dstDir) out_put = dstDir + '/assets/MergeJson.json' configMapPath = os.path.join(srcDir, "ConfigMap.json") f = open(configMapPath) ConfigMap = json.load(f) f.close() mergeJson(srcDir, dstDir, out_put) mergeJsonMd5 = get_file_md5(out_put) else: copySrc(assetSrc, assetDst, None, [r".*\.js$", r".*\.js\.map"]) path_ = packArgs['mod_file_path'] tmplt_name = "mini_tmplt" src_tmplt = os.path.normpath(os.path.join(path_, tmplt_name)) copySrc(src_tmplt, dst_project_path) udpateMergeJsonMD5(dst_project_path + '/hooks.js', mergeJsonMd5) # 修改项目配置 cfg_file = os.path.join(dst_project_path, 'project.config.json') proj_name = 'fishClient-' + os.path.basename(os.path.dirname(dstDir)) modify_proj_cfg(cfg_file, proj_name, packArgs) # copy渠道相关的CfgPackage.js if packArgs['cfgPackagePath']: moveFileTo(packArgs['cfgPackagePath'], dst_project_path + 'src/assets/scripts/CfgPackage.js') # project 文件夹压缩备份 ts_str = datetime.datetime.fromtimestamp( time.time()).strftime('%Y%m%d_%H%M%S') dst_proj_zip_path = utils.flat_path( os.path.join(os.path.dirname(dstDir), 'publish', '%s_%s' % (version, ts_str), 'project.zip')) utils.zip_folder(dst_project_path, dst_proj_zip_path) # 压缩png if packArgs['compressPng']: pngyu.start(os.path.join(dstDir, "assets"), os.path.join(srcDir, "PngMap.json")) zipDir = '' # 生产远端资源包和更新包 createZip(zipDir, dstDir, version, ts_str) shutil.rmtree(dstDir) # 删除临时目录