diff options
| author | Peter Melnichenko <mpeterval@gmail.com> | 2016-08-22 20:03:15 +0300 |
|---|---|---|
| committer | Peter Melnichenko <mpeterval@gmail.com> | 2016-08-23 08:52:16 +0300 |
| commit | b603e64b7e41e718157e98d1bcfa8673351b87f9 (patch) | |
| tree | aa762985d750e3e1ef9f1317cbc3f69f0e660542 | |
| parent | a57e1f97870bb25aec22b886b731689e61884ed5 (diff) | |
| download | luarocks-b603e64b7e41e718157e98d1bcfa8673351b87f9.tar.gz luarocks-b603e64b7e41e718157e98d1bcfa8673351b87f9.tar.bz2 luarocks-b603e64b7e41e718157e98d1bcfa8673351b87f9.zip | |
install.bat: get rid of vars.LUA_LIB_NAMES
Generate list of names when needed instead of pregenerating
a list of 5.1 and then changing it when LUA_VERSION is different.
| -rw-r--r-- | install.bat | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/install.bat b/install.bat index 7ed59525..bdde4413 100644 --- a/install.bat +++ b/install.bat | |||
| @@ -24,10 +24,6 @@ vars.LUA_LIBDIR = nil | |||
| 24 | vars.LUA_LIBNAME = nil | 24 | vars.LUA_LIBNAME = nil |
| 25 | vars.LUA_VERSION = "5.1" | 25 | vars.LUA_VERSION = "5.1" |
| 26 | vars.LUA_SHORTV = nil -- "51" | 26 | vars.LUA_SHORTV = nil -- "51" |
| 27 | -- MinGW does not generate .lib, nor needs it to link, but MSVC does | ||
| 28 | -- so .lib must be listed first to ensure they are found first if present. | ||
| 29 | -- To prevent MSVC trying to link to a .dll, which won't work. | ||
| 30 | vars.LUA_LIB_NAMES = "lua5.1.lib lua51.lib lua5.1.dll lua51.dll liblua.dll.a" | ||
| 31 | vars.LUA_RUNTIME = nil | 27 | vars.LUA_RUNTIME = nil |
| 32 | vars.UNAME_M = nil | 28 | vars.UNAME_M = nil |
| 33 | vars.COMPILER_ENV_CMD = nil | 29 | vars.COMPILER_ENV_CMD = nil |
| @@ -273,14 +269,8 @@ local function check_flags() | |||
| 273 | die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) | 269 | die("Bundled Lua version is 5.1, cannot install "..vars.LUA_VERSION) |
| 274 | end | 270 | end |
| 275 | end | 271 | end |
| 276 | if vars.LUA_VERSION ~= "5.1" then | 272 | if not vars.LUA_VERSION:match("^5%.[123]$") then |
| 277 | if vars.LUA_VERSION == "5.2" then | 273 | die("Bad argument: /LV must either be 5.1, 5.2, or 5.3") |
| 278 | vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%12") | ||
| 279 | elseif vars.LUA_VERSION == "5.3" then | ||
| 280 | vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)1", "5%13") | ||
| 281 | else | ||
| 282 | die("Bad argument: /LV must either be 5.1, 5.2, or 5.3") | ||
| 283 | end | ||
| 284 | end | 274 | end |
| 285 | if USE_MSVC_MANUAL and USE_MINGW then | 275 | if USE_MSVC_MANUAL and USE_MINGW then |
| 286 | die("Cannot combine option /MSVC and /MW") | 276 | die("Cannot combine option /MSVC and /MW") |
| @@ -339,7 +329,6 @@ local function look_for_interpreter(directory) | |||
| 339 | else | 329 | else |
| 340 | vars.LUA_VERSION = version | 330 | vars.LUA_VERSION = version |
| 341 | vars.LUA_SHORTV = version:gsub("%.", "") | 331 | vars.LUA_SHORTV = version:gsub("%.", "") |
| 342 | vars.LUA_LIB_NAMES = vars.LUA_LIB_NAMES:gsub("5([%.]?)[123]", "5%1" .. version:sub(-1)) | ||
| 343 | end | 332 | end |
| 344 | end | 333 | end |
| 345 | 334 | ||
| @@ -358,6 +347,10 @@ local function look_for_interpreter(directory) | |||
| 358 | end | 347 | end |
| 359 | 348 | ||
| 360 | local function look_for_link_libraries(directory) | 349 | local function look_for_link_libraries(directory) |
| 350 | -- MinGW does not generate .lib, nor needs it to link, but MSVC does, | ||
| 351 | -- so .lib must be listed first to ensure they are found first if present, | ||
| 352 | -- to prevent MSVC trying to link to a .dll, which won't work. | ||
| 353 | local names = {S"lua$LUA_VERSION.lib", S"lua$LUA_SHORTV.lib", S"lua$LUA_VERSION.dll", S"lua$LUA_SHORTV.dll", "liblua.dll.a"} | ||
| 361 | local directories | 354 | local directories |
| 362 | if vars.LUA_LIBDIR then | 355 | if vars.LUA_LIBDIR then |
| 363 | directories = {vars.LUA_LIBDIR} | 356 | directories = {vars.LUA_LIBDIR} |
| @@ -366,7 +359,7 @@ local function look_for_link_libraries(directory) | |||
| 366 | end | 359 | end |
| 367 | 360 | ||
| 368 | for _, dir in ipairs(directories) do | 361 | for _, dir in ipairs(directories) do |
| 369 | for name in vars.LUA_LIB_NAMES:gmatch("[^%s]+") do | 362 | for _, name in ipairs(names) do |
| 370 | local full_name = dir .. "\\" .. name | 363 | local full_name = dir .. "\\" .. name |
| 371 | print(" checking for " .. full_name) | 364 | print(" checking for " .. full_name) |
| 372 | if exists(full_name) then | 365 | if exists(full_name) then |
| @@ -379,7 +372,7 @@ local function look_for_link_libraries(directory) | |||
| 379 | end | 372 | end |
| 380 | 373 | ||
| 381 | if vars.LUA_LIBDIR then | 374 | if vars.LUA_LIBDIR then |
| 382 | die(S"link library (one of; $LUA_LIB_NAMES) not found in $LUA_LIBDIR") | 375 | die(("Link library (one of %s) not found in %s"):format(table.concat(names, ", "), vars.LUA_LIBDIR)) |
| 383 | end | 376 | end |
| 384 | return false | 377 | return false |
| 385 | end | 378 | end |
