diff options
author | Peter Melnichenko <mpeterval@gmail.com> | 2016-08-21 18:26:53 +0300 |
---|---|---|
committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-08-21 18:29:58 +0300 |
commit | e3c6073f5912d3fd9d098783483a63bf39610fb3 (patch) | |
tree | 92b389df4528264ee3cc670c9a50fc6457d18b0a | |
parent | 5cdc22fb3c3a85160cd7c2d49ba10ab113e4a784 (diff) | |
download | luarocks-e3c6073f5912d3fd9d098783483a63bf39610fb3.tar.gz luarocks-e3c6073f5912d3fd9d098783483a63bf39610fb3.tar.bz2 luarocks-e3c6073f5912d3fd9d098783483a63bf39610fb3.zip |
Refactor look_for_interpreter in install.bat
Replace repeating code with loops. The only side effect should
be that LUA_BINDIR now does not have trailing backslash when
it's inferred.
-rw-r--r-- | install.bat | 66 |
1 files changed, 21 insertions, 45 deletions
diff --git a/install.bat b/install.bat index cc4a5257..1bce4c53 100644 --- a/install.bat +++ b/install.bat | |||
@@ -287,56 +287,32 @@ end | |||
287 | -- *********************************************************** | 287 | -- *********************************************************** |
288 | -- Detect Lua | 288 | -- Detect Lua |
289 | -- *********************************************************** | 289 | -- *********************************************************** |
290 | local function look_for_interpreter (directory) | 290 | local function look_for_interpreter(directory) |
291 | local names = {S"lua$LUA_VERSION.exe", S"lua$LUA_SHORTV.exe", "lua.exe", "luajit.exe"} | ||
292 | local directories | ||
291 | if vars.LUA_BINDIR then | 293 | if vars.LUA_BINDIR then |
292 | -- if LUA_BINDIR is specified, it must be there, otherwise we fail | 294 | -- If LUA_BINDIR is specified, look only in that directory. |
293 | if exists( S"$LUA_BINDIR\\lua$LUA_VERSION.exe" ) then | 295 | directories = {vars.LUA_BINDIR} |
294 | vars.LUA_INTERPRETER = S"lua$LUA_VERSION.exe" | 296 | else |
295 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | 297 | -- Try candidate directory and its `bin` subdirectory. |
296 | return true | 298 | directories = {directory, directory .. "\\bin"} |
297 | elseif exists( S"$LUA_BINDIR\\lua$LUA_SHORTV.exe" ) then | ||
298 | vars.LUA_INTERPRETER = S"lua$LUA_SHORTV.exe" | ||
299 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
300 | return true | ||
301 | elseif exists(S"$LUA_BINDIR\\lua.exe") then | ||
302 | vars.LUA_INTERPRETER = "lua.exe" | ||
303 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
304 | return true | ||
305 | elseif exists(S"$LUA_BINDIR\\luajit.exe") then | ||
306 | vars.LUA_INTERPRETER = "luajit.exe" | ||
307 | print(S" Found $LUA_BINDIR\\$LUA_INTERPRETER") | ||
308 | return true | ||
309 | end | ||
310 | die(S"Lua executable lua.exe, luajit.exe, lua$LUA_SHORTV.exe or lua$LUA_VERSION.exe not found in $LUA_BINDIR") | ||
311 | end | 299 | end |
312 | 300 | ||
313 | for _, e in ipairs{ [[\]], [[\bin\]] } do | 301 | for _, dir in ipairs(directories) do |
314 | if exists(directory..e.."\\lua"..vars.LUA_VERSION..".exe") then | 302 | for _, name in ipairs(names) do |
315 | vars.LUA_INTERPRETER = S"lua$LUA_VERSION.exe" | 303 | local full_name = dir .. "\\" .. name |
316 | vars.LUA_BINDIR = directory .. e | 304 | if exists(full_name) then |
317 | print(" Found ."..e..vars.LUA_INTERPRETER) | 305 | vars.LUA_INTERPRETER = name |
318 | return true | 306 | vars.LUA_BINDIR = dir |
319 | 307 | print(" Found " .. full_name) | |
320 | elseif exists(directory..e.."\\lua"..vars.LUA_SHORTV..".exe") then | 308 | return true |
321 | vars.LUA_INTERPRETER = S"lua$LUA_SHORTV.exe" | 309 | end |
322 | vars.LUA_BINDIR = directory .. e | ||
323 | print(" Found ."..e..vars.LUA_INTERPRETER) | ||
324 | return true | ||
325 | |||
326 | elseif exists(directory..e.."\\lua.exe") then | ||
327 | vars.LUA_INTERPRETER = "lua.exe" | ||
328 | vars.LUA_BINDIR = directory..e | ||
329 | print(" Found ."..e..vars.LUA_INTERPRETER) | ||
330 | return true | ||
331 | |||
332 | elseif exists(directory..e.."\\luajit.exe") then | ||
333 | vars.LUA_INTERPRETER = "luajit.exe" | ||
334 | vars.LUA_BINDIR = directory..e | ||
335 | print(" Found ."..e..vars.LUA_INTERPRETER) | ||
336 | return true | ||
337 | end | 310 | end |
338 | end | 311 | end |
339 | --print(" No Lua interpreter found") | 312 | |
313 | if vars.LUA_BINDIR then | ||
314 | die(S"Lua executable lua.exe, luajit.exe, lua$LUA_SHORTV.exe or lua$LUA_VERSION.exe not found in $LUA_BINDIR") | ||
315 | end | ||
340 | return false | 316 | return false |
341 | end | 317 | end |
342 | 318 | ||