From 4323ed7a2f567242680f484920a9b721f895d3ca Mon Sep 17 00:00:00 2001 From: Renaud Guillard Date: Wed, 7 Jan 2015 00:31:34 +0100 Subject: [PATCH] os.findlib(): add new argument to specify additional library search paths --- src/base/os.lua | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/base/os.lua b/src/base/os.lua index f02694c0..12e90998 100644 --- a/src/base/os.lua +++ b/src/base/os.lua @@ -63,7 +63,10 @@ return dirs end - function os.findlib(libname) + function os.findlib(libname, libdirs) + -- libname: library name with or without prefix and suffix + -- libdirs: (array or string): A set of additional search paths + local path, formats -- assemble a search path, depending on the platform @@ -99,6 +102,18 @@ path = path .. ":/lib:/usr/lib:/usr/local/lib" end + local userpath = "" + + if type(libdirs) == "string" then + userpath = libdirs + elseif type(libdirs) == "table" then + userpath = table.implode(libdirs, "", "", ":") + end + + if (#userpath > 0) then + path = ":" .. userpath .. path + end + for _, fmt in ipairs(formats) do local name = string.format(fmt, libname) local result = os.pathsearch(name, path)