diff options
Diffstat (limited to 'src/luarocks/deps.lua')
-rw-r--r-- | src/luarocks/deps.lua | 43 |
1 files changed, 38 insertions, 5 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 90c7b3d9..53798cd1 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -303,7 +303,8 @@ local function check_external_dependency_at(extdir, name, ext_files, vars, dirs, | |||
303 | local file = ext_files[dirdata.testfile] | 303 | local file = ext_files[dirdata.testfile] |
304 | if file then | 304 | if file then |
305 | local files = {} | 305 | local files = {} |
306 | if not file:match("%.") then | 306 | -- If it doesn't look like it contains a filename extension |
307 | if not (file:match("%.[a-z]+$") or file:match("%.[a-z]+%.")) then | ||
307 | add_all_patterns(file, dirdata.pattern, files) | 308 | add_all_patterns(file, dirdata.pattern, files) |
308 | else | 309 | else |
309 | for _, pattern in ipairs(dirdata.pattern) do | 310 | for _, pattern in ipairs(dirdata.pattern) do |
@@ -474,16 +475,48 @@ function deps.scan_deps(results, manifest, name, version, deps_mode) | |||
474 | end | 475 | end |
475 | end | 476 | end |
476 | 477 | ||
477 | function deps.check_lua_library(rockspec) | 478 | local function find_lua_incdir(prefix, luaver, luajitver) |
479 | luajitver = luajitver and luajitver:gsub("%-.*", "") | ||
480 | local incdirs = { | ||
481 | prefix .. "/include/lua/" .. luaver, | ||
482 | prefix .. "/include/lua" .. luaver, | ||
483 | prefix .. "/include", | ||
484 | prefix, | ||
485 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), | ||
486 | } | ||
487 | for _, d in ipairs(incdirs) do | ||
488 | local lua_h = dir.path(d, "lua.h") | ||
489 | local fd = io.open(lua_h) | ||
490 | if fd then | ||
491 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
492 | fd:close() | ||
493 | return d | ||
494 | end | ||
495 | end | ||
496 | |||
497 | -- not found, will fallback to a default | ||
498 | return nil | ||
499 | end | ||
500 | |||
501 | function deps.check_lua(vars) | ||
502 | if (not vars.LUA_INCDIR) and vars.LUA_DIR then | ||
503 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, cfg.luajit_version) | ||
504 | end | ||
505 | local shortv = cfg.lua_version:gsub("%.", "") | ||
478 | local libnames = { | 506 | local libnames = { |
479 | "lua" .. cfg.lua_version, | 507 | "lua" .. cfg.lua_version, |
480 | "lua" .. cfg.lua_version:gsub("%.", ""), | 508 | "lua" .. shortv, |
509 | "lua-" .. cfg.lua_version, | ||
510 | "lua-" .. shortv, | ||
481 | "lua", | 511 | "lua", |
482 | } | 512 | } |
513 | if cfg.luajit_version then | ||
514 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) | ||
515 | end | ||
483 | for _, libname in ipairs(libnames) do | 516 | for _, libname in ipairs(libnames) do |
484 | local ok = check_external_dependency("LUA", { library = libname }, rockspec.variables, "build") | 517 | local ok = check_external_dependency("LUA", { library = libname }, vars, "build") |
485 | if ok then | 518 | if ok then |
486 | rockspec.variables.LUALIB = rockspec.variables.LUA_LIBDIR_FILE | 519 | vars.LUALIB = vars.LUA_LIBDIR_FILE |
487 | return true | 520 | return true |
488 | end | 521 | end |
489 | end | 522 | end |