diff options
author | Xpol Wan <xpolife@gmail.com> | 2015-11-01 14:08:09 +0800 |
---|---|---|
committer | Xpol Wan <xpolife@gmail.com> | 2015-11-01 14:08:09 +0800 |
commit | 21839814515a42e9c2da4a9cbc28029bddbab43e (patch) | |
tree | 39c480e11717264d3218167fa46e5896b2411de6 | |
parent | 4c3b41e765cf42afecfba8e32965e5c057c96870 (diff) | |
download | luarocks-21839814515a42e9c2da4a9cbc28029bddbab43e.tar.gz luarocks-21839814515a42e9c2da4a9cbc28029bddbab43e.tar.bz2 luarocks-21839814515a42e9c2da4a9cbc28029bddbab43e.zip |
Support Visual Studio Express Editions and cleanup code.
-rw-r--r-- | install.bat | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/install.bat b/install.bat index 0514af1b..01461667 100644 --- a/install.bat +++ b/install.bat | |||
@@ -412,21 +412,18 @@ end | |||
412 | -- get a string value from windows registry. | 412 | -- get a string value from windows registry. |
413 | local function get_registry(key, value) | 413 | local function get_registry(key, value) |
414 | local keys = {key} | 414 | local keys = {key} |
415 | local key64, replaces = key:gsub("(%u+\\SOFTWARE\\)", "\1Wow6432Node\\", 1) | 415 | local key64, replaced = key:gsub("(%u+\\Software\\)", "\1Wow6432Node\\", 1) |
416 | if replaces == 0 then | ||
417 | key64, replaces = key:gsub("(%u+\\Software\\)", "\1Wow6432Node\\", 1) | ||
418 | end | ||
419 | 416 | ||
420 | if replaces == 1 then | 417 | if replaced == 1 then |
421 | table.insert(keys, 1, key64) | 418 | keys = {key64, key} |
422 | end | 419 | end |
423 | 420 | ||
424 | for _, k in ipairs(keys) do | 421 | for _, k in ipairs(keys) do |
425 | local h = io.popen('reg query "'..k..'" /v '..value..' 2>NUL') | 422 | local h = io.popen('reg query "'..k..'" /v '..value..' 2>NUL') |
426 | local output = h:read('*a') | 423 | local output = h:read("*a") |
427 | h:close() | 424 | h:close() |
428 | 425 | ||
429 | local v = output:match('REG_SZ%s+([^\n]+)') | 426 | local v = output:match("REG_SZ%s+([^\n]+)") |
430 | if v then | 427 | if v then |
431 | return v | 428 | return v |
432 | end | 429 | end |
@@ -437,9 +434,16 @@ end | |||
437 | -- requires vars.LUA_RUNTIME to be set before calling this function. | 434 | -- requires vars.LUA_RUNTIME to be set before calling this function. |
438 | local function get_visual_studio_directory() | 435 | local function get_visual_studio_directory() |
439 | local major, minor = vars.LUA_RUNTIME:match('VCR%u*(%d+)(%d)$') -- MSVCR<x><y> or VCRUNTIME<x><y> | 436 | local major, minor = vars.LUA_RUNTIME:match('VCR%u*(%d+)(%d)$') -- MSVCR<x><y> or VCRUNTIME<x><y> |
440 | if not major then return "" end | 437 | if not major then return nil end |
441 | local key = ("HKLM\\SOFTWARE\\Microsoft\\VisualStudio\\%d.%d\\Setup\\VC"):format(major, minor) | 438 | local keys = { |
442 | return get_registry(key, 'ProductDir') | 439 | "HKLM\\Software\\Microsoft\\VisualStudio\\%d.%d\\Setup\\VC", |
440 | "HKLM\\Software\\Microsoft\\VCExpress\\%d.%d\\Setup\\VS" | ||
441 | } | ||
442 | for _, key in ipairs(keys) do | ||
443 | local vcdir = get_registry(key:format(major, minor), "ProductDir") | ||
444 | if vcdir then return vcdir end | ||
445 | end | ||
446 | return nil | ||
443 | end | 447 | end |
444 | 448 | ||
445 | -- requires vars.LUA_RUNTIME to be set before calling this function. | 449 | -- requires vars.LUA_RUNTIME to be set before calling this function. |
@@ -456,8 +460,8 @@ local function get_windows_sdk_directory() | |||
456 | return nil | 460 | return nil |
457 | end | 461 | end |
458 | 462 | ||
459 | local key = "HKLM\\SOFTWARE\\Microsoft\\Microsoft SDKs\\Windows\\"..wsdkver | 463 | local key = "HKLM\\Software\\Microsoft\\Microsoft SDKs\\Windows\\"..wsdkver |
460 | return get_registry(key, 'InstallationFolder') | 464 | return get_registry(key, "InstallationFolder") |
461 | end | 465 | end |
462 | -- returns the batch command to setup msvc compiler path. | 466 | -- returns the batch command to setup msvc compiler path. |
463 | -- requires vars.LUA_RUNTIME and vars.UNAME_M to be set before calling this function. | 467 | -- requires vars.LUA_RUNTIME and vars.UNAME_M to be set before calling this function. |
@@ -486,7 +490,7 @@ local function get_msvc_env_setup_cmd() | |||
486 | if wsdkdir then | 490 | if wsdkdir then |
487 | local setenv = wsdkdir.."Bin\\SetEnv.cmd" | 491 | local setenv = wsdkdir.."Bin\\SetEnv.cmd" |
488 | if exists(setenv) then | 492 | if exists(setenv) then |
489 | return ("call \"%s\" /Release /%s"):format(setenv, x64 and "x64" or "x86") | 493 | return ('call "%s" /Release /%s'):format(setenv, x64 and "x64" or "x86") |
490 | end | 494 | end |
491 | end | 495 | end |
492 | 496 | ||