aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHisham Muhammad <hisham@gobolinux.org>2024-02-19 10:54:49 -0300
committerHisham Muhammad <hisham@gobolinux.org>2024-02-19 10:54:49 -0300
commit97fcaef0f769f4d59ff063e477ecffdc7e3c6103 (patch)
treebd66adf338d972112c99fc26946a0a39553de0e4
parent272921b2adf6136448dda9011425f8304c9d508d (diff)
downloadluarocks-fix-1041.tar.gz
luarocks-fix-1041.tar.bz2
luarocks-fix-1041.zip
when picking a default dependency dir, look for lib/ firstfix-1041
When a rockspec specifies `external_dependencies` but those don't define a `library` entry, we don't have a way to check for the various possible `external_deps_subdirs` to find the one that contains the library. (But people really should specify a `library` entry there if they're linking the library!) Previously, we were just picking the first one from the list. On Windows, this meant that sometimes setting `MY_DEPENDENCY_DIR` would not be sufficient if the library was under `$MY_DEPENDENCY_DIR/lib`, because "" was picked first. We now improve the heuristic by putting "lib" first on the list and checking if it exists. I'm still keeping "bin" in the end of the list, because I think this is less common that a flat directory structure on Windows, so "lib" covers the Unix-like trees and "" covers flat trees (I don't remember why have "bin" as a library subdir on Windows, but if it's there then we must have seen it in the wild!) This means that "bin" will never get auto-picked by this heuristic, but it will be available for the cases where `library` _is_ set. While I'm at it, I also flipped the order of some Unix entries, so that this heuristic for these kind of rockspecs gets a nicer behavior on Unix systems that have things like `/usr/lib64` and `/usr/lib/<platform>` as well. Fixes #1041.
-rw-r--r--src/luarocks/core/cfg.lua16
-rw-r--r--src/luarocks/deps.lua12
2 files changed, 19 insertions, 9 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
index 2e5301c1..2e144c62 100644
--- a/src/luarocks/core/cfg.lua
+++ b/src/luarocks/core/cfg.lua
@@ -319,8 +319,8 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
319 defaults.local_cache = localappdata.."/LuaRocks/Cache" 319 defaults.local_cache = localappdata.."/LuaRocks/Cache"
320 defaults.web_browser = "start" 320 defaults.web_browser = "start"
321 321
322 defaults.external_deps_subdirs.lib = { "", "lib", "bin" } 322 defaults.external_deps_subdirs.lib = { "lib", "", "bin" }
323 defaults.runtime_external_deps_subdirs.lib = { "", "lib", "bin" } 323 defaults.runtime_external_deps_subdirs.lib = { "lib", "", "bin" }
324 defaults.link_lua_explicitly = true 324 defaults.link_lua_explicitly = true
325 defaults.fs_use_modules = false 325 defaults.fs_use_modules = false
326 end 326 end
@@ -494,8 +494,8 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
494 494
495 -- Homebrew 495 -- Homebrew
496 table.insert(defaults.external_deps_dirs, "/usr/local/opt") 496 table.insert(defaults.external_deps_dirs, "/usr/local/opt")
497 defaults.external_deps_subdirs.lib = { "", "lib", } 497 defaults.external_deps_subdirs.lib = { "lib", "" }
498 defaults.runtime_external_deps_subdirs.lib = { "", "lib", } 498 defaults.runtime_external_deps_subdirs.lib = { "lib", "" }
499 table.insert(defaults.external_deps_patterns.lib, 1, "/?/lib/lib?.dylib") 499 table.insert(defaults.external_deps_patterns.lib, 1, "/?/lib/lib?.dylib")
500 table.insert(defaults.runtime_external_deps_patterns.lib, 1, "/?/lib/lib?.dylib") 500 table.insert(defaults.runtime_external_deps_patterns.lib, 1, "/?/lib/lib?.dylib")
501 end 501 end
@@ -505,11 +505,11 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
505 505
506 local gcc_arch = util.popen_read("gcc -print-multiarch 2>/dev/null") 506 local gcc_arch = util.popen_read("gcc -print-multiarch 2>/dev/null")
507 if gcc_arch and gcc_arch ~= "" then 507 if gcc_arch and gcc_arch ~= "" then
508 defaults.external_deps_subdirs.lib = { "lib", "lib/" .. gcc_arch, "lib64" } 508 defaults.external_deps_subdirs.lib = { "lib/" .. gcc_arch, "lib64", "lib" }
509 defaults.runtime_external_deps_subdirs.lib = { "lib", "lib/" .. gcc_arch, "lib64" } 509 defaults.runtime_external_deps_subdirs.lib = { "lib/" .. gcc_arch, "lib64", "lib" }
510 else 510 else
511 defaults.external_deps_subdirs.lib = { "lib", "lib64" } 511 defaults.external_deps_subdirs.lib = { "lib64", "lib" }
512 defaults.runtime_external_deps_subdirs.lib = { "lib", "lib64" } 512 defaults.runtime_external_deps_subdirs.lib = { "lib64", "lib" }
513 end 513 end
514 end 514 end
515 515
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index e61425f6..f4c04c35 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -446,7 +446,6 @@ local function check_external_dependency_at(prefix, name, ext_files, vars, dirs,
446 else 446 else
447 paths = { dir.path(prefix, dirdata.subdir) } 447 paths = { dir.path(prefix, dirdata.subdir) }
448 end 448 end
449 dirdata.dir = paths[1]
450 local file_or_files = ext_files[dirdata.testfile] 449 local file_or_files = ext_files[dirdata.testfile]
451 if file_or_files then 450 if file_or_files then
452 local files = {} 451 local files = {}
@@ -512,6 +511,17 @@ local function check_external_dependency_at(prefix, name, ext_files, vars, dirs,
512 if not found then 511 if not found then
513 return nil, dirname, dirdata.testfile 512 return nil, dirname, dirdata.testfile
514 end 513 end
514 else
515 -- When we have a set of subdir suffixes, look for one that exists.
516 -- For these reason, we now put "lib" ahead of "" on Windows in our
517 -- default set.
518 dirdata.dir = paths[1]
519 for _, p in ipairs(paths) do
520 if fs.exists(p) then
521 dirdata.dir = p
522 break
523 end
524 end
515 end 525 end
516 end 526 end
517 527