You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

84 lines
2.3 KiB

#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import sys
import os.path
ContextTemplate = """
local Context = Context or {
versionIPs = $versionIPs,
versionPort=$versionPort,
gameIP="$gameIP",
gamePort="9710",
maintenanceIP="$maintenanceIP",
lang="$lang",
buildMode="$mode",
appVersion="$version",
publishChannel="$publishChannel"
}
return Context
"""
EnvTemplate = """
local Env={debug=$debug,disableLog=$disableLog,consoleOpen=$debug}
return Env
"""
if __name__ == "__main__":
count = len(sys.argv)
if count < 10:
print("生成Context和Env的参数错误")
exit(-1)
params = {}
params["versionPort"] = "9601"
for i in range(1,count):
param_str = sys.argv[i]
split_index = param_str.index("=")
if split_index > 0:
elements = param_str.split("=")
params[elements[0]] = elements[1]
context_keys = [
"versionIP",
"versionPort",
"gameIP",
"maintenanceIP",
"lang",
"mode",
"version",
"publishChannel"
]
env_keys = [
"debug",
"disableLog"
]
for key in env_keys:
if key not in params:
print(f"Env缺少参数[{key}]")
exit(-1)
for key in context_keys:
if key not in params:
print(f"Context缺少参数[{key}]")
exit(-1)
content = EnvTemplate
for key in env_keys:
value = params[key]
content = content.replace("$"+key,value)
cur_dir = os.path.curdir
env_path=f"{cur_dir}/pandora/Assets/Lua/Const/Env.lua"
with open(env_path,"wt",encoding="UTF-8",newline="\n") as f:
f.write(content)
context_path=f"{cur_dir}/pandora/Assets/Lua/Const/Context.lua"
content = ContextTemplate
for key in context_keys:
value = params[key]
if key == "versionIP":
value = value.replace("_","|")
elements = value.split("#")
value = "{"
for element in elements:
value = value+f"'{element}',"
value = value+"}"
content = content.replace("$"+key+"s",value)
else:
content = content.replace("$"+key,value)
with open(context_path,"wt",encoding="UTF-8",newline="\n") as f:
f.write(content)
print(content)