更新子仓库,添加动态设置混淆宏的过程
parent
dc221a1a0d
commit
a23a5ed53f
|
|
@ -181,7 +181,7 @@ pipeline {
|
||||||
// python脚本: Tool/py_tools/PreHandle.py <sdk_path> <channel_path>
|
// python脚本: Tool/py_tools/PreHandle.py <sdk_path> <channel_path>
|
||||||
sh "chmod +x $WORKSPACE/Tool/py_tools/PreHandle.py"
|
sh "chmod +x $WORKSPACE/Tool/py_tools/PreHandle.py"
|
||||||
// 使用 returnStatus 获取脚本的退出码
|
// 使用 returnStatus 获取脚本的退出码
|
||||||
def pythonResult = sh(script: "python3 $WORKSPACE/Tool/py_tools/PreHandle.py ${sdkPath} ${channelPath}", returnStatus: true)
|
def pythonResult = sh(script: "python3 $WORKSPACE/Tool/py_tools/PreHandle.py ${sdkPath} ${channelPath} ${OBFUZ}", returnStatus: true)
|
||||||
if (pythonResult != 0) {
|
if (pythonResult != 0) {
|
||||||
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}"
|
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Debug】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}"
|
||||||
SendMessageToWechat(message)
|
SendMessageToWechat(message)
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ def IsDev() {
|
||||||
else if('Test' == params.Channel)
|
else if('Test' == params.Channel)
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
def CheckRemoteBranchExists(repoUrl, branchName) {
|
def CheckRemoteBranchExists(repoUrl, branchName) {
|
||||||
|
|
@ -211,7 +211,7 @@ pipeline {
|
||||||
// python脚本: Tool/py_tools/PreHandle.py <sdk_path> <channel_path>
|
// python脚本: Tool/py_tools/PreHandle.py <sdk_path> <channel_path>
|
||||||
sh "chmod +x $WORKSPACE/Tool/py_tools/PreHandle.py"
|
sh "chmod +x $WORKSPACE/Tool/py_tools/PreHandle.py"
|
||||||
// 使用 returnStatus 获取脚本的退出码
|
// 使用 returnStatus 获取脚本的退出码
|
||||||
def pythonResult = sh(script: "python3 $WORKSPACE/Tool/py_tools/PreHandle.py ${sdkPath} ${channelPath}", returnStatus: true)
|
def pythonResult = sh(script: "python3 $WORKSPACE/Tool/py_tools/PreHandle.py ${sdkPath} ${channelPath} ${OBFUZ}", returnStatus: true)
|
||||||
if (pythonResult != 0) {
|
if (pythonResult != 0) {
|
||||||
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}"
|
def message = "【${PLATFORM_PARAM}】【${VERSION_PARAM}】【Release】【${CHANNEL_PARAM}】修改渠道文件夹失败: pythonResult=${pythonResult}"
|
||||||
SendMessageToWechat(message)
|
SendMessageToWechat(message)
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 2bf88fe9a68cf476e09829aa66dc2479f9ca0001
|
Subproject commit c1291e380956bcc75f1352268fba2bf34ada52a3
|
||||||
|
|
@ -1,15 +1,16 @@
|
||||||
# 传入参数 0:SDK_PATH 1:ChannelPath
|
# 传入参数 0:SDK_PATH 1:ChannelPath 2:Obfuz(可选, true/false)
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 3:
|
||||||
print("Usage: python PreHandle.py <SDK_PATH> <ChannelPath>")
|
print("Usage: python PreHandle.py <SDK_PATH> <ChannelPath> [Obfuz]")
|
||||||
sys.exit(1) # 参数不足时返回错误码1
|
sys.exit(1) # 参数不足时返回错误码1
|
||||||
|
|
||||||
sdk_path = sys.argv[1]
|
sdk_path = sys.argv[1]
|
||||||
channel_path = sys.argv[2]
|
channel_path = sys.argv[2]
|
||||||
|
obfuz = sys.argv[3].lower() == 'true' if len(sys.argv) >= 4 else None
|
||||||
|
|
||||||
if not os.path.exists(sdk_path):
|
if not os.path.exists(sdk_path):
|
||||||
print(f"Error: SDK path '{sdk_path}' does not exist.")
|
print(f"Error: SDK path '{sdk_path}' does not exist.")
|
||||||
|
|
@ -50,10 +51,55 @@ def main():
|
||||||
for package in packageList:
|
for package in packageList:
|
||||||
HandlePackage(package, sdk_path, channel_path)
|
HandlePackage(package, sdk_path, channel_path)
|
||||||
|
|
||||||
|
# 同步 USE_OBFUZ 宏(如果传入了 Obfuz 参数)
|
||||||
|
if obfuz is not None:
|
||||||
|
SyncUseObfuzDefine(channel_path, obfuz)
|
||||||
|
|
||||||
# 处理完成,正常退出
|
# 处理完成,正常退出
|
||||||
print("All packages processed successfully.")
|
print("All packages processed successfully.")
|
||||||
sys.exit(0) # 改为成功退出
|
sys.exit(0) # 改为成功退出
|
||||||
|
|
||||||
|
def SyncUseObfuzDefine(channel_path, enable):
|
||||||
|
"""根据 enable 参数在 ChannelSetting.yaml 的 Define_list 中添加或移除 USE_OBFUZ"""
|
||||||
|
channel_setting_path = os.path.join(channel_path, "ChannelSetting.yaml")
|
||||||
|
if not os.path.exists(channel_setting_path):
|
||||||
|
print(f"[PreHandle] WARNING: ChannelSetting.yaml not found at {channel_setting_path}, skip USE_OBFUZ sync")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
with open(channel_setting_path, 'r', encoding='utf-8') as f:
|
||||||
|
data = yaml.safe_load(f) or {}
|
||||||
|
except (IOError, yaml.YAMLError) as e:
|
||||||
|
print(f"[PreHandle] ERROR: Failed to read ChannelSetting.yaml: {e}")
|
||||||
|
return
|
||||||
|
|
||||||
|
defines = data.get('Define_list') or []
|
||||||
|
changed = False
|
||||||
|
if enable:
|
||||||
|
if 'USE_OBFUZ' not in defines:
|
||||||
|
defines.append('USE_OBFUZ')
|
||||||
|
data['Define_list'] = defines
|
||||||
|
changed = True
|
||||||
|
print('[PreHandle] Added USE_OBFUZ to Define_list')
|
||||||
|
else:
|
||||||
|
print('[PreHandle] USE_OBFUZ already in Define_list, skip')
|
||||||
|
else:
|
||||||
|
if 'USE_OBFUZ' in defines:
|
||||||
|
defines.remove('USE_OBFUZ')
|
||||||
|
data['Define_list'] = defines
|
||||||
|
changed = True
|
||||||
|
print('[PreHandle] Removed USE_OBFUZ from Define_list')
|
||||||
|
else:
|
||||||
|
print('[PreHandle] USE_OBFUZ not in Define_list, skip')
|
||||||
|
|
||||||
|
if changed:
|
||||||
|
try:
|
||||||
|
with open(channel_setting_path, 'w', encoding='utf-8') as f:
|
||||||
|
yaml.dump(data, f, allow_unicode=True)
|
||||||
|
except IOError as e:
|
||||||
|
print(f"[PreHandle] ERROR: Failed to write ChannelSetting.yaml: {e}")
|
||||||
|
|
||||||
|
|
||||||
def HandlePackage(packageDefineName, sdk_path, channel_path):
|
def HandlePackage(packageDefineName, sdk_path, channel_path):
|
||||||
# 处理包定义名称
|
# 处理包定义名称
|
||||||
if '@' not in packageDefineName:
|
if '@' not in packageDefineName:
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue