diff options
author | Xpol Wan <xpolife@gmail.com> | 2015-10-23 16:14:18 +0800 |
---|---|---|
committer | Xpol Wan <xpolife@gmail.com> | 2015-10-23 16:14:18 +0800 |
commit | 7235ad9f40fbbf27b9fd1097817587e892690556 (patch) | |
tree | 0afe4806078fc09dc5f1254dc240829f58204e75 | |
parent | 9c99043149e7578fbbfedbbdc7950a3c1f61ba6e (diff) | |
download | luarocks-7235ad9f40fbbf27b9fd1097817587e892690556.tar.gz luarocks-7235ad9f40fbbf27b9fd1097817587e892690556.tar.bz2 luarocks-7235ad9f40fbbf27b9fd1097817587e892690556.zip |
Automatically setup MSVC command line tools for VC2008 or above.
-rw-r--r-- | install.bat | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/install.bat b/install.bat index 57e3611c..90e9b8d4 100644 --- a/install.bat +++ b/install.bat | |||
@@ -409,6 +409,25 @@ local function get_architecture() | |||
409 | return proc | 409 | return proc |
410 | end | 410 | end |
411 | 411 | ||
412 | -- uses vars.LUA_RUNTIME and vars.UNAME_M | ||
413 | local function get_compiler_env_cmd() | ||
414 | local major, minor = vars.LUA_RUNTIME:match('^MSVCR(%d+)(%d)$') | ||
415 | if not major then return "" end | ||
416 | local key = "HKEY_LOCAL_MACHINE\\SOFTWARE%s\\Microsoft\\VisualStudio\\%d.%d" | ||
417 | local hostarch64 = os.getenv("ProgramFiles(x86)")~=nil -- 'PROCESSOR_ARCHITECTURE' will always return 'x86' if interpreter is 32 bit. | ||
418 | key = key:format(hostarch64 and "\\Wow6432Node" or "", major, minor) | ||
419 | |||
420 | local h = io.popen('reg query "'..key..'" /v InstallDir 2>NUL') | ||
421 | local output = h:read('*a') | ||
422 | h:close() | ||
423 | |||
424 | local msvcdir = output:match("REG_SZ%s+(.+)\\Common7\\IDE") | ||
425 | if not msvcdir then return "" end | ||
426 | local msvcarch = vars.UNAME_M=="x86_64" and " x86_amd64" or "" | ||
427 | |||
428 | return ('call "%s\\VC\\vcvarsall.bat"%s'):format(msvcdir, msvcarch) | ||
429 | end | ||
430 | |||
412 | local function look_for_lua_install () | 431 | local function look_for_lua_install () |
413 | print("Looking for Lua interpreter") | 432 | print("Looking for Lua interpreter") |
414 | local directories | 433 | local directories |
@@ -627,6 +646,7 @@ if SELFCONTAINED then | |||
627 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] | 646 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] |
628 | REGISTRY = false | 647 | REGISTRY = false |
629 | end | 648 | end |
649 | vars.COMPILER_ENV_CMD = get_compiler_env_cmd(vars.LUA_RUNTIME, vars.UNAME_M) | ||
630 | 650 | ||
631 | print(S[[ | 651 | print(S[[ |
632 | 652 | ||
@@ -731,6 +751,7 @@ for _, c in ipairs{"luarocks", "luarocks-admin"} do | |||
731 | f:write(S[[ | 751 | f:write(S[[ |
732 | @ECHO OFF | 752 | @ECHO OFF |
733 | SETLOCAL | 753 | SETLOCAL |
754 | $COMPILER_ENV_CMD | ||
734 | SET "LUA_PATH=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH%" | 755 | SET "LUA_PATH=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH%" |
735 | IF NOT "%LUA_PATH_5_2%"=="" ( | 756 | IF NOT "%LUA_PATH_5_2%"=="" ( |
736 | SET "LUA_PATH_5_2=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_2%" | 757 | SET "LUA_PATH_5_2=$LUADIR\?.lua;$LUADIR\?\init.lua;%LUA_PATH_5_2%" |