Skip to content

Commit

Permalink
Improved compatibility with Lua 5.2 interpreter (closes #357).
Browse files Browse the repository at this point in the history
  • Loading branch information
pkulchenko committed Sep 19, 2014
1 parent 79d15ad commit 2b7cec0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 14 deletions.
21 changes: 14 additions & 7 deletions interpreters/luabase.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,28 @@ return {
local cmd = '"'..exe..'" '..code..(params and " "..params or "")

-- modify CPATH to work with other Lua versions
local clibs = ('/clibs%s/'):format(version and tostring(version):gsub('%.','') or '')
local _, cpath = wx.wxGetEnv("LUA_CPATH")
local envname = "LUA_CPATH"
if version then
local env = "LUA_CPATH_"..string.gsub(version, '%.', '_')
if os.getenv(env) then envname = env end
end

local cpath = os.getenv(envname)
if rundebug and cpath then
wx.wxSetEnv("LUA_CPATH", ide.osclibs..';'..cpath)
wx.wxSetEnv(envname, ide.osclibs..';'..cpath)
end
if version and cpath and not cpath:find(clibs, 1, true) then
local _, cpath = wx.wxGetEnv("LUA_CPATH")
wx.wxSetEnv("LUA_CPATH", cpath:gsub('/clibs/', clibs))
if version and cpath then
local cpath = os.getenv(envname)
local clibs = string.format('/clibs%s/', version):gsub('%.','')
if not cpath:find(clibs, 1, true) then cpath = cpath:gsub('/clibs/', clibs) end
wx.wxSetEnv(envname, cpath)
end

-- CommandLineRun(cmd,wdir,tooutput,nohide,stringcallback,uid,endcallback)
local pid = CommandLineRun(cmd,self:fworkdir(wfilename),true,false,nil,nil,
function() if rundebug then wx.wxRemoveFile(filepath) end end)

if (rundebug or version) and cpath then wx.wxSetEnv("LUA_CPATH", cpath) end
if (rundebug or version) and cpath then wx.wxSetEnv(envname, cpath) end
return pid
end,
fprojdir = function(self,wfilename)
Expand Down
16 changes: 9 additions & 7 deletions src/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -235,20 +235,22 @@ local function setLuaPaths(mainpath, osname)
-- if the path has an excamation mark, allow Lua to expand it as this
-- expansion happens only once.
if osname == "Windows" and mainpath:find('%!') then mainpath = "!/../" end
wx.wxSetEnv("LUA_PATH", package.path .. ";"
-- ;; will be replaced with the default (c)path by the Lua interpreter
wx.wxSetEnv("LUA_PATH",
(os.getenv("LUA_PATH") or "") .. ';'
.. "./?.lua;./?/init.lua;./lua/?.lua;./lua/?/init.lua" .. ';'
.. mainpath.."lualibs/?/?.lua;"..mainpath.."lualibs/?.lua" .. ';'
.. mainpath.."lualibs/?/?.lua;"..mainpath.."lualibs/?.lua" .. ';;'
.. luadev_path)

local clibs =
ide.osclibs = -- keep the list to use for other Lua versions
osname == "Windows" and mainpath.."bin/?.dll;"..mainpath.."bin/clibs/?.dll" or
osname == "Macintosh" and mainpath.."bin/lib?.dylib;"..mainpath.."bin/clibs/?.dylib" or
osname == "Unix" and mainpath..("bin/linux/%s/lib?.so;"):format(arch)
..mainpath..("bin/linux/%s/clibs/?.so"):format(arch) or
nil
if clibs then wx.wxSetEnv("LUA_CPATH",
package.cpath .. ';' .. clibs .. ';' .. luadev_cpath) end
ide.osclibs = clibs -- keep the list to use for other Lua versions
assert(false, "Unexpected OS name")

wx.wxSetEnv("LUA_CPATH",
(os.getenv("LUA_CPATH") or "") .. ';' .. ide.osclibs .. ';;' .. luadev_cpath)
end

---------------
Expand Down

0 comments on commit 2b7cec0

Please sign in to comment.