diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2018-06-27 10:55:16 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-07-01 21:32:39 -0300 |
| commit | 9404d59d48a511983ed30a6d0f605041a74ff332 (patch) | |
| tree | 920340b4b019a2dff9c7eeaeab01314af386b547 /src | |
| parent | b7680a66385dde34c8e8dbdeafc22156425cb38c (diff) | |
| download | luarocks-9404d59d48a511983ed30a6d0f605041a74ff332.tar.gz luarocks-9404d59d48a511983ed30a6d0f605041a74ff332.tar.bz2 luarocks-9404d59d48a511983ed30a6d0f605041a74ff332.zip | |
Let LuaRocks find LUA_LIBDIR and LUA_INCDIR by itself
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/cmd.lua | 24 | ||||
| -rw-r--r-- | src/luarocks/cmd/config.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/core/cfg.lua | 10 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 43 |
5 files changed, 44 insertions, 45 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index a609615e..3c7ff84e 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -119,11 +119,9 @@ local function process_dependencies(rockspec, opts) | |||
| 119 | end | 119 | end |
| 120 | end | 120 | end |
| 121 | 121 | ||
| 122 | if cfg.link_lua_explicitly then | 122 | local ok, err, errcode = deps.check_lua(rockspec.variables) |
| 123 | local ok, err, errcode = deps.check_lua_library(rockspec) | 123 | if not ok then |
| 124 | if not ok then | 124 | return nil, err, errcode |
| 125 | return nil, err, errcode | ||
| 126 | end | ||
| 127 | end | 125 | end |
| 128 | 126 | ||
| 129 | if opts.deps_mode == "none" then | 127 | if opts.deps_mode == "none" then |
| @@ -138,7 +136,7 @@ local function process_dependencies(rockspec, opts) | |||
| 138 | end | 136 | end |
| 139 | end | 137 | end |
| 140 | end | 138 | end |
| 141 | ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode) | 139 | local ok, err, errcode = deps.fulfill_dependencies(rockspec, "dependencies", opts.deps_mode) |
| 142 | if err then | 140 | if err then |
| 143 | return nil, err, errcode | 141 | return nil, err, errcode |
| 144 | end | 142 | end |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index d4ee5bc0..9639fd7d 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -108,28 +108,6 @@ do | |||
| 108 | end | 108 | end |
| 109 | end | 109 | end |
| 110 | 110 | ||
| 111 | local function find_lua_incdir(prefix, luaver, luajitver) | ||
| 112 | luajitver = luajitver and luajitver:gsub("%-.*", "") | ||
| 113 | local incdirs = { | ||
| 114 | prefix .. "/include/lua/" .. luaver, | ||
| 115 | prefix .. "/include/lua" .. luaver, | ||
| 116 | prefix .. "/include", | ||
| 117 | prefix, | ||
| 118 | luajitver and prefix .. "/include/luajit-" .. luajitver, | ||
| 119 | } | ||
| 120 | |||
| 121 | for _, d in ipairs(incdirs) do | ||
| 122 | local lua_h = dir.path(d, "lua.h") | ||
| 123 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
| 124 | if exists(lua_h) then | ||
| 125 | return d | ||
| 126 | end | ||
| 127 | end | ||
| 128 | |||
| 129 | -- fallback to a default, as it is not necessarily needed. | ||
| 130 | return incdirs[1] | ||
| 131 | end | ||
| 132 | |||
| 133 | function cmd.find_lua(prefix, luaver) | 111 | function cmd.find_lua(prefix, luaver) |
| 134 | local lua_interpreter, bindir, luajitver | 112 | local lua_interpreter, bindir, luajitver |
| 135 | lua_interpreter, bindir, luaver, luajitver = find_lua_bindir(prefix, luaver) | 113 | lua_interpreter, bindir, luaver, luajitver = find_lua_bindir(prefix, luaver) |
| @@ -143,8 +121,6 @@ do | |||
| 143 | lua_interpreter = lua_interpreter, | 121 | lua_interpreter = lua_interpreter, |
| 144 | lua_dir = prefix, | 122 | lua_dir = prefix, |
| 145 | lua_bindir = bindir, | 123 | lua_bindir = bindir, |
| 146 | lua_incdir = find_lua_incdir(prefix, luaver, luajitver), | ||
| 147 | lua_libdir = prefix .. "/lib", | ||
| 148 | } | 124 | } |
| 149 | end | 125 | end |
| 150 | end | 126 | end |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index cd446f44..794cc989 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
| @@ -4,6 +4,7 @@ local config_cmd = {} | |||
| 4 | 4 | ||
| 5 | local cfg = require("luarocks.core.cfg") | 5 | local cfg = require("luarocks.core.cfg") |
| 6 | local util = require("luarocks.util") | 6 | local util = require("luarocks.util") |
| 7 | local deps = require("luarocks.deps") | ||
| 7 | local dir = require("luarocks.dir") | 8 | local dir = require("luarocks.dir") |
| 8 | local fun = require("luarocks.fun") | 9 | local fun = require("luarocks.fun") |
| 9 | 10 | ||
| @@ -119,6 +120,7 @@ end | |||
| 119 | --- Driver function for "config" command. | 120 | --- Driver function for "config" command. |
| 120 | -- @return boolean: True if succeeded, nil on errors. | 121 | -- @return boolean: True if succeeded, nil on errors. |
| 121 | function config_cmd.command(flags) | 122 | function config_cmd.command(flags) |
| 123 | deps.check_lua(cfg.variables) | ||
| 122 | if flags["lua-incdir"] then | 124 | if flags["lua-incdir"] then |
| 123 | print(cfg.variables.LUA_INCDIR) | 125 | print(cfg.variables.LUA_INCDIR) |
| 124 | return true | 126 | return true |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index df10db2b..ee9af258 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -260,11 +260,6 @@ local function make_defaults(lua_version, target_cpu, platforms, home) | |||
| 260 | defaults.variables.CFLAGS = "/nologo /MD /O2" | 260 | defaults.variables.CFLAGS = "/nologo /MD /O2" |
| 261 | defaults.variables.LIBFLAG = "/nologo /dll" | 261 | defaults.variables.LIBFLAG = "/nologo /dll" |
| 262 | 262 | ||
| 263 | defaults.variables.LUA_DIR = "c:/lua" | ||
| 264 | defaults.variables.LUA_BINDIR = "c:/lua/bin" | ||
| 265 | defaults.variables.LUA_LIBDIR = "c:/lua/lib" | ||
| 266 | defaults.variables.LUA_INCDIR = "c:/lua/include" | ||
| 267 | |||
| 268 | defaults.external_deps_patterns = { | 263 | defaults.external_deps_patterns = { |
| 269 | bin = { "?.exe", "?.bat" }, | 264 | bin = { "?.exe", "?.bat" }, |
| 270 | lib = { "?.lib", "?.dll", "lib?.dll" }, | 265 | lib = { "?.lib", "?.dll", "lib?.dll" }, |
| @@ -333,11 +328,6 @@ local function make_defaults(lua_version, target_cpu, platforms, home) | |||
| 333 | defaults.gcc_rpath = true | 328 | defaults.gcc_rpath = true |
| 334 | defaults.variables.LIBFLAG = "-shared" | 329 | defaults.variables.LIBFLAG = "-shared" |
| 335 | 330 | ||
| 336 | defaults.variables.LUA_DIR = "/usr/local" | ||
| 337 | defaults.variables.LUA_BINDIR = "/usr/local/bin" | ||
| 338 | defaults.variables.LUA_LIBDIR = "/usr/local/lib" | ||
| 339 | defaults.variables.LUA_INCDIR = "/usr/local/include" | ||
| 340 | |||
| 341 | defaults.external_deps_patterns = { | 331 | defaults.external_deps_patterns = { |
| 342 | bin = { "?" }, | 332 | bin = { "?" }, |
| 343 | lib = { "lib?.a", "lib?.so", "lib?.so.*" }, | 333 | lib = { "lib?.a", "lib?.so", "lib?.so.*" }, |
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 |
