summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-11-08 21:40:57 +0800
committerruki <[email protected]>2020-11-08 21:40:57 +0800
commit6f58d347401697543a16d0a7f93cb5b401908fb0 (patch)
tree75160b3407b691ec5baed61fd04a53ffe3a4694a
parent89ca182fc97765d4e2a7bb57a565044fdca07586 (diff)
fix os.scriptdir
-rw-r--r--xmake/core/base/interpreter.lua7
-rw-r--r--xmake/core/package/package.lua2
-rw-r--r--xmake/core/sandbox/sandbox.lua18
3 files changed, 4 insertions, 23 deletions
diff --git a/xmake/core/base/interpreter.lua b/xmake/core/base/interpreter.lua
index 99ed8e2da..818ff9576 100644
--- a/xmake/core/base/interpreter.lua
+++ b/xmake/core/base/interpreter.lua
@@ -723,6 +723,9 @@ function interpreter:load(file, opt)
-- clear first
self:_clear()
+ -- translate to absolute file path for scriptdir/rootdir
+ file = path.absolute(file)
+
-- init the current file
self._PRIVATE._CURFILE = file
self._PRIVATE._SCRIPT_FILES = {file}
@@ -784,11 +787,7 @@ end
-- get script directory
function interpreter:scriptdir()
-
- -- check
assert(self and self._PRIVATE and self._PRIVATE._CURFILE)
-
- -- get it
return path.directory(self._PRIVATE._CURFILE)
end
diff --git a/xmake/core/package/package.lua b/xmake/core/package/package.lua
index f95929648..b6494e637 100644
--- a/xmake/core/package/package.lua
+++ b/xmake/core/package/package.lua
@@ -48,7 +48,7 @@ function _instance.new(name, info, scriptdir)
local instance = table.inherit(_instance)
instance._NAME = name
instance._INFO = info
- instance._SCRIPTDIR = scriptdir
+ instance._SCRIPTDIR = scriptdir and path.absolute(scriptdir)
return instance
end
diff --git a/xmake/core/sandbox/sandbox.lua b/xmake/core/sandbox/sandbox.lua
index a293ee003..08598d5c5 100644
--- a/xmake/core/sandbox/sandbox.lua
+++ b/xmake/core/sandbox/sandbox.lua
@@ -184,8 +184,6 @@ function sandbox.new(script, filter, rootdir)
-- save script
self._PRIVATE._SCRIPT = script
-
- -- ok
return self
end
@@ -277,41 +275,25 @@ function sandbox:module()
module[k] = v
end
end
-
- -- save module
self._PRIVATE._MODULE = module
-
- -- ok
return module
end
-- get script from the given sandbox
function sandbox:script()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get it
return self._PRIVATE._SCRIPT
end
-- get filter from the given sandbox
function sandbox:filter()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get it
return self._PRIVATE._FILTER
end
-- get root directory from the given sandbox
function sandbox:rootdir()
-
- -- check
assert(self and self._PRIVATE)
-
- -- get it
return self._PRIVATE._ROOTDIR
end