diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/cmd.lua | 43 | ||||
| -rw-r--r-- | src/luarocks/cmd/config.lua | 4 | ||||
| -rw-r--r-- | src/luarocks/core/cfg.lua | 2 | ||||
| -rw-r--r-- | src/luarocks/deps.lua | 28 |
4 files changed, 65 insertions, 12 deletions
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index be863cfa..37266b40 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
| @@ -266,7 +266,10 @@ do | |||
| 266 | if args.lua_dir then | 266 | if args.lua_dir then |
| 267 | local detected, err = util.find_lua(args.lua_dir, lua_version) | 267 | local detected, err = util.find_lua(args.lua_dir, lua_version) |
| 268 | if not detected then | 268 | if not detected then |
| 269 | die(err) | 269 | local suggestion = (not args.lua_version) |
| 270 | and "\nYou may want to specify a different Lua version with --lua-version\n" | ||
| 271 | or "" | ||
| 272 | die(err .. suggestion) | ||
| 270 | end | 273 | end |
| 271 | return detected | 274 | return detected |
| 272 | end | 275 | end |
| @@ -324,11 +327,45 @@ local function get_status(status) | |||
| 324 | return status and "ok" or "not found" | 327 | return status and "ok" or "not found" |
| 325 | end | 328 | end |
| 326 | 329 | ||
| 330 | local function use_to_fix_location(key) | ||
| 331 | local buf = " ****************************************\n" | ||
| 332 | buf = buf .. " Use the command\n\n" | ||
| 333 | buf = buf .. " luarocks config " .. key .. " <dir>\n\n" | ||
| 334 | buf = buf .. " to fix the location\n" | ||
| 335 | buf = buf .. " ****************************************\n" | ||
| 336 | return buf | ||
| 337 | end | ||
| 338 | |||
| 327 | local function get_config_text(cfg) | 339 | local function get_config_text(cfg) |
| 328 | local buf = "Configuration:\n Lua version: "..cfg.lua_version.."\n" | 340 | local deps = require("luarocks.deps") |
| 341 | |||
| 342 | local libdir_ok = deps.check_lua_libdir(cfg.variables) | ||
| 343 | local incdir_ok = deps.check_lua_incdir(cfg.variables) | ||
| 344 | local bindir_ok = fs.exists(cfg.variables.LUA_BINDIR) | ||
| 345 | local luadir_ok = fs.exists(cfg.variables.LUA_DIR) | ||
| 346 | local lua_ok = fs.exists(cfg.variables.LUA) | ||
| 347 | |||
| 348 | local buf = "Configuration:\n" | ||
| 349 | buf = buf.." Lua:\n" | ||
| 350 | buf = buf.." Version : "..cfg.lua_version.."\n" | ||
| 329 | if cfg.luajit_version then | 351 | if cfg.luajit_version then |
| 330 | buf = buf.." LuaJIT version: "..cfg.luajit_version.."\n" | 352 | buf = buf.." LuaJIT : "..cfg.luajit_version.."\n" |
| 331 | end | 353 | end |
| 354 | buf = buf.." Interpreter: "..(cfg.variables.LUA or "").." ("..get_status(lua_ok)..")\n" | ||
| 355 | buf = buf.." LUA_DIR : "..(cfg.variables.LUA_DIR or "").." ("..get_status(luadir_ok)..")\n" | ||
| 356 | if not lua_ok then | ||
| 357 | buf = buf .. use_to_fix_location("lua_dir") | ||
| 358 | end | ||
| 359 | buf = buf.." LUA_BINDIR : "..(cfg.variables.LUA_BINDIR or "").." ("..get_status(bindir_ok)..")\n" | ||
| 360 | buf = buf.." LUA_INCDIR : "..(cfg.variables.LUA_INCDIR or "").." ("..get_status(incdir_ok)..")\n" | ||
| 361 | if lua_ok and not incdir_ok then | ||
| 362 | buf = buf .. use_to_fix_location("variables.LUA_INCDIR") | ||
| 363 | end | ||
| 364 | buf = buf.." LUA_LIBDIR : "..(cfg.variables.LUA_LIBDIR or "").." ("..get_status(libdir_ok)..")\n" | ||
| 365 | if lua_ok and not libdir_ok then | ||
| 366 | buf = buf .. use_to_fix_location("variables.LUA_LIBDIR") | ||
| 367 | end | ||
| 368 | |||
| 332 | buf = buf.."\n Configuration files:\n" | 369 | buf = buf.."\n Configuration files:\n" |
| 333 | local conf = cfg.config_files | 370 | local conf = cfg.config_files |
| 334 | buf = buf.." System : "..fs.absolute_name(conf.system.file).." ("..get_status(conf.system.found)..")\n" | 371 | buf = buf.." System : "..fs.absolute_name(conf.system.file).." ("..get_status(conf.system.found)..")\n" |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index bdabe960..5e92634a 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
| @@ -297,6 +297,10 @@ function config_cmd.command(args) | |||
| 297 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, | 297 | ["variables.LUA_LIBDIR"] = cfg.variables.LUA_LIBDIR, |
| 298 | ["lua_interpreter"] = cfg.lua_interpreter, | 298 | ["lua_interpreter"] = cfg.lua_interpreter, |
| 299 | } | 299 | } |
| 300 | if args.lua_version then | ||
| 301 | local prefix = dir.dir_name(cfg.config_files[scope].file) | ||
| 302 | persist.save_default_lua_version(prefix, args.lua_version) | ||
| 303 | end | ||
| 300 | return write_entries(keys, scope, args.unset) | 304 | return write_entries(keys, scope, args.unset) |
| 301 | end | 305 | end |
| 302 | 306 | ||
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 0c79fc63..3917e2af 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -690,6 +690,8 @@ function cfg.init(detected, warning) | |||
| 690 | if detected.given_lua_dir then | 690 | if detected.given_lua_dir then |
| 691 | cfg.variables.LUA_DIR = detected.given_lua_dir | 691 | cfg.variables.LUA_DIR = detected.given_lua_dir |
| 692 | cfg.variables.LUA_BINDIR = detected.lua_bindir | 692 | cfg.variables.LUA_BINDIR = detected.lua_bindir |
| 693 | cfg.variables.LUA_LIBDIR = nil | ||
| 694 | cfg.variables.LUA_INCDIR = nil | ||
| 693 | cfg.lua_interpreter = detected.lua_interpreter | 695 | cfg.lua_interpreter = detected.lua_interpreter |
| 694 | end | 696 | end |
| 695 | 697 | ||
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 0eb80193..d935a5c8 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
| @@ -649,6 +649,16 @@ function deps.scan_deps(results, manifest, name, version, deps_mode) | |||
| 649 | end | 649 | end |
| 650 | end | 650 | end |
| 651 | 651 | ||
| 652 | local function lua_h_exists(d) | ||
| 653 | local lua_h = dir.path(d, "lua.h") | ||
| 654 | local fd = io.open(lua_h) | ||
| 655 | if fd then | ||
| 656 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
| 657 | fd:close() | ||
| 658 | return d | ||
| 659 | end | ||
| 660 | end | ||
| 661 | |||
| 652 | local function find_lua_incdir(prefix, luaver, luajitver) | 662 | local function find_lua_incdir(prefix, luaver, luajitver) |
| 653 | luajitver = luajitver and luajitver:gsub("%-.*", "") | 663 | luajitver = luajitver and luajitver:gsub("%-.*", "") |
| 654 | local shortv = luaver:gsub("%.", "") | 664 | local shortv = luaver:gsub("%.", "") |
| @@ -662,11 +672,7 @@ local function find_lua_incdir(prefix, luaver, luajitver) | |||
| 662 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), | 672 | luajitver and prefix .. "/include/luajit-" .. luajitver:match("^(%d+%.%d+)"), |
| 663 | } | 673 | } |
| 664 | for _, d in ipairs(incdirs) do | 674 | for _, d in ipairs(incdirs) do |
| 665 | local lua_h = dir.path(d, "lua.h") | 675 | if lua_h_exists(d) then |
| 666 | local fd = io.open(lua_h) | ||
| 667 | if fd then | ||
| 668 | -- TODO check that LUA_VERSION_MAJOR and LUA_VERSION_MINOR match luaver | ||
| 669 | fd:close() | ||
| 670 | return d | 676 | return d |
| 671 | end | 677 | end |
| 672 | end | 678 | end |
| @@ -678,14 +684,18 @@ end | |||
| 678 | function deps.check_lua_incdir(vars) | 684 | function deps.check_lua_incdir(vars) |
| 679 | local ljv = util.get_luajit_version() | 685 | local ljv = util.get_luajit_version() |
| 680 | 686 | ||
| 681 | if (not vars.LUA_INCDIR) and vars.LUA_DIR then | 687 | if vars.LUA_INCDIR then |
| 688 | return lua_h_exists(vars.LUA_INCDIR) | ||
| 689 | end | ||
| 690 | |||
| 691 | if vars.LUA_DIR then | ||
| 682 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) | 692 | vars.LUA_INCDIR = find_lua_incdir(vars.LUA_DIR, cfg.lua_version, ljv) |
| 683 | if vars.LUA_INCDIR == nil then | 693 | if vars.LUA_INCDIR then |
| 684 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency" | 694 | return true |
| 685 | end | 695 | end |
| 686 | end | 696 | end |
| 687 | 697 | ||
| 688 | return true | 698 | return nil, "Failed finding Lua header files. You may need to install them or configure LUA_INCDIR.", "dependency" |
| 689 | end | 699 | end |
| 690 | 700 | ||
| 691 | function deps.check_lua_libdir(vars) | 701 | function deps.check_lua_libdir(vars) |
