aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2022-12-07 20:15:43 -0300
committerGitHub <noreply@github.com>2022-12-07 20:15:43 -0300
commit500aeba152d6da90331788885df99ea314081c6f (patch)
treef9080df6a3e0fe358c97f0acf5049126f702b768
parent1c9266d6521c16e126fdff0be785c81170ed4b4c (diff)
downloadluarocks-500aeba152d6da90331788885df99ea314081c6f.tar.gz
luarocks-500aeba152d6da90331788885df99ea314081c6f.tar.bz2
luarocks-500aeba152d6da90331788885df99ea314081c6f.zip
path.path_to_module: accept custom extensions in package.(c)path (#1468)
-rw-r--r--src/luarocks/core/path.lua31
1 files changed, 18 insertions, 13 deletions
diff --git a/src/luarocks/core/path.lua b/src/luarocks/core/path.lua
index bf6bdc2d..b354a41a 100644
--- a/src/luarocks/core/path.lua
+++ b/src/luarocks/core/path.lua
@@ -44,24 +44,29 @@ end
44function path.path_to_module(file) 44function path.path_to_module(file)
45 assert(type(file) == "string") 45 assert(type(file) == "string")
46 46
47 local name = file:match("(.*)%."..cfg.lua_extension.."$") 47 local exts = {}
48 if name then 48 local paths = package.path .. ";" .. package.cpath
49 name = name:gsub("/", ".") 49 for entry in paths:gmatch("[^;]+") do
50 else 50 local ext = entry:match("%.([a-z]+)$")
51 name = file:match("(.*)%."..cfg.lib_extension.."$") 51 if ext then
52 exts[ext] = true
53 end
54 end
55
56 local name
57 for ext, _ in pairs(exts) do
58 name = file:match("(.*)%." .. ext .. "$")
52 if name then 59 if name then
53 name = name:gsub("/", ".") 60 name = name:gsub("[/\\]", ".")
54 --[[ TODO disable static libs until we fix the conflict in the manifest, which will take extending the manifest format. 61 break
55 else
56 name = file:match("(.*)%."..cfg.static_lib_extension.."$")
57 if name then
58 name = name:gsub("/", ".")
59 end
60 ]]
61 end 62 end
62 end 63 end
64
63 if not name then name = file end 65 if not name then name = file end
66
67 -- remove any beginning and trailing slashes-converted-to-dots
64 name = name:gsub("^%.+", ""):gsub("%.+$", "") 68 name = name:gsub("^%.+", ""):gsub("%.+$", "")
69
65 return name 70 return name
66end 71end
67 72