diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 11:55:39 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-02-19 16:35:00 -0300 |
| commit | c13ff298bdd424d7b7401fce4f0379cda0348af8 (patch) | |
| tree | 9cc8551a3c23ae09020bb135c202aa34029d150d /src | |
| parent | 50ebdd5d17c8390d30132c165d2e0a614dc0ecae (diff) | |
| download | luarocks-c13ff298bdd424d7b7401fce4f0379cda0348af8.tar.gz luarocks-c13ff298bdd424d7b7401fce4f0379cda0348af8.tar.bz2 luarocks-c13ff298bdd424d7b7401fce4f0379cda0348af8.zip | |
fix(build): don't look for Lua headers when installing pure-Lua rocks
This only applies to 'builtin' as we can't know about other modes,
but this should be good enough.
Fixes #1275.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build.lua | 34 | ||||
| -rw-r--r-- | src/luarocks/build/builtin.lua | 52 | ||||
| -rw-r--r-- | src/luarocks/cmd.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 54 |
4 files changed, 85 insertions, 57 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 471de427..55242e60 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -111,18 +111,6 @@ local function process_dependencies(rockspec, opts) | |||
| 111 | end | 111 | end |
| 112 | end | 112 | end |
| 113 | 113 | ||
| 114 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) | ||
| 115 | if not ok then | ||
| 116 | return nil, err, errcode | ||
| 117 | end | ||
| 118 | |||
| 119 | if cfg.link_lua_explicitly then | ||
| 120 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | ||
| 121 | if not ok then | ||
| 122 | return nil, err, errcode | ||
| 123 | end | ||
| 124 | end | ||
| 125 | |||
| 126 | if opts.deps_mode == "none" then | 114 | if opts.deps_mode == "none" then |
| 127 | return true | 115 | return true |
| 128 | end | 116 | end |
| @@ -165,11 +153,8 @@ local function process_dependencies(rockspec, opts) | |||
| 165 | end | 153 | end |
| 166 | end | 154 | end |
| 167 | end | 155 | end |
| 168 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify) | 156 | |
| 169 | if err then | 157 | return deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode, opts.verify) |
| 170 | return nil, err, errcode | ||
| 171 | end | ||
| 172 | return true | ||
| 173 | end | 158 | end |
| 174 | 159 | ||
| 175 | local function fetch_and_change_to_source_dir(rockspec, opts) | 160 | local function fetch_and_change_to_source_dir(rockspec, opts) |
| @@ -241,6 +226,21 @@ local function run_build_driver(rockspec, no_install) | |||
| 241 | if not pok or type(driver) ~= "table" then | 226 | if not pok or type(driver) ~= "table" then |
| 242 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver | 227 | return nil, "Failed initializing build back-end for build type '"..btype.."': "..driver |
| 243 | end | 228 | end |
| 229 | |||
| 230 | if not driver.skip_lua_inc_lib_check then | ||
| 231 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) | ||
| 232 | if not ok then | ||
| 233 | return nil, err, errcode | ||
| 234 | end | ||
| 235 | |||
| 236 | if cfg.link_lua_explicitly then | ||
| 237 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | ||
| 238 | if not ok then | ||
| 239 | return nil, err, errcode | ||
| 240 | end | ||
| 241 | end | ||
| 242 | end | ||
| 243 | |||
| 244 | local ok, err = driver.run(rockspec, no_install) | 244 | local ok, err = driver.run(rockspec, no_install) |
| 245 | if not ok then | 245 | if not ok then |
| 246 | return nil, "Build error: " .. err | 246 | return nil, "Build error: " .. err |
diff --git a/src/luarocks/build/builtin.lua b/src/luarocks/build/builtin.lua index 70210bab..c55b61a0 100644 --- a/src/luarocks/build/builtin.lua +++ b/src/luarocks/build/builtin.lua | |||
| @@ -2,6 +2,11 @@ | |||
| 2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. | 2 | --- A builtin build system: back-end to provide a portable way of building C-based Lua modules. |
| 3 | local builtin = {} | 3 | local builtin = {} |
| 4 | 4 | ||
| 5 | -- This build driver checks LUA_INCDIR and LUA_LIBDIR on demand, | ||
| 6 | -- so that pure-Lua rocks don't need to have development headers | ||
| 7 | -- installed. | ||
| 8 | builtin.skip_lua_inc_lib_check = true | ||
| 9 | |||
| 5 | local unpack = unpack or table.unpack | 10 | local unpack = unpack or table.unpack |
| 6 | 11 | ||
| 7 | local fs = require("luarocks.fs") | 12 | local fs = require("luarocks.fs") |
| @@ -9,38 +14,7 @@ local path = require("luarocks.path") | |||
| 9 | local util = require("luarocks.util") | 14 | local util = require("luarocks.util") |
| 10 | local cfg = require("luarocks.core.cfg") | 15 | local cfg = require("luarocks.core.cfg") |
| 11 | local dir = require("luarocks.dir") | 16 | local dir = require("luarocks.dir") |
| 12 | 17 | local deps = require("luarocks.deps") | |
| 13 | function builtin.autodetect_external_dependencies(build) | ||
| 14 | if not build or not build.modules then | ||
| 15 | return nil | ||
| 16 | end | ||
| 17 | local extdeps = {} | ||
| 18 | local any = false | ||
| 19 | for _, data in pairs(build.modules) do | ||
| 20 | if type(data) == "table" and data.libraries then | ||
| 21 | local libraries = data.libraries | ||
| 22 | if type(libraries) == "string" then | ||
| 23 | libraries = { libraries } | ||
| 24 | end | ||
| 25 | local incdirs = {} | ||
| 26 | local libdirs = {} | ||
| 27 | for _, lib in ipairs(libraries) do | ||
| 28 | local upper = lib:upper():gsub("%+", "P"):gsub("[^%w]", "_") | ||
| 29 | any = true | ||
| 30 | extdeps[upper] = { library = lib } | ||
| 31 | table.insert(incdirs, "$(" .. upper .. "_INCDIR)") | ||
| 32 | table.insert(libdirs, "$(" .. upper .. "_LIBDIR)") | ||
| 33 | end | ||
| 34 | if not data.incdirs then | ||
| 35 | data.incdirs = incdirs | ||
| 36 | end | ||
| 37 | if not data.libdirs then | ||
| 38 | data.libdirs = libdirs | ||
| 39 | end | ||
| 40 | end | ||
| 41 | end | ||
| 42 | return any and extdeps or nil | ||
| 43 | end | ||
| 44 | 18 | ||
| 45 | local function autoextract_libs(external_dependencies, variables) | 19 | local function autoextract_libs(external_dependencies, variables) |
| 46 | if not external_dependencies then | 20 | if not external_dependencies then |
| @@ -323,10 +297,16 @@ function builtin.run(rockspec, no_install) | |||
| 323 | end | 297 | end |
| 324 | if type(info) == "table" then | 298 | if type(info) == "table" then |
| 325 | if not checked_lua_h then | 299 | if not checked_lua_h then |
| 326 | local lua_incdir, lua_h = variables.LUA_INCDIR, "lua.h" | 300 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) |
| 327 | if not fs.exists(dir.path(lua_incdir, lua_h)) then | 301 | if not ok then |
| 328 | return nil, "Lua header file "..lua_h.." not found (looked in "..lua_incdir.."). \n" .. | 302 | return nil, err, errcode |
| 329 | "You need to install the Lua development package for your system." | 303 | end |
| 304 | |||
| 305 | if cfg.link_lua_explicitly then | ||
| 306 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | ||
| 307 | if not ok then | ||
| 308 | return nil, err, errcode | ||
| 309 | end | ||
| 330 | end | 310 | end |
| 331 | checked_lua_h = true | 311 | checked_lua_h = true |
| 332 | end | 312 | end |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 3cbe3852..3067f4ce 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -561,7 +561,7 @@ function cmd.run_command(description, commands, external_namespace, ...) | |||
| 561 | util.warning("command module " .. module .. " does not implement command(), skipping") | 561 | util.warning("command module " .. module .. " does not implement command(), skipping") |
| 562 | end | 562 | end |
| 563 | else | 563 | else |
| 564 | util.warning("failed to load command module " .. module) | 564 | util.warning("failed to load command module " .. module .. ": " .. mod) |
| 565 | end | 565 | end |
| 566 | end | 566 | end |
| 567 | 567 | ||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 8af28327..2680b64b 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -10,7 +10,6 @@ local fun = require("luarocks.fun") | |||
| 10 | local util = require("luarocks.util") | 10 | local util = require("luarocks.util") |
| 11 | local vers = require("luarocks.core.vers") | 11 | local vers = require("luarocks.core.vers") |
| 12 | local queries = require("luarocks.queries") | 12 | local queries = require("luarocks.queries") |
| 13 | local builtin = require("luarocks.build.builtin") | ||
| 14 | local deplocks = require("luarocks.deplocks") | 13 | local deplocks = require("luarocks.deplocks") |
| 15 | 14 | ||
| 16 | --- Generate a function that matches dep queries against the manifest, | 15 | --- Generate a function that matches dep queries against the manifest, |
| @@ -570,6 +569,40 @@ local function check_external_dependency(name, ext_files, vars, mode, cache) | |||
| 570 | return nil, err_dirname, err_testfile, err_files | 569 | return nil, err_dirname, err_testfile, err_files |
| 571 | end | 570 | end |
| 572 | 571 | ||
| 572 | function deps.autodetect_external_dependencies(build) | ||
| 573 | -- only applies to the 'builtin' build type | ||
| 574 | if not build or not build.modules then | ||
| 575 | return nil | ||
| 576 | end | ||
| 577 | |||
| 578 | local extdeps = {} | ||
| 579 | local any = false | ||
| 580 | for _, data in pairs(build.modules) do | ||
| 581 | if type(data) == "table" and data.libraries then | ||
| 582 | local libraries = data.libraries | ||
| 583 | if type(libraries) == "string" then | ||
| 584 | libraries = { libraries } | ||
| 585 | end | ||
| 586 | local incdirs = {} | ||
| 587 | local libdirs = {} | ||
| 588 | for _, lib in ipairs(libraries) do | ||
| 589 | local upper = lib:upper():gsub("%+", "P"):gsub("[^%w]", "_") | ||
| 590 | any = true | ||
| 591 | extdeps[upper] = { library = lib } | ||
| 592 | table.insert(incdirs, "$(" .. upper .. "_INCDIR)") | ||
| 593 | table.insert(libdirs, "$(" .. upper .. "_LIBDIR)") | ||
| 594 | end | ||
| 595 | if not data.incdirs then | ||
| 596 | data.incdirs = incdirs | ||
| 597 | end | ||
| 598 | if not data.libdirs then | ||
| 599 | data.libdirs = libdirs | ||
| 600 | end | ||
| 601 | end | ||
| 602 | end | ||
| 603 | return any and extdeps or nil | ||
| 604 | end | ||
| 605 | |||
| 573 | --- Set up path-related variables for external dependencies. | 606 | --- Set up path-related variables for external dependencies. |
| 574 | -- For each key in the external_dependencies table in the | 607 | -- For each key in the external_dependencies table in the |
| 575 | -- rockspec file, four variables are created: <key>_DIR, <key>_BINDIR, | 608 | -- rockspec file, four variables are created: <key>_DIR, <key>_BINDIR, |
| @@ -587,7 +620,7 @@ function deps.check_external_deps(rockspec, mode) | |||
| 587 | assert(rockspec:type() == "rockspec") | 620 | assert(rockspec:type() == "rockspec") |
| 588 | 621 | ||
| 589 | if not rockspec.external_dependencies then | 622 | if not rockspec.external_dependencies then |
| 590 | rockspec.external_dependencies = builtin.autodetect_external_dependencies(rockspec.build) | 623 | rockspec.external_dependencies = deps.autodetect_external_dependencies(rockspec.build) |
| 591 | end | 624 | end |
| 592 | if not rockspec.external_dependencies then | 625 | if not rockspec.external_dependencies then |
| 593 | return true | 626 | return true |
| @@ -706,16 +739,25 @@ local function find_lua_incdir(prefix, luaver, luajitver) | |||
| 706 | end | 739 | end |
| 707 | 740 | ||
| 708 | function deps.check_lua_incdir(vars) | 741 | function deps.check_lua_incdir(vars) |
| 742 | if vars.LUA_INCDIR_OK == true | ||
| 743 | then return true | ||
| 744 | end | ||
| 745 | |||
| 709 | local ljv = util.get_luajit_version() | 746 | local ljv = util.get_luajit_version() |
| 710 | 747 | ||
| 711 | if vars.LUA_INCDIR then | 748 | if vars.LUA_INCDIR then |
| 712 | return lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) | 749 | local ok, err = lua_h_exists(vars.LUA_INCDIR, cfg.lua_version) |
| 750 | if ok then | ||
| 751 | vars.LUA_INCDIR_OK = true | ||
| 752 | end | ||
| 753 | return ok, err | ||
| 713 | end | 754 | end |
| 714 | 755 | ||
| 715 | if vars.LUA_DIR then | 756 | if vars.LUA_DIR then |
| 716 | local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) | 757 | local d, err = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) |
| 717 | if d then | 758 | if d then |
| 718 | vars.LUA_INCDIR = d | 759 | vars.LUA_INCDIR = d |
| 760 | vars.LUA_INCDIR_OK = true | ||
| 719 | return true | 761 | return true |
| 720 | end | 762 | end |
| 721 | return nil, err | 763 | return nil, err |
| @@ -725,10 +767,15 @@ function deps.check_lua_incdir(vars) | |||
| 725 | end | 767 | end |
| 726 | 768 | ||
| 727 | function deps.check_lua_libdir(vars) | 769 | function deps.check_lua_libdir(vars) |
| 770 | if vars.LUA_LIBDIR_OK == true | ||
| 771 | then return true | ||
| 772 | end | ||
| 773 | |||
| 728 | local fs = require("luarocks.fs") | 774 | local fs = require("luarocks.fs") |
| 729 | local ljv = util.get_luajit_version() | 775 | local ljv = util.get_luajit_version() |
| 730 | 776 | ||
| 731 | if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then | 777 | if vars.LUA_LIBDIR and vars.LUALIB and fs.exists(dir.path(vars.LUA_LIBDIR, vars.LUALIB)) then |
| 778 | vars.LUA_LIBDIR_OK = true | ||
| 732 | return true | 779 | return true |
| 733 | end | 780 | end |
| 734 | 781 | ||
| @@ -768,6 +815,7 @@ function deps.check_lua_libdir(vars) | |||
| 768 | 815 | ||
| 769 | if ok then | 816 | if ok then |
| 770 | vars.LUALIB = vars.LUA_LIBDIR_FILE | 817 | vars.LUALIB = vars.LUA_LIBDIR_FILE |
| 818 | vars.LUA_LIBDIR_OK = true | ||
| 771 | return true | 819 | return true |
| 772 | else | 820 | else |
| 773 | err = err or "Failed finding Lua library. You may need to configure LUA_LIBDIR." | 821 | err = err or "Failed finding Lua library. You may need to configure LUA_LIBDIR." |
