diff options
| author | ruki <[email protected]> | 2019-08-24 11:07:15 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-08-24 11:07:15 +0800 |
| commit | bb5306699e625775cc115720ef1818c8697b467a (patch) | |
| tree | 7ed9f2a5d22437812b4b6795afe827b5753fef36 /xmake/modules/private/utils/bcsave.lua | |
| parent | 216839989f150af359ad63143f5b0593f500cd56 (diff) | |
improve bcsave
Diffstat (limited to 'xmake/modules/private/utils/bcsave.lua')
| -rw-r--r-- | xmake/modules/private/utils/bcsave.lua | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/xmake/modules/private/utils/bcsave.lua b/xmake/modules/private/utils/bcsave.lua index 528b3ec91..2ae3ae430 100644 --- a/xmake/modules/private/utils/bcsave.lua +++ b/xmake/modules/private/utils/bcsave.lua @@ -34,13 +34,10 @@ local options = -- save lua files to bitcode files in the given directory function save(sourcedir, outputdir, opt) - -- check - assert(outputdir, "no output directory!") - -- init source directory and options opt = opt or {} sourcedir = path.absolute(sourcedir or os.programdir()) - outputdir = path.absolute(outputdir) + outputdir = outputdir and path.absolute(outputdir) or sourcedir assert(os.isdir(sourcedir), "%s not found!", sourcedir) -- trace @@ -54,13 +51,14 @@ function save(sourcedir, outputdir, opt) if opt.excludedirs then pattern = pattern .. "|" .. opt.excludedirs end + local override = (outputdir == sourcedir) for _, luafile in ipairs(os.files(pattern)) do -- get relative lua file path to decrease bitcode file size (without strip) luafile = path.relative(luafile, sourcedir) -- get bitcode file path - local bcfile = path.join(outputdir, luafile) + local bcfile = override and os.tmpfile() or path.join(outputdir, luafile) -- generate bitcode file bcsave(luafile, bcfile, {strip = opt.strip}) @@ -71,6 +69,11 @@ function save(sourcedir, outputdir, opt) total_lua = total_lua + luasize total_bc = total_bc + bcsize vprint("generating %s (%d => %d)..", luafile, luasize, bcsize) + + -- override? + if override then + os.cp(bcfile, luafile) + end end os.cd(oldir) @@ -87,12 +90,6 @@ function main(...) , "" , "Usage: xmake l private.utils.bcsave [options]") - -- check outputdir - if not opt.outputdir then - opt.help() - raise("please set output directory!") - end - -- save bitcode files save(opt.sourcedir, opt.outputdir, opt) end |
