summaryrefslogtreecommitdiff
path: root/xmake/core
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/core')
-rw-r--r--xmake/core/sandbox/import.lua14
-rw-r--r--xmake/core/sandbox/import/core/platform.lua (renamed from xmake/core/sandbox/import/platform.lua)0
-rw-r--r--xmake/core/sandbox/import/core/project.lua (renamed from xmake/core/sandbox/import/project.lua)0
-rw-r--r--xmake/core/sandbox/import/core/template.lua (renamed from xmake/core/sandbox/import/template.lua)0
4 files changed, 12 insertions, 2 deletions
diff --git a/xmake/core/sandbox/import.lua b/xmake/core/sandbox/import.lua
index 27417a23b..236547eaf 100644
--- a/xmake/core/sandbox/import.lua
+++ b/xmake/core/sandbox/import.lua
@@ -22,6 +22,7 @@
-- load modules
local os = require("base/os")
+local path = require("base/path")
local utils = require("base/utils")
-- import module
@@ -33,17 +34,26 @@ function sandbox_import(name)
os.raise("cannot import module: %s", name)
end
+ -- get module name
+ local modulename = path.basename(name)
+ if not modulename then
+ os.raise("cannot get module name for %s", name)
+ end
+
-- get the parent scope
local scope_parent = getfenv(2)
assert(scope_parent)
-- this module has been imported?
- if rawget(scope_parent, name) then
+ if rawget(scope_parent, modulename) then
os.raise("this module: %s has been imported!", name)
end
-- import this module into the parent scope
- scope_parent[name] = module
+ scope_parent[modulename] = module
+
+ -- return it
+ return module
end
-- load module
diff --git a/xmake/core/sandbox/import/platform.lua b/xmake/core/sandbox/import/core/platform.lua
index e6de93681..e6de93681 100644
--- a/xmake/core/sandbox/import/platform.lua
+++ b/xmake/core/sandbox/import/core/platform.lua
diff --git a/xmake/core/sandbox/import/project.lua b/xmake/core/sandbox/import/core/project.lua
index 3d65b8768..3d65b8768 100644
--- a/xmake/core/sandbox/import/project.lua
+++ b/xmake/core/sandbox/import/core/project.lua
diff --git a/xmake/core/sandbox/import/template.lua b/xmake/core/sandbox/import/core/template.lua
index 980e98a52..980e98a52 100644
--- a/xmake/core/sandbox/import/template.lua
+++ b/xmake/core/sandbox/import/core/template.lua