diff options
| author | OpportunityLiu <[email protected]> | 2019-07-01 14:19:05 +0800 |
|---|---|---|
| committer | OpportunityLiu <[email protected]> | 2019-07-01 14:19:05 +0800 |
| commit | f40152174188626df4b70ca1b9044a721fd3c6e8 (patch) | |
| tree | 388f5b8e3acdcf1bc9253556fe762dc8b09a5d2a /xmake/core/_xmake_main.lua | |
| parent | 19cbd06f95dddacd1247d1dffab9fa29d719d02b (diff) | |
utf8 support
Diffstat (limited to 'xmake/core/_xmake_main.lua')
| -rw-r--r-- | xmake/core/_xmake_main.lua | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/xmake/core/_xmake_main.lua b/xmake/core/_xmake_main.lua index 3246b1b57..809c58715 100644 --- a/xmake/core/_xmake_main.lua +++ b/xmake/core/_xmake_main.lua @@ -48,8 +48,24 @@ function loadfile(filepath) end end - -- load script from file - local script, errors = _loadfile(filepath) + -- load script data from file + local data, rerrors = io.readfile(filepath) + if not data then + return nil, rerrors + end + + -- init displaypath + local displaypath = filepath + if filepath:startswith(xmake._WORKING_DIR) then + displaypath = path.join(".", path.relative(filepath, xmake._WORKING_DIR)) + elseif filepath:startswith(xmake._PROGRAM_DIR) then + displaypath = path.join("$(programdir)", path.relative(filepath, xmake._PROGRAM_DIR)) + elseif filepath:startswith(xmake._PROJECT_DIR) then + displaypath = path.join("$(projectdir)", path.relative(filepath, xmake._PROJECT_DIR)) + end + + -- load script from string + local script, errors = load(data, "@" .. displaypath) if script then _loadcache[filepath] = {script = script, mtime = mtime or os.mtime(filepath)} end |
