unity打包脚本

 require("utils")

 -- platform android ios
 -- switch public or dev
 -- cfg dev tencent_test

APP = '/Users/admin/2018.4.20f1/Unity.app/Contents/MacOS/Unity'
PROJECT_DEV = '/Volumes/DISK/code/client2/wly2-publish/-Trunk/wly2_dev'
PROJECT_PUBLISH = '/Volumes/DISK/code/client2/wly2-publish/-Trunk/wly2_publish'
DEST_PATH = '/Volumes/DISK/code/client2/wly2-publish/-Trunk/publish/'

args = {}
for k, v in ipairs(arg) do
    local arr = string.split(v, "=")
    if #arr == 2 then
        args[arr[1]] = arr[2]
    end
end

local cmd = string.format('svn cleanup %s;svn revert -R %s;svn up %s', PROJECT_DEV, PROJECT_DEV, PROJECT_DEV)

local function switch()
    if args.cfg == 'dev' then
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -logFile -executeMethod EditorTools_GameCfg.ImportGameCfg', APP, PROJECT_DEV)
    elseif args.cfg == 'tencent_test' then
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -logFile -executeMethod EditorTools_GameCfg.ImportGameCfgTXTest', APP, PROJECT_DEV)
    end
end

if args.platform == 'android' then
    if args.switch == "dev" then
        cmd = cmd .. ';' .. "rm -rf " .. PROJECT_DEV .. '/Assets/XLua/Gen'
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -buildTarget Android -logFile', APP, PROJECT_DEV)
        switch()
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -executeMethod Builder.BuildAndroidCmd -logFile', APP, PROJECT_DEV)
    elseif args.switch == "public" then
        cmd = cmd .. ';' .. "rm -rf " .. PROJECT_PUBLISH .. '/Assets/XLua/Gen'
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -buildTarget Android -logFile', APP, PROJECT_DEV)
        switch()
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -executeMethod Builder.BuildAndroidABCmd -logFile', APP, PROJECT_DEV)
        cmd = cmd .. ';' .. string.format('%s -batchmode -quit -projectPath %s -executeMethod Builder.BuildAndroidCmd -logFile', APP, PROJECT_PUBLISH)
    end
end

print(cmd)
os.execute(cmd)

local path = ''
if args.switch == "dev" then
    path = PROJECT_DEV
elseif args.switch == "public" then
    path = PROJECT_PUBLISH
end
for file in lfs.dir(path) do
    local f = path .. '/' .. file
    if not isDir(f) then
        local file_name, file_type = getFileType(f)
        if file_type == 'apk' then
            os.execute(string.format('mv %s %s', f, DEST_PATH .. file_name .. '-' .. args.switch .. os.date("%Y%m%d%H%M%S", os.time()) .. '.apk'))
        elseif file_type == 'zip' then
            -- os.execute(string.format('mv %s %s', f, DEST_PATH .. file_name .. '-' .. args.switch .. os.date("%Y%m%d%H%M%S", os.time()) .. '.zip'))
        end
    end
end

自动unity打包,持续优化中。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值