diff options
author | Jakob Stendahl <jakob.stendahl@outlook.com> | 2018-01-09 15:01:04 +0100 |
---|---|---|
committer | Jakob Stendahl <jakob.stendahl@outlook.com> | 2018-01-09 15:01:04 +0100 |
commit | bb6e704ab011a497ac8c735afc0fd4c52a1425ce (patch) | |
tree | bed462d18c4f976f30c690b529d6de8b2a6ba2ff /love2dToAPK/tools/tools/zbstudio-win/interpreters | |
parent | d2c375c015fe3e216234a887ab75e08d40f5f5db (diff) | |
download | Love2dToAPK-bb6e704ab011a497ac8c735afc0fd4c52a1425ce.tar.gz Love2dToAPK-bb6e704ab011a497ac8c735afc0fd4c52a1425ce.zip |
Added old project
Diffstat (limited to 'love2dToAPK/tools/tools/zbstudio-win/interpreters')
5 files changed, 170 insertions, 0 deletions
diff --git a/love2dToAPK/tools/tools/zbstudio-win/interpreters/love2d.lua b/love2dToAPK/tools/tools/zbstudio-win/interpreters/love2d.lua new file mode 100644 index 0000000..9059584 --- /dev/null +++ b/love2dToAPK/tools/tools/zbstudio-win/interpreters/love2d.lua @@ -0,0 +1,61 @@ +-- Copyright 2011-12 Paul Kulchenko, ZeroBrane LLC + +local love2d +local win = ide.osname == "Windows" +local mac = ide.osname == "Macintosh" + +return { + name = "LÖVE", + description = "LÖVE game engine", + api = {"baselib", "love2d"}, + frun = function(self,wfilename,rundebug) + love2d = love2d or ide.config.path.love2d -- check if the path is configured + if not love2d then + local sep = win and ';' or ':' + local default = + win and (GenerateProgramFilesPath('love', sep)..sep) + or mac and ('/Applications/love.app/Contents/MacOS'..sep) + or '' + local path = default + ..(os.getenv('PATH') or '')..sep + ..(GetPathWithSep(self:fworkdir(wfilename)))..sep + ..(os.getenv('HOME') and GetPathWithSep(os.getenv('HOME'))..'bin' or '') + local paths = {} + for p in path:gmatch("[^"..sep.."]+") do + love2d = love2d or GetFullPathIfExists(p, win and 'love.exe' or 'love') + table.insert(paths, p) + end + if not love2d then + DisplayOutputLn("Can't find love2d executable in any of the following folders: " + ..table.concat(paths, ", ")) + return + end + end + + if not GetFullPathIfExists(self:fworkdir(wfilename), 'main.lua') then + DisplayOutputLn(("Can't find 'main.lua' file in the current project folder: '%s'.") + :format(self:fworkdir(wfilename))) + return + end + + if rundebug then + DebuggerAttachDefault({runstart = ide.config.debugger.runonstart == true}) + end + + -- suppress hiding ConsoleWindowClass as this is used by Love console + local uhw = ide.config.unhidewindow + local cwc = uhw and uhw.ConsoleWindowClass + if uhw then uhw.ConsoleWindowClass = 0 end + + local params = ide.config.arg.any or ide.config.arg.love2d + local cmd = ('"%s" "%s"%s%s'):format(love2d, self:fworkdir(wfilename), + params and " "..params or "", rundebug and ' -debug' or '') + -- CommandLineRun(cmd,wdir,tooutput,nohide,stringcallback,uid,endcallback) + return CommandLineRun(cmd,self:fworkdir(wfilename),true,true,nil,nil, + function() if uhw then uhw.ConsoleWindowClass = cwc end end) + end, + hasdebugger = true, + fattachdebug = function(self) DebuggerAttachDefault() end, + scratchextloop = true, + takeparameters = true, +} diff --git a/love2dToAPK/tools/tools/zbstudio-win/interpreters/luabase.lua b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luabase.lua new file mode 100644 index 0000000..d33edc2 --- /dev/null +++ b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luabase.lua @@ -0,0 +1,101 @@ +function MakeLuaInterpreter(version, name) + +local function exePath(self, version) + local version = tostring(version):gsub('%.','') + local mainpath = ide.editorFilename:gsub("[^/\\]+$","") + local macExe = mainpath..([[bin/lua.app/Contents/MacOS/lua%s]]):format(version) + return ide.config.path['lua'..version] + or (ide.osname == "Windows" and mainpath..([[bin\lua%s.exe]]):format(version)) + or (ide.osname == "Unix" and mainpath..([[bin/linux/%s/lua%s]]):format(ide.osarch, version)) + or (wx.wxFileExists(macExe) and macExe or mainpath..([[bin/lua%s]]):format(version)) +end + +return { + name = ("Lua%s"):format(name or version or ""), + description = ("Lua%s interpreter with debugger"):format(name or version or ""), + api = {"baselib"}, + luaversion = version or '5.1', + fexepath = exePath, + frun = function(self,wfilename,rundebug) + local exe = self:fexepath(version or "") + local filepath = wfilename:GetFullPath() + + do + -- if running on Windows and can't open the file, this may mean that + -- the file path includes unicode characters that need special handling + local fh = io.open(filepath, "r") + if fh then fh:close() end + if ide.osname == 'Windows' and pcall(require, "winapi") + and wfilename:FileExists() and not fh then + winapi.set_encoding(winapi.CP_UTF8) + local shortpath = winapi.short_path(filepath) + if shortpath == filepath then + DisplayOutputLn( + ("Can't get short path for a Unicode file name '%s' to open the file.") + :format(filepath)) + DisplayOutputLn( + ("You can enable short names by using `fsutil 8dot3name set %s: 0` and recreate the file or directory.") + :format(wfilename:GetVolume())) + end + filepath = shortpath + end + end + + if rundebug then + DebuggerAttachDefault({runstart = ide.config.debugger.runonstart == true}) + + -- update arg to point to the proper file + rundebug = ('if arg then arg[0] = [[%s]] end '):format(filepath)..rundebug + + local tmpfile = wx.wxFileName() + tmpfile:AssignTempFileName(".") + filepath = tmpfile:GetFullPath() + local f = io.open(filepath, "w") + if not f then + DisplayOutputLn("Can't open temporary file '"..filepath.."' for writing.") + return + end + f:write(rundebug) + f:close() + end + local params = ide.config.arg.any or ide.config.arg.lua + local code = ([[-e "io.stdout:setvbuf('no')" "%s"]]):format(filepath) + local cmd = '"'..exe..'" '..code..(params and " "..params or "") + + -- modify CPATH to work with other Lua versions + 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 and not ide.config.path['lua'..(version or "")] then + -- prepend osclibs as the libraries may be needed for debugging, + -- but only if no path.lua is set as it may conflict with system libs + wx.wxSetEnv(envname, ide.osclibs..';'..cpath) + end + 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(envname, cpath) end + return pid + end, + hasdebugger = true, + fattachdebug = function(self) DebuggerAttachDefault() end, + scratchextloop = false, + unhideanywindow = true, + takeparameters = true, +} + +end + +return nil -- as this is not a real interpreter diff --git a/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb.lua b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb.lua new file mode 100644 index 0000000..49af279 --- /dev/null +++ b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb.lua @@ -0,0 +1,2 @@ +dofile 'interpreters/luabase.lua' +return MakeLuaInterpreter() diff --git a/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb52.lua b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb52.lua new file mode 100644 index 0000000..989afbc --- /dev/null +++ b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb52.lua @@ -0,0 +1,2 @@ +dofile 'interpreters/luabase.lua' +return MakeLuaInterpreter(5.2, ' 5.2') diff --git a/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb53.lua b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb53.lua new file mode 100644 index 0000000..4b08672 --- /dev/null +++ b/love2dToAPK/tools/tools/zbstudio-win/interpreters/luadeb53.lua @@ -0,0 +1,4 @@ +dofile 'interpreters/luabase.lua' +local interpreter = MakeLuaInterpreter(5.3, ' 5.3') +interpreter.skipcompile = true +return interpreter |