-- -- HAMSTER.LUA Copyright (c) 2003-05, asko.kauppi@sci.fi -- -- Autodetecting OS/compiler front end for Hamster. -- -- Usage: -- 'lua [-w] -l hamster ..yourbuildscripts..' -- -- Author: -- asko.kauppi@sci.fi -- -- License: -- GPL (see 'license.txt') -- -- To-do: ... -- local MY_PATH for pat in string.gfind( LUA_PATH, "[^;]+" ) do local try= string.gsub( pat, "?%.lua", "" ) local fh= io.open(try.."hamster.lua","r") if fh then fh:close(); MY_PATH=try; break end end assert( MY_PATH, "Path to Hamster not found!" ) -- "Tools/Hamster/" -- local m= assert( dofile( MY_PATH.."hamster_core.lua" ) ) -- just two funcs needed local Loc_PathAsTable= assert( m.PathAsTable ) local Loc_FileExists= assert( m.FileExists ) ----- -- Returns: "gcc" for Gnu GCC (Win32/Linux/OS X/...) -- "msc" for MS Visual C++ (Win32) -- "evc" for eMbedded Visual C++ (WinCE) -- 'nil' for others (system specific default compiler) -- local function Loc_CompilerDetect( ) -- if WINCE then return "evc" -- elseif (not WIN32) or WIN32.msys then return "gcc" end -- Win32 native left: msc or gcc? -- local tbl= Loc_PathAsTable() -- Try to find gcc first, if none, try msc. -- for _,dir in pairs(tbl) do if Loc_FileExists( dir.."gcc.exe" ) then return "gcc" end end for _,dir in pairs(tbl) do if Loc_FileExists( dir.."cl.exe" ) then return "msc" end end -- Note: SCons supports more compilers than this (s.a. Intel) and -- you can use them with Hamster just as well. -- return nil -- No compiler found?!? end local which= Loc_CompilerDetect() or "custom" -- ASSUME( not rawget(_G,"arg") ) -- started by '-l', right? rawset(_G,"arg",false) arg= { [0]= MY_PATH.."hamster_"..which..".lua", m } -- already loaded hamster_core m= dofile( arg[0] ) if not m then error( "Necessary adapter not found: "..arg[0] ) end assert( rawget(_G,"hamster") == m ) return m