diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/cfg.lua | 28 | ||||
-rw-r--r-- | src/luarocks/path.lua | 19 |
2 files changed, 36 insertions, 11 deletions
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 259293c3..967d756c 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
@@ -443,15 +443,25 @@ local cfg_mt = { | |||
443 | } | 443 | } |
444 | setmetatable(_M, cfg_mt) | 444 | setmetatable(_M, cfg_mt) |
445 | 445 | ||
446 | for _,tree in ipairs(rocks_trees) do | 446 | function package_paths() |
447 | if type(tree) == "string" then | 447 | local new_path, new_cpath = {}, {} |
448 | package.path = tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua;"..package.path | 448 | for _,tree in ipairs(rocks_trees) do |
449 | package.cpath = tree..lib_modules_path.."/?."..lib_extension..";"..package.cpath | 449 | if type(tree) == "string" then |
450 | else | 450 | table.insert(new_path, 1, tree..lua_modules_path.."/?.lua;"..tree..lua_modules_path.."/?/init.lua") |
451 | package.path = (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;".. | 451 | table.insert(new_cpath, 1, tree..lib_modules_path.."/?."..lib_extension) |
452 | (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua;"..package.path | 452 | else |
453 | package.cpath = (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension..";"..package.cpath | 453 | table.insert(new_path, 1, (tree.lua_dir or tree.root..lua_modules_path).."/?.lua;".. |
454 | end | 454 | (tree.lua_dir or tree.root..lua_modules_path).."/?/init.lua") |
455 | table.insert(new_cpath, 1, (tree.lib_dir or tree.root..lib_modules_path).."/?."..lib_extension) | ||
456 | end | ||
457 | end | ||
458 | return table.concat(new_path, ";"), table.concat(new_cpath, ";") | ||
459 | end | ||
460 | |||
461 | do | ||
462 | local new_path, new_cpath = package_paths() | ||
463 | package.path = new_path..";"..package.path | ||
464 | package.cpath = new_cpath..";"..package.cpath | ||
455 | end | 465 | end |
456 | 466 | ||
457 | function which_config() | 467 | function which_config() |
diff --git a/src/luarocks/path.lua b/src/luarocks/path.lua index cfe06118..7af81c07 100644 --- a/src/luarocks/path.lua +++ b/src/luarocks/path.lua | |||
@@ -389,13 +389,28 @@ end | |||
389 | function run(...) | 389 | function run(...) |
390 | local flags = util.parse_flags(...) | 390 | local flags = util.parse_flags(...) |
391 | local deps_mode = deps.get_deps_mode(flags) | 391 | local deps_mode = deps.get_deps_mode(flags) |
392 | |||
393 | local lr_path, lr_cpath = cfg.package_paths() | ||
394 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) | ||
395 | |||
396 | if flags["lr-path"] then | ||
397 | util.printout(util.remove_path_dupes(lr_path, ';')) | ||
398 | return true | ||
399 | elseif flags["lr-cpath"] then | ||
400 | util.printout(util.remove_path_dupes(lr_cpath, ';')) | ||
401 | return true | ||
402 | elseif flags["lr-bin"] then | ||
403 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) | ||
404 | util.printout(util.remove_path_dupes(lr_bin, ';')) | ||
405 | return true | ||
406 | end | ||
392 | 407 | ||
393 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) | 408 | util.printout(cfg.export_lua_path:format(util.remove_path_dupes(package.path, ';'))) |
394 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) | 409 | util.printout(cfg.export_lua_cpath:format(util.remove_path_dupes(package.cpath, ';'))) |
395 | if flags["bin"] then | 410 | if flags["bin"] then |
396 | local bin_dirs = map_trees(deps_mode, deploy_bin_dir) | ||
397 | table.insert(bin_dirs, 1, os.getenv("PATH")) | 411 | table.insert(bin_dirs, 1, os.getenv("PATH")) |
398 | util.printout(cfg.export_path:format(util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator))) | 412 | local lr_bin = util.remove_path_dupes(table.concat(bin_dirs, cfg.export_path_separator), cfg.export_path_separator) |
413 | util.printout(cfg.export_path:format(lr_bin)) | ||
399 | end | 414 | end |
400 | return true | 415 | return true |
401 | end | 416 | end |