Mercurial > pub > dyncall > bindings
diff lua/luadyncall/test/test_path.lua @ 0:0cfcc391201f
initial from svn dyncall-1745
author | Daniel Adler |
---|---|
date | Thu, 19 Mar 2015 22:26:28 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/lua/luadyncall/test/test_path.lua Thu Mar 19 22:26:28 2015 +0100 @@ -0,0 +1,36 @@ +require "path" +require "dynload" + +function init(env,syspath) + local env = env or "LIBPATH" + local syspath = syspath or ";?.framework/?;lib?.dylib;" + print("env\t="..env) + print("syspath\t="..syspath) + local path = pathinit(env,syspath) + print("path\t="..path) + return(path) +end + +local mypath = init() + +function findlib(name) + local found, location = pathfind(mypath, name, loadlib) + if found then + print("found at " .. location .. " ( object= " .. tostring(found) .. " )" ) + else + print("FAILED: findlib('"..name.."'). tried:\n - " .. table.concat(location,"\n - ") .. "\n" ) + end +end + +function trylib(name) + print("trylib",name) + local status, msg = pcall( findlib, name ) + print(status,msg) +end + +trylib("GL") +trylib("OpenGL") +trylib("SDL") +trylib("Bla") + +