summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-08-25 09:19:35 +0800
committerruki <[email protected]>2019-08-25 09:19:35 +0800
commit6514385571fc00e18535a2f2e054177d91f867be (patch)
treeb97f5c11ccb573f2e968eadb3fdfbab4b7254ed8
parent03bbbd76be1ef10d993ac472d1a01ce55b88bee4 (diff)
improve display pathes
-rw-r--r--xmake/core/_xmake_main.lua7
-rw-r--r--xmake/core/sandbox/modules/import/lib/luajit/bcsave.lua4
-rw-r--r--xmake/modules/private/utils/bcsave.lua3
3 files changed, 9 insertions, 5 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index 631549cc0..ebba707eb 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -73,17 +73,20 @@ end
--
-- @param filepath the lua file path
-- @param mode the load mode, e.g 't', 'b' or 'bt' (default)
--- @param opt the arguments option, e.g. {displaypath = ""}
+-- @param opt the arguments option, e.g. {displaypath = "", nocache = true}
--
local _loadcache = {}
function loadfile(filepath, mode, opt)
+ -- init options
+ opt = opt or {}
+
-- get absolute path
filepath = path.absolute(filepath)
-- attempt to load script from cache first
local mtime = nil
- local cache = _loadcache[filepath]
+ local cache = (not opt.nocache) and _loadcache[filepath] or nil
if cache and cache.script then
mtime = os.mtime(filepath)
if mtime > 0 and cache.mtime == mtime then
diff --git a/xmake/core/sandbox/modules/import/lib/luajit/bcsave.lua b/xmake/core/sandbox/modules/import/lib/luajit/bcsave.lua
index 28ea0ced7..773b47f67 100644
--- a/xmake/core/sandbox/modules/import/lib/luajit/bcsave.lua
+++ b/xmake/core/sandbox/modules/import/lib/luajit/bcsave.lua
@@ -27,11 +27,11 @@ local raise = require("sandbox/modules/raise")
--
-- @param luafile the lua file
-- @param bcfile the bitcode file
--- @param opt the arguments option, e.g. {strip = true, displaypath = "/xxx/a.lua"}
+-- @param opt the arguments option, e.g. {strip = true, displaypath = "/xxx/a.lua", nocache = true}
--
function main(luafile, bcfile, opt)
opt = opt or {}
- local result, errors = loadfile(luafile, "bt", {displaypath = opt.displaypath})
+ local result, errors = loadfile(luafile, "bt", {displaypath = opt.displaypath, opt.nocache})
if not result then
raise(errors)
end
diff --git a/xmake/modules/private/utils/bcsave.lua b/xmake/modules/private/utils/bcsave.lua
index 9310180b4..27e7dabd9 100644
--- a/xmake/modules/private/utils/bcsave.lua
+++ b/xmake/modules/private/utils/bcsave.lua
@@ -64,7 +64,8 @@ function save(sourcedir, outputdir, opt)
local bcfile = override and os.tmpfile() or path.join(outputdir, relativepath)
-- generate bitcode file
- bcsave(luafile, bcfile, {strip = opt.strip, displaypath = displaypath})
+ -- @note we disable cache to ensure all display pathes are correct
+ bcsave(luafile, bcfile, {strip = opt.strip, displaypath = displaypath, nocache = true})
-- trace
local luasize = os.filesize(luafile)