diff --git a/tools/accord/src_convert.lua b/tools/accord/src_convert.lua deleted file mode 100644 index 3b1a3409..00000000 --- a/tools/accord/src_convert.lua +++ /dev/null @@ -1,148 +0,0 @@ ---系统验证 -local function is_linux() - if package.config:sub(1, 1) == "\\" then - return false - end - return true -end - ---转换文件 -local function convert(source_path, target_path) - local input_file = io.open(source_path, 'r') - local output_file = io.open(target_path, 'w') - output_file:write('return [[\n') - for line in input_file:lines() do - output_file:write(line) - output_file:write('\n') - end - output_file:write(']]\n') - input_file:close() - output_file:close() -end - --- 保存配置列表 -local function save_conf(file, list) - local input_file = io.open(file, 'w') - input_file:write('return {\nsrc_list={\n') - for i, v in ipairs(list) do - input_file:write('\t\t['..i..']="'.. string.match(v, "robot/accord/lua.+")..'",\n') - print("v="..v) - end - input_file:write('\t}\n}\n') - input_file:close() -end - ---文件遍历 -local function traverse(src_path) - local files = {} - local dirs = {} - local pfile = is_linux()==false and 'dir /b "'..src_path..'"' or 'ls -p "'..src_path..'"' - for file in io.popen(pfile):lines() do - local filepath = src_path..'/'..file - local index = string.find(file,"%.") - if index == nil then - table.insert(dirs, filepath) - local subdir_files,sub_dirs = traverse(filepath) - for _, v in ipairs(subdir_files) do - table.insert(files, v) - end - for _, v in ipairs(sub_dirs) do - table.insert(dirs, v) - end - else - if file ~= '.' and file ~= '..' then - local attr = io.open(filepath, 'r') - if attr then - io.close(attr) - if file:sub(-1) == '/' then - table.insert(dirs, filepath) - local subdir_files,sub_dirs = traverse(filepath) - for _, v in ipairs(subdir_files) do - table.insert(files, v) - end - for _, v in ipairs(sub_dirs) do - table.insert(dirs, v) - end - else - table.insert(files, { - name=file, - path=filepath, - }) - end - end - end - end - end - return files,dirs -end - --- 基础路径 -local base_path = nil --- 资源路径 -local src_path = nil --- lua路径 -local lua_path = nil --- 配置路径 -local conf_path = nil - --- 读取启动参数 -for _, v in ipairs(arg) do - base_path = v - print("base_path="..base_path) - break; -end - -if base_path == nil then - print("非法的基础路径,请检查启动脚本") - return -end - --- 路径初始化 -src_path = base_path..'/src' -lua_path = base_path..'/lua' -conf_path = base_path.."/src_conf.lua" -print("src_path="..src_path) - --- 输出系统环境 -if is_linux() then - print("os=linux") - -- 清理目录 - os.execute(("rm -r '%s'"):format(lua_path)) -else - print("os=windows") - os.execute(("rd /s /q \"%s\""):format(lua_path)) -end -os.remove(conf_path) - - --- 遍历文件和目录 -local files,dirs = traverse(src_path) -local conf_list = {} - -table.insert(dirs, "lua") --- 创建初始化目录 -for _, v in ipairs(dirs) do - local dir_path = base_path..'/'..string.gsub(v, src_path, "lua") - local cmd = "" - if is_linux() == false then - cmd = 'mkdir "' .. dir_path:gsub("/", "\\") .. '"' - os.execute(cmd) - print("cmd="..cmd) - else - cmd = 'mkdir -p ' .. dir_path - os.execute(cmd) - end - print("mkdir cmd="..cmd) -end - --- 转换所有文件 -for _, v in ipairs(files) do - local source = v.path - local target_path = base_path..'/'..string.gsub(source, src_path, "lua")..".lua" - convert(source, target_path) - table.insert(conf_list, target_path) - print("convert path="..source.." target_path="..target_path) -end - --- 将lua文件列表写入lua配置 -save_conf(conf_path, conf_list) \ No newline at end of file diff --git a/tools/accord_convert.bat b/tools/accord_convert.bat deleted file mode 100644 index c74d743b..00000000 --- a/tools/accord_convert.bat +++ /dev/null @@ -1,8 +0,0 @@ -@echo off - -chcp 65001 - -:: 将src目录下的html、css、js转换为lua文件 -..\bin\lua.exe ../tools/accord/src_convert.lua ../server/robot/accord -pause -