Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/premake-4.x-stable.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Perkins <starkos@industriousone.com>2013-01-29 19:58:11 +0400
committerJason Perkins <starkos@industriousone.com>2013-01-29 19:58:11 +0400
commit65b2ea88641f53f2a69564d8651c1034e693eba2 (patch)
tree9ac1cccdc1c7f9b0282d6c8029c00f97d6dd25cb
parent1ab1d57421cab892d5b41a4da4a277310e2dc297 (diff)
parentb2ca3e4d0df86b77e336eb57cdc3fe31e2997014 (diff)
Merged in bitshifter/premake-stable-linux-findlib-fix-take-2 (pull request #7)
Process ld.so.conf for includes, fixes os.findlib in Linux.
-rw-r--r--src/base/os.lua38
1 files changed, 32 insertions, 6 deletions
diff --git a/src/base/os.lua b/src/base/os.lua
index e9a1ff0..87255da 100644
--- a/src/base/os.lua
+++ b/src/base/os.lua
@@ -19,6 +19,36 @@
-- Scan the well-known system locations for a particular library.
--
+ local function parse_ld_so_conf(conf_file)
+ -- Linux ldconfig file parser to find system library locations
+ local first, last
+ local dirs = { }
+ for line in io.lines(conf_file) do
+ -- ignore comments
+ first = line:find("#", 1, true)
+ if first ~= nil then
+ line = line:sub(1, first - 1)
+ end
+
+ if line ~= "" then
+ -- check for include files
+ first, last = line:find("include%s+")
+ if first ~= nil then
+ -- found include glob
+ local include_glob = line:sub(last + 1)
+ local includes = os.matchfiles(include_glob)
+ for _, v in ipairs(includes) do
+ dirs = table.join(dirs, parse_ld_so_conf(v))
+ end
+ else
+ -- found an actual ld path entry
+ table.insert(dirs, line)
+ end
+ end
+ end
+ return dirs
+ end
+
function os.findlib(libname)
local path, formats
@@ -37,12 +67,8 @@
formats = { "lib%s.so", "%s.so" }
path = os.getenv("LD_LIBRARY_PATH") or ""
- io.input("/etc/ld.so.conf")
- if io.input() then
- for line in io.lines() do
- path = path .. ":" .. line
- end
- io.input():close()
+ for _, v in ipairs(parse_ld_so_conf("/etc/ld.so.conf")) do
+ path = path .. ":" .. v
end
end