【打包】增加define_list 去重
parent
337655c0d7
commit
3431e42246
|
|
@ -60,7 +60,7 @@ def HandlePackage(packageDefineName, sdk_path, channel_path):
|
|||
print(f"Error: Invalid package format '{packageDefineName}'. Expected format 'packageName@version'.")
|
||||
sys.exit(8) # 返回错误码8
|
||||
packageName, version = packageDefineName.split('@', 1)
|
||||
print(f"Package Name: {packageName}, Version: {version}")
|
||||
print(f"Start Handle Package Name: {packageName}, Version: {version}")
|
||||
# 检查sdk_path/packageName 是否存在
|
||||
package_path = os.path.join(sdk_path, packageName)
|
||||
if not os.path.exists(package_path):
|
||||
|
|
@ -119,24 +119,44 @@ def ModifyDefineList(versionPath, channel_path):
|
|||
try:
|
||||
with open(channel_setting_path, 'r', encoding='utf-8') as file:
|
||||
channel_setting = yaml.safe_load(file)
|
||||
print(f"Channel Setting Before Modification: {channel_setting}")
|
||||
# print(f"Channel Setting Before Modification: {channel_setting}")
|
||||
except (IOError, yaml.YAMLError) as e:
|
||||
print(f"Error reading channel setting file '{channel_setting_path}': {e}")
|
||||
sys.exit(11)
|
||||
|
||||
print(f"Old Define_List: {channel_setting.get('Define_list', [])}")
|
||||
|
||||
# 修改DefineList
|
||||
# 修改DefineList(添加去重功能)
|
||||
if "Define_list" not in channel_setting:
|
||||
channel_setting["Define_list"] = []
|
||||
channel_setting["Define_list"].extend(define_list)
|
||||
|
||||
# 合并并去重
|
||||
current_defines = set(channel_setting["Define_list"])
|
||||
new_defines = set(define_list)
|
||||
|
||||
# 输出将要添加的新定义
|
||||
added_defines = new_defines - current_defines
|
||||
if added_defines:
|
||||
print(f"Adding new defines: {list(added_defines)}")
|
||||
|
||||
# 重复项警告
|
||||
duplicate_defines = new_defines & current_defines
|
||||
if duplicate_defines:
|
||||
print(f"Warning: Duplicate defines found and will be ignored: {list(duplicate_defines)}")
|
||||
|
||||
# 更新定义列表(保持原有顺序,添加新项)
|
||||
channel_setting["Define_list"] = list(current_defines | new_defines)
|
||||
|
||||
try:
|
||||
with open(channel_setting_path, 'w', encoding='utf-8') as file:
|
||||
yaml.dump(channel_setting, file, allow_unicode=True)
|
||||
print(f"Channel Setting After Modification: {channel_setting}")
|
||||
# print(f"Channel Setting After Modification: {channel_setting}")
|
||||
except IOError as e:
|
||||
print(f"Error writing channel setting file '{channel_setting_path}': {e}")
|
||||
sys.exit(15)
|
||||
|
||||
print(f"New Define_List: {channel_setting['Define_list']}")
|
||||
|
||||
def CopyAssets(srcAssetPath, targetAssetPath):
|
||||
# 如果srcAssetPath不存在,则返回
|
||||
if not os.path.exists(srcAssetPath):
|
||||
|
|
@ -151,7 +171,7 @@ def CopyAssets(srcAssetPath, targetAssetPath):
|
|||
print(f"Error: Failed to create directory '{targetAssetPath}': {e}")
|
||||
sys.exit(12)
|
||||
|
||||
print(f"Start copying assets from '{srcAssetPath}' to '{targetAssetPath}'")
|
||||
# print(f"Start copying assets from '{srcAssetPath}' to '{targetAssetPath}'")
|
||||
|
||||
# 遍历srcAssetPath下的所有文件和文件夹
|
||||
try:
|
||||
|
|
|
|||
Loading…
Reference in New Issue