diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2019-07-26 19:11:21 -0300 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2019-07-26 23:58:19 -0300 |
commit | 1d3bb56b309ce0463249852f901147157f34adfa (patch) | |
tree | c55817e90dbc51e45b8ecb8f59581c3f00047a10 /src | |
parent | 4dd439f804844ce82c1519eede0e9201db72ba77 (diff) | |
download | luarocks-1d3bb56b309ce0463249852f901147157f34adfa.tar.gz luarocks-1d3bb56b309ce0463249852f901147157f34adfa.tar.bz2 luarocks-1d3bb56b309ce0463249852f901147157f34adfa.zip |
cfg: avoid setting LUA_LIBDIR and LUA_INCDIR too early
Diffstat (limited to 'src')
-rw-r--r-- | src/luarocks/build.lua | 9 | ||||
-rw-r--r-- | src/luarocks/cmd.lua | 15 | ||||
-rw-r--r-- | src/luarocks/cmd/config.lua | 3 | ||||
-rw-r--r-- | src/luarocks/cmd/init.lua | 2 | ||||
-rw-r--r-- | src/luarocks/core/cfg.lua | 22 | ||||
-rw-r--r-- | src/luarocks/deps.lua | 48 |
6 files changed, 57 insertions, 42 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index c2dd4439..2ac7dd3a 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -109,11 +109,18 @@ local function process_dependencies(rockspec, opts) | |||
109 | end | 109 | end |
110 | end | 110 | end |
111 | 111 | ||
112 | local ok, err, errcode = deps.check_lua(rockspec.variables) | 112 | local ok, err, errcode = deps.check_lua_incdir(rockspec.variables) |
113 | if not ok then | 113 | if not ok then |
114 | return nil, err, errcode | 114 | return nil, err, errcode |
115 | end | 115 | end |
116 | 116 | ||
117 | if cfg.link_lua_explicitly then | ||
118 | local ok, err, errcode = deps.check_lua_libdir(rockspec.variables) | ||
119 | if not ok then | ||
120 | return nil, err, errcode | ||
121 | end | ||
122 | end | ||
123 | |||
117 | if opts.deps_mode == "none" then | 124 | if opts.deps_mode == "none" then |
118 | util.warning("skipping dependency checks.") | 125 | util.warning("skipping dependency checks.") |
119 | return true | 126 | return true |
diff --git a/src/luarocks/cmd.lua b/src/luarocks/cmd.lua index 4397ffbd..1ead6c4b 100644 --- a/src/luarocks/cmd.lua +++ b/src/luarocks/cmd.lua | |||
@@ -178,12 +178,12 @@ do | |||
178 | do | 178 | do |
179 | local function find_project_dir(project_tree) | 179 | local function find_project_dir(project_tree) |
180 | if project_tree then | 180 | if project_tree then |
181 | return project_tree:gsub("[/\\][^/\\]+$", "") | 181 | return project_tree:gsub("[/\\][^/\\]+$", ""), true |
182 | else | 182 | else |
183 | local try = "." | 183 | local try = "." |
184 | for _ = 1, 10 do -- FIXME detect when root dir was hit instead | 184 | for _ = 1, 10 do -- FIXME detect when root dir was hit instead |
185 | if util.exists(try .. "/.luarocks") and util.exists(try .. "/lua_modules") then | 185 | if util.exists(try .. "/.luarocks") and util.exists(try .. "/lua_modules") then |
186 | return try | 186 | return try, false |
187 | elseif util.exists(try .. "/.luarocks-no-project") then | 187 | elseif util.exists(try .. "/.luarocks-no-project") then |
188 | break | 188 | break |
189 | end | 189 | end |
@@ -265,8 +265,17 @@ do | |||
265 | end | 265 | end |
266 | 266 | ||
267 | detect_config_via_flags = function(flags) | 267 | detect_config_via_flags = function(flags) |
268 | local project_dir = find_project_dir(flags["project-tree"]) | 268 | local project_dir, given = find_project_dir(flags["project-tree"]) |
269 | local detected = detect_lua_via_flags(flags, project_dir) | 269 | local detected = detect_lua_via_flags(flags, project_dir) |
270 | if flags["lua-version"] then | ||
271 | detected.given_lua_version = flags["lua-version"] | ||
272 | end | ||
273 | if flags["lua-dir"] then | ||
274 | detected.given_lua_dir = flags["lua-dir"] | ||
275 | end | ||
276 | if given then | ||
277 | detected.given_project_dir = project_dir | ||
278 | end | ||
270 | detected.project_dir = project_dir | 279 | detected.project_dir = project_dir |
271 | return detected | 280 | return detected |
272 | end | 281 | end |
diff --git a/src/luarocks/cmd/config.lua b/src/luarocks/cmd/config.lua index e9b2fef4..b3cb5e07 100644 --- a/src/luarocks/cmd/config.lua +++ b/src/luarocks/cmd/config.lua | |||
@@ -234,7 +234,8 @@ end | |||
234 | --- Driver function for "config" command. | 234 | --- Driver function for "config" command. |
235 | -- @return boolean: True if succeeded, nil on errors. | 235 | -- @return boolean: True if succeeded, nil on errors. |
236 | function config_cmd.command(flags, var, val) | 236 | function config_cmd.command(flags, var, val) |
237 | deps.check_lua(cfg.variables) | 237 | deps.check_lua_incdir(cfg.variables) |
238 | deps.check_lua_libdir(cfg.variables) | ||
238 | 239 | ||
239 | -- deprecated flags | 240 | -- deprecated flags |
240 | if flags["lua-incdir"] then | 241 | if flags["lua-incdir"] then |
diff --git a/src/luarocks/cmd/init.lua b/src/luarocks/cmd/init.lua index 88de283b..60aa4f82 100644 --- a/src/luarocks/cmd/init.lua +++ b/src/luarocks/cmd/init.lua | |||
@@ -70,7 +70,7 @@ function init.command(flags, name, version) | |||
70 | if not cfg.lua_found then | 70 | if not cfg.lua_found then |
71 | return nil, "Lua installation is not found." | 71 | return nil, "Lua installation is not found." |
72 | end | 72 | end |
73 | local ok, err = deps.check_lua(cfg.variables) | 73 | local ok, err = deps.check_lua_incdir(cfg.variables) |
74 | if not ok then | 74 | if not ok then |
75 | return nil, err | 75 | return nil, err |
76 | end | 76 | end |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index 8edd5f63..008ae7dc 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
@@ -514,8 +514,6 @@ local cfg = {} | |||
514 | -- environment. All fields below are optional: | 514 | -- environment. All fields below are optional: |
515 | -- * lua_version (in x.y format, e.g. "5.3") | 515 | -- * lua_version (in x.y format, e.g. "5.3") |
516 | -- * lua_bindir (e.g. "/usr/local/bin") | 516 | -- * lua_bindir (e.g. "/usr/local/bin") |
517 | -- * lua_incdir (e.g. "/usr/local/include/lua5.3/") | ||
518 | -- * lua_libdir(e.g. "/usr/local/lib") | ||
519 | -- * lua_dir (e.g. "/usr/local") | 517 | -- * lua_dir (e.g. "/usr/local") |
520 | -- * lua_interpreter (e.g. "lua-5.3") | 518 | -- * lua_interpreter (e.g. "lua-5.3") |
521 | -- * project_dir (a string with the path of the project directory | 519 | -- * project_dir (a string with the path of the project directory |
@@ -533,8 +531,6 @@ function cfg.init(detected, warning) | |||
533 | local lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) | 531 | local lua_version = detected.lua_version or hardcoded.LUA_VERSION or _VERSION:sub(5) |
534 | local lua_interpreter = detected.lua_interpreter or hardcoded.LUA_INTERPRETER or (arg and arg[-1] and arg[-1]:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") | 532 | local lua_interpreter = detected.lua_interpreter or hardcoded.LUA_INTERPRETER or (arg and arg[-1] and arg[-1]:gsub(".*[\\/]", "")) or (is_windows and "lua.exe" or "lua") |
535 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR or (arg and arg[-1] and arg[-1]:gsub("[\\/][^\\/]+$", "")) | 533 | local lua_bindir = detected.lua_bindir or hardcoded.LUA_BINDIR or (arg and arg[-1] and arg[-1]:gsub("[\\/][^\\/]+$", "")) |
536 | local lua_incdir = detected.lua_incdir or hardcoded.LUA_INCDIR | ||
537 | local lua_libdir = detected.lua_libdir or hardcoded.LUA_LIBDIR | ||
538 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) | 534 | local lua_dir = detected.lua_dir or hardcoded.LUA_DIR or (lua_bindir and lua_bindir:gsub("[\\/]bin$", "")) |
539 | local project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir | 535 | local project_dir = (not hardcoded.FORCE_CONFIG) and detected.project_dir |
540 | 536 | ||
@@ -558,8 +554,8 @@ function cfg.init(detected, warning) | |||
558 | cfg.variables = { | 554 | cfg.variables = { |
559 | LUA_DIR = lua_dir, | 555 | LUA_DIR = lua_dir, |
560 | LUA_BINDIR = lua_bindir, | 556 | LUA_BINDIR = lua_bindir, |
561 | LUA_INCDIR = lua_incdir, | 557 | LUA_LIBDIR = hardcoded.LUA_LIBDIR, |
562 | LUA_LIBDIR = lua_libdir, | 558 | LUA_INCDIR = hardcoded.LUA_INCDIR, |
563 | } | 559 | } |
564 | 560 | ||
565 | cfg.init = init | 561 | cfg.init = init |
@@ -668,14 +664,14 @@ function cfg.init(detected, warning) | |||
668 | -- Let's finish up the cfg table. | 664 | -- Let's finish up the cfg table. |
669 | ---------------------------------------- | 665 | ---------------------------------------- |
670 | 666 | ||
671 | -- Settings detected or given via the CLI (i.e. --lua-dir) take precedence over config files: | 667 | -- Settings given via the CLI (i.e. --lua-dir) take precedence over config files. |
672 | cfg.project_dir = project_dir | 668 | cfg.project_dir = detected.given_project_dir or project_dir |
673 | cfg.lua_version = detected.lua_version or cfg.lua_version | 669 | cfg.lua_version = detected.given_lua_version or lua_version or cfg.lua_version |
670 | cfg.variables.LUA_DIR = detected.given_lua_dir or cfg.variables.LUA_DIR or lua_dir | ||
671 | |||
674 | cfg.lua_interpreter = detected.lua_interpreter or cfg.lua_interpreter | 672 | cfg.lua_interpreter = detected.lua_interpreter or cfg.lua_interpreter |
675 | cfg.variables.LUA_BINDIR = detected.lua_bindir or cfg.variables.LUA_BINDIR or lua_bindir | 673 | |
676 | cfg.variables.LUA_INCDIR = detected.lua_incdir or cfg.variables.LUA_INCDIR or lua_incdir | 674 | cfg.variables.LUA_BINDIR = cfg.variables.LUA_BINDIR or lua_bindir |
677 | cfg.variables.LUA_LIBDIR = detected.lua_libdir or cfg.variables.LUA_LIBDIR or lua_libdir | ||
678 | cfg.variables.LUA_DIR = detected.lua_dir or cfg.variables.LUA_DIR or lua_dir | ||
679 | 675 | ||
680 | -- Build a default list of rocks trees if not given | 676 | -- Build a default list of rocks trees if not given |
681 | if cfg.rocks_trees == nil then | 677 | if cfg.rocks_trees == nil then |
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua index 9ea14881..9ee21772 100644 --- a/src/luarocks/deps.lua +++ b/src/luarocks/deps.lua | |||
@@ -531,7 +531,7 @@ local function find_lua_incdir(prefix, luaver, luajitver) | |||
531 | return nil | 531 | return nil |
532 | end | 532 | end |
533 | 533 | ||
534 | function deps.check_lua(vars) | 534 | function deps.check_lua_incdir(vars) |
535 | local ljv = util.get_luajit_version() | 535 | local ljv = util.get_luajit_version() |
536 | 536 | ||
537 | if (not vars.LUA_INCDIR) and vars.LUA_DIR then | 537 | if (not vars.LUA_INCDIR) and vars.LUA_DIR then |
@@ -541,30 +541,32 @@ function deps.check_lua(vars) | |||
541 | end | 541 | end |
542 | end | 542 | end |
543 | 543 | ||
544 | if cfg.link_lua_explicitly then | 544 | return true |
545 | local shortv = cfg.lua_version:gsub("%.", "") | 545 | end |
546 | local libnames = { | 546 | |
547 | "lua" .. cfg.lua_version, | 547 | function deps.check_lua_libdir(vars) |
548 | "lua" .. shortv, | 548 | local ljv = util.get_luajit_version() |
549 | "lua-" .. cfg.lua_version, | 549 | |
550 | "lua-" .. shortv, | 550 | local shortv = cfg.lua_version:gsub("%.", "") |
551 | "lua", | 551 | local libnames = { |
552 | } | 552 | "lua" .. cfg.lua_version, |
553 | if ljv then | 553 | "lua" .. shortv, |
554 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) | 554 | "lua-" .. cfg.lua_version, |
555 | end | 555 | "lua-" .. shortv, |
556 | local cache = {} | 556 | "lua", |
557 | for _, libname in ipairs(libnames) do | 557 | } |
558 | local ok = check_external_dependency("LUA", { library = libname }, vars, "build", cache) | 558 | if ljv then |
559 | if ok then | 559 | table.insert(libnames, 1, "luajit-" .. cfg.lua_version) |
560 | vars.LUALIB = vars.LUA_LIBDIR_FILE | 560 | end |
561 | return true | 561 | local cache = {} |
562 | end | 562 | for _, libname in ipairs(libnames) do |
563 | local ok = check_external_dependency("LUA", { library = libname }, vars, "build", cache) | ||
564 | if ok then | ||
565 | vars.LUALIB = vars.LUA_LIBDIR_FILE | ||
566 | return true | ||
563 | end | 567 | end |
564 | return nil, "Failed finding Lua library. You may need to configure LUA_LIBDIR.", "dependency" | ||
565 | end | 568 | end |
566 | 569 | return nil, "Failed finding Lua library. You may need to configure LUA_LIBDIR.", "dependency" | |
567 | return true | ||
568 | end | 570 | end |
569 | 571 | ||
570 | local valid_deps_modes = { | 572 | local valid_deps_modes = { |