|
@@ -1,19 +1,19 @@
|
|
|
# -*- coding:utf-8 -*-
|
|
|
|
|
|
-import file_utils, http_utils, contants, text_utils, apk_tool, path_utils, icon_utils, package_utils
|
|
|
+from V2 import icon_utils, file_utils, package_utils, apk_tool, path_utils, contants, http_utils, print_log, text_utils
|
|
|
import json, os, shutil, time, traceback
|
|
|
-import print_log
|
|
|
-from print_log import printlog
|
|
|
+from V2.print_log import printlog
|
|
|
|
|
|
|
|
|
def startMerge(config_json_path):
|
|
|
apk_decompile_tmp_dir = ''
|
|
|
+ isSuccess = False
|
|
|
try:
|
|
|
time_start = time.time()
|
|
|
json_text = file_utils.read_file(config_json_path)
|
|
|
config = json.loads(json_text)
|
|
|
gcp_code = config['gcp_code']
|
|
|
- print_log.LOGFILE = os.path.join(contants.SDK_LOG, "%s.txt"%gcp_code)
|
|
|
+ print_log.LOGFILE = os.path.join(contants.SDK_LOG, "%s.txt" % gcp_code)
|
|
|
if os.path.exists(print_log.LOGFILE):
|
|
|
os.remove(print_log.LOGFILE)
|
|
|
|
|
@@ -25,9 +25,6 @@ def startMerge(config_json_path):
|
|
|
|
|
|
printlog("[config_json_path] : %s" % config_json_path)
|
|
|
|
|
|
- if 'refactorSdk' in config and toBoolean(config['refactorSdk']):
|
|
|
- printlog("using refactorSdk")
|
|
|
-
|
|
|
origin_apk_full_path = config['apk_path']
|
|
|
|
|
|
printlog("[origin_apk_full_path] : %s" % origin_apk_full_path)
|
|
@@ -130,7 +127,6 @@ def startMerge(config_json_path):
|
|
|
targetSdkVersion = meta_config['targetSdkVersion']
|
|
|
printlog("[targetSdkVersion]: %s" % targetSdkVersion)
|
|
|
|
|
|
-
|
|
|
orientation = meta_config['SDK_ORIENTATION']
|
|
|
printlog("[orientation]: %s" % orientation)
|
|
|
|
|
@@ -152,13 +148,13 @@ def startMerge(config_json_path):
|
|
|
icon_utils.replace_icon(apk_decompile_tmp_dir, icon_path)
|
|
|
if package_utils.pack(apk_decompile_tmp_dir, channel_path, sdk_name, package_name, platform):
|
|
|
printlog("合并代码失败")
|
|
|
- return 1
|
|
|
+ return False
|
|
|
|
|
|
# 修改${applicationId}为包名
|
|
|
splash_path = config['splash']
|
|
|
if splash_path:
|
|
|
if os.path.exists(splash_path):
|
|
|
- apk_temp_splash_path = os.path.join(apk_decompile_tmp_dir, 'res', 'drawable', 'yyxx_comm_welcome')
|
|
|
+ apk_temp_splash_path = os.path.join(apk_decompile_tmp_dir, 'assets','yyxx_comm_welcome.jpg')
|
|
|
shutil.copy(splash_path, apk_temp_splash_path)
|
|
|
printlog("复制闪屏页至[apk_temp_splash_path] : %s" % apk_temp_splash_path)
|
|
|
else:
|
|
@@ -168,8 +164,9 @@ def startMerge(config_json_path):
|
|
|
temp_yyxx_cfg_path = os.path.join(apk_decompile_tmp_dir, 'assets', 'yyxx_game', 'yyxx_cfg.properties')
|
|
|
if not os.path.exists(temp_yyxx_cfg_path):
|
|
|
printlog('找不到yyxx_cfg.properties,请检查游戏是否正确接入SDK')
|
|
|
- return 1
|
|
|
-
|
|
|
+ return False
|
|
|
+ file_utils.replace_assets_param(temp_yyxx_cfg_path, 'YYXX_GCP_CODE',
|
|
|
+ gcp_code)
|
|
|
temp_manifest_path = os.path.join(apk_decompile_tmp_dir, 'AndroidManifest.xml')
|
|
|
sdk_client_config = config['sdk_client_config']
|
|
|
printlog('[sdk_client_config] : %s' % sdk_client_config)
|
|
@@ -252,7 +249,9 @@ def startMerge(config_json_path):
|
|
|
if ret:
|
|
|
printlog('apk签名失败')
|
|
|
return ret
|
|
|
+
|
|
|
printlog("开始执行apk压缩")
|
|
|
+
|
|
|
ret = apk_tool.zipalign(out_put_signed_apk_path, out_put_zipalign_apk_path)
|
|
|
if ret:
|
|
|
printlog('apk压缩失败')
|
|
@@ -270,20 +269,14 @@ def startMerge(config_json_path):
|
|
|
time_c = time.time() - time_start
|
|
|
|
|
|
printlog("APK路径:%s\n切包总用时:%s秒" % (dis_path, time_c))
|
|
|
-
|
|
|
+ isSuccess = True
|
|
|
except:
|
|
|
printlog(traceback.format_exc())
|
|
|
+ isSuccess = False
|
|
|
finally:
|
|
|
if apk_decompile_tmp_dir:
|
|
|
printlog('清空打包临时目录')
|
|
|
printlog('[apk_decompile_tmp_dir]:%s' % os.path.dirname(apk_decompile_tmp_dir))
|
|
|
- # file_utils.delete_folder(os.path.dirname(apk_decompile_tmp_dir))
|
|
|
-
|
|
|
-
|
|
|
-def toBoolean(bool_str):
|
|
|
- if type(bool_str) == bool:
|
|
|
- return bool_str
|
|
|
+ file_utils.delete_folder(os.path.dirname(apk_decompile_tmp_dir))
|
|
|
+ return isSuccess
|
|
|
|
|
|
- if bool_str == 'true':
|
|
|
- return True
|
|
|
- return False
|