annotate lua/luadyncall/test/test_path.lua @ 14:7752fcb107e7

- erlang binding build fix, linker arg was at wrong place
author cslag
date Sat, 26 Mar 2016 16:09:04 +0100
parents 0cfcc391201f
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
1 require "path"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
2 require "dynload"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
3
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
4 function init(env,syspath)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
5 local env = env or "LIBPATH"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
6 local syspath = syspath or ";?.framework/?;lib?.dylib;"
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
7 print("env\t="..env)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
8 print("syspath\t="..syspath)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
9 local path = pathinit(env,syspath)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
10 print("path\t="..path)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
11 return(path)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
12 end
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
13
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
14 local mypath = init()
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
15
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
16 function findlib(name)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
17 local found, location = pathfind(mypath, name, loadlib)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
18 if found then
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
19 print("found at " .. location .. " ( object= " .. tostring(found) .. " )" )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
20 else
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
21 print("FAILED: findlib('"..name.."'). tried:\n - " .. table.concat(location,"\n - ") .. "\n" )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
22 end
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
23 end
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
24
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
25 function trylib(name)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
26 print("trylib",name)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
27 local status, msg = pcall( findlib, name )
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
28 print(status,msg)
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
29 end
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
30
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
31 trylib("GL")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
32 trylib("OpenGL")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
33 trylib("SDL")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
34 trylib("Bla")
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
35
0cfcc391201f initial from svn dyncall-1745
Daniel Adler
parents:
diff changeset
36