summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2019-05-24 22:17:23 +0800
committerruki <[email protected]>2019-05-24 07:44:20 +0800
commit58ac0d1b5ea7ee2711f9b61698048a918cc374ac (patch)
tree679fce56610cbafc60f4b65aa7c912e9e0f1ad56
parent4de6d0fcc5ddbde041c32e487a29068b162791c3 (diff)
improve loadfile
-rw-r--r--xmake/core/_xmake_main.lua15
1 files changed, 15 insertions, 0 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua
index 1c1acc47a..68c45044d 100644
--- a/xmake/core/_xmake_main.lua
+++ b/xmake/core/_xmake_main.lua
@@ -30,6 +30,21 @@ xmake._PROGRAM_FILE = _PROGRAM_FILE
xmake._PROJECT_DIR = _PROJECT_DIR
xmake._PROJECT_FILE = "xmake.lua"
+-- init script loader
+local _loadfile = _loadfile or loadfile
+local _loadcache = {}
+function loadfile(filepath)
+ local errors = nil
+ local script = _loadcache[filepath]
+ if script == nil then
+ script, errors = _loadfile(filepath)
+ if script and filepath:startswith(_PROGRAM_DIR) then
+ _loadcache[filepath] = script
+ end
+ end
+ return script, errors
+end
+
-- init package path
package.path = xmake._PROGRAM_DIR .. "/core/?.lua;" .. package.path