diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-12-01 14:58:41 +0100 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2015-12-01 14:58:41 +0100 |
| commit | f00f9c9ecf110b05f62d6cc2d42b2f662a935015 (patch) | |
| tree | 719d85630acd3457145e96c1eb0c59a69f3a9df7 | |
| parent | 4bf9303acaa02ce9361ac814a7b093ff6d11acba (diff) | |
| parent | c8459585c9cb0f52d3a117125b537bd98f5515ab (diff) | |
| download | luarocks-f00f9c9ecf110b05f62d6cc2d42b2f662a935015.tar.gz luarocks-f00f9c9ecf110b05f62d6cc2d42b2f662a935015.tar.bz2 luarocks-f00f9c9ecf110b05f62d6cc2d42b2f662a935015.zip | |
Merge branch 'master' of github.com:xpol/luarocks into test_xpol
| -rw-r--r-- | install.bat | 93 |
1 files changed, 92 insertions, 1 deletions
diff --git a/install.bat b/install.bat index 42b01c43..718ec8d6 100644 --- a/install.bat +++ b/install.bat | |||
| @@ -408,6 +408,95 @@ local function get_architecture() | |||
| 408 | return proc | 408 | return proc |
| 409 | end | 409 | end |
| 410 | 410 | ||
| 411 | -- get a string value from windows registry. | ||
| 412 | local function get_registry(key, value) | ||
| 413 | local keys = {key} | ||
| 414 | local key64, replaced = key:gsub("(%u+\\Software\\)", "\1Wow6432Node\\", 1) | ||
| 415 | |||
| 416 | if replaced == 1 then | ||
| 417 | keys = {key64, key} | ||
| 418 | end | ||
| 419 | |||
| 420 | for _, k in ipairs(keys) do | ||
| 421 | local h = io.popen('reg query "'..k..'" /v '..value..' 2>NUL') | ||
| 422 | local output = h:read("*a") | ||
| 423 | h:close() | ||
| 424 | |||
| 425 | local v = output:match("REG_SZ%s+([^\n]+)") | ||
| 426 | if v then | ||
| 427 | return v | ||
| 428 | end | ||
| 429 | end | ||
| 430 | return nil | ||
| 431 | end | ||
| 432 | |||
| 433 | local function get_visual_studio_directory() | ||
| 434 | assert(type(vars.LUA_RUNTIME)=="string", "requires vars.LUA_RUNTIME to be set before calling this function.") | ||
| 435 | local major, minor = vars.LUA_RUNTIME:match('VCR%u*(%d+)(%d)$') -- MSVCR<x><y> or VCRUNTIME<x><y> | ||
| 436 | if not major then return nil end | ||
| 437 | local keys = { | ||
| 438 | "HKLM\\Software\\Microsoft\\VisualStudio\\%d.%d\\Setup\\VC", | ||
| 439 | "HKLM\\Software\\Microsoft\\VCExpress\\%d.%d\\Setup\\VS" | ||
| 440 | } | ||
| 441 | for _, key in ipairs(keys) do | ||
| 442 | local vcdir = get_registry(key:format(major, minor), "ProductDir") | ||
| 443 | if vcdir then return vcdir end | ||
| 444 | end | ||
| 445 | return nil | ||
| 446 | end | ||
| 447 | |||
| 448 | local function get_windows_sdk_directory() | ||
| 449 | assert(type(vars.LUA_RUNTIME) == "string", "requires vars.LUA_RUNTIME to be set before calling this function.") | ||
| 450 | -- Only v7.1 and v6.1 shipped with compilers | ||
| 451 | -- Other versions requires a separate installation of Visual Studio. | ||
| 452 | -- see https://github.com/keplerproject/luarocks/pull/443#issuecomment-152792516 | ||
| 453 | local wsdks = { | ||
| 454 | ["MSVCR100"] = "v7.1", -- shipped with Visual Studio 2010 compilers. | ||
| 455 | ["MSVCR90"] = "v6.1", -- shipped with Visual Studio 2008 compilers. | ||
| 456 | } | ||
| 457 | local wsdkver = wsdks[vars.LUA_RUNTIME] | ||
| 458 | if not wsdkver then | ||
| 459 | return nil | ||
| 460 | end | ||
| 461 | |||
| 462 | local key = "HKLM\\Software\\Microsoft\\Microsoft SDKs\\Windows\\"..wsdkver | ||
| 463 | return get_registry(key, "InstallationFolder") | ||
| 464 | end | ||
| 465 | -- returns the batch command to setup msvc compiler path. | ||
| 466 | local function get_msvc_env_setup_cmd() | ||
| 467 | assert(type(vars.UNAME_M) == "string", "requires vars.UNAME_M to be set before calling this function.") | ||
| 468 | local x64 = vars.UNAME_M=="x86_64" | ||
| 469 | |||
| 470 | -- 1. try visual studio command line tools | ||
| 471 | local vcdir = get_visual_studio_directory() | ||
| 472 | if vcdir then | ||
| 473 | -- 1.1. try vcvarsall.bat | ||
| 474 | local vcvarsall = vcdir .. 'vcvarsall.bat' | ||
| 475 | if exists(vcvarsall) then | ||
| 476 | return ('call "%s"%s'):format(vcvarsall, x64 and ' amd64' or '') | ||
| 477 | end | ||
| 478 | |||
| 479 | -- 1.2. try vcvars32.bat / vcvars64.bat | ||
| 480 | local relative_path = x64 and "bin\\amd64\\vcvars64.bat" or "bin\\vcvars32.bat" | ||
| 481 | local full_path = vcdir .. relative_path | ||
| 482 | if exists(full_path) then | ||
| 483 | return ('call "%s"'):format(full_path) | ||
| 484 | end | ||
| 485 | end | ||
| 486 | |||
| 487 | -- 2. try for Windows SDKs command line tools. | ||
| 488 | local wsdkdir = get_windows_sdk_directory() | ||
| 489 | if wsdkdir then | ||
| 490 | local setenv = wsdkdir.."Bin\\SetEnv.cmd" | ||
| 491 | if exists(setenv) then | ||
| 492 | return ('call "%s" /Release /%s'):format(setenv, x64 and "x64" or "x86") | ||
| 493 | end | ||
| 494 | end | ||
| 495 | |||
| 496 | -- finaly, we can't detect more, just don't setup the msvc compiler in luarocks.bat. | ||
| 497 | return "" | ||
| 498 | end | ||
| 499 | |||
| 411 | local function look_for_lua_install () | 500 | local function look_for_lua_install () |
| 412 | print("Looking for Lua interpreter") | 501 | print("Looking for Lua interpreter") |
| 413 | local directories | 502 | local directories |
| @@ -653,6 +742,7 @@ if SELFCONTAINED then | |||
| 653 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] | 742 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] |
| 654 | REGISTRY = false | 743 | REGISTRY = false |
| 655 | end | 744 | end |
| 745 | vars.COMPILER_ENV_CMD = USE_MINGW and "" or get_msvc_env_setup_cmd() | ||
| 656 | 746 | ||
| 657 | print(S[[ | 747 | print(S[[ |
| 658 | 748 | ||
| @@ -758,7 +848,8 @@ for _, c in ipairs{"luarocks", "luarocks-admin"} do | |||
| 758 | local f = io.open(vars.BINDIR.."\\"..c..".bat", "w") | 848 | local f = io.open(vars.BINDIR.."\\"..c..".bat", "w") |
| 759 | f:write(S[[ | 849 | f:write(S[[ |
| 760 | @ECHO OFF | 850 | @ECHO OFF |
| 761 | SETLOCAL | 851 | SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS |
| 852 | $COMPILER_ENV_CMD | ||
| 762 | SET "LUA_PATH=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH%" | 853 | SET "LUA_PATH=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH%" |
| 763 | IF NOT "%LUA_PATH_5_2%"=="" ( | 854 | IF NOT "%LUA_PATH_5_2%"=="" ( |
| 764 | SET "LUA_PATH_5_2=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_2%" | 855 | SET "LUA_PATH_5_2=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_2%" |
