diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2018-01-09 18:48:42 +0100 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2018-01-11 14:37:52 -0200 |
| commit | 4c22bfb86abcd97253c73d2175d0a715c2a2cc12 (patch) | |
| tree | 68352fdf0e83900c3adbc7231a180c28ec38e320 | |
| parent | 07d4ff85e189da8b52214a744b1e5af9901dfdea (diff) | |
| download | luarocks-4c22bfb86abcd97253c73d2175d0a715c2a2cc12.tar.gz luarocks-4c22bfb86abcd97253c73d2175d0a715c2a2cc12.tar.bz2 luarocks-4c22bfb86abcd97253c73d2175d0a715c2a2cc12.zip | |
Update Windows installer to better handle gcc toolchains (#759)
Update the Windows installer to better handle gcc toolchain in different environments
| -rw-r--r-- | install.bat | 92 |
1 files changed, 89 insertions, 3 deletions
diff --git a/install.bat b/install.bat index 0f334ab9..09cf9aa2 100644 --- a/install.bat +++ b/install.bat | |||
| @@ -27,6 +27,13 @@ vars.LUA_SHORTV = nil -- "51" | |||
| 27 | vars.LUA_RUNTIME = nil | 27 | vars.LUA_RUNTIME = nil |
| 28 | vars.UNAME_M = nil | 28 | vars.UNAME_M = nil |
| 29 | vars.COMPILER_ENV_CMD = nil | 29 | vars.COMPILER_ENV_CMD = nil |
| 30 | vars.MINGW_BIN_PATH = nil | ||
| 31 | vars.MINGW_CC = nil | ||
| 32 | vars.MINGW_MAKE = nil | ||
| 33 | vars.MINGW_RC = nil | ||
| 34 | vars.MINGW_LD = nil | ||
| 35 | vars.MINGW_AR = nil | ||
| 36 | vars.MINGW_RANLIB = nil | ||
| 30 | 37 | ||
| 31 | local FORCE = false | 38 | local FORCE = false |
| 32 | local FORCE_CONFIG = false | 39 | local FORCE_CONFIG = false |
| @@ -617,6 +624,66 @@ local function restore_config_files() | |||
| 617 | vars.CONFBACKUPDIR = nil | 624 | vars.CONFBACKUPDIR = nil |
| 618 | end | 625 | end |
| 619 | 626 | ||
| 627 | -- Find GCC based toolchain | ||
| 628 | local find_gcc_suite = function() | ||
| 629 | |||
| 630 | -- read output os-command | ||
| 631 | local read_output = function(cmd) | ||
| 632 | local f = io.popen("type NUL && " .. cmd .. ' 2>NUL') | ||
| 633 | if not f then return nil, "failed to open command: " .. tostring(cmd) end | ||
| 634 | local lines = {} | ||
| 635 | while true do | ||
| 636 | local l = f:read() | ||
| 637 | if not l then | ||
| 638 | f:close() | ||
| 639 | return lines | ||
| 640 | end | ||
| 641 | table.insert(lines, l) | ||
| 642 | end | ||
| 643 | end | ||
| 644 | |||
| 645 | -- returns: full filename, path, filename | ||
| 646 | local find_file = function(mask, path) | ||
| 647 | local cmd | ||
| 648 | if path then | ||
| 649 | cmd = 'where.exe /R "' .. path .. '" ' .. mask | ||
| 650 | else | ||
| 651 | cmd = 'where.exe ' .. mask | ||
| 652 | end | ||
| 653 | local files, err = read_output(cmd) | ||
| 654 | if not files or not files[1] then | ||
| 655 | return nil, "couldn't find '".. mask .. "', " .. (err or "not found") | ||
| 656 | end | ||
| 657 | local path, file = string.match(files[1], "^(.+)%\\([^%\\]+)$") | ||
| 658 | return files[1], path, file | ||
| 659 | end | ||
| 660 | |||
| 661 | local first_one = "*gcc.exe" -- first file we're assuming to point to the compiler suite | ||
| 662 | local full, path, filename = find_file(first_one, nil) | ||
| 663 | if not full then | ||
| 664 | return nil, path | ||
| 665 | end | ||
| 666 | vars.MINGW_BIN_PATH = path | ||
| 667 | |||
| 668 | local result = { | ||
| 669 | gcc = full | ||
| 670 | } | ||
| 671 | for i, name in ipairs({"make", "ar", "windres", "ranlib"}) do | ||
| 672 | result[name] = find_file(name..".exe", path) | ||
| 673 | if not result[name] then | ||
| 674 | result[name] = find_file("*"..name.."*.exe", path) | ||
| 675 | end | ||
| 676 | end | ||
| 677 | |||
| 678 | vars.MINGW_MAKE = (result.make and '[['..result.make..']]') or "nil -- not found by installer" | ||
| 679 | vars.MINGW_CC = (result.gcc and '[['..result.gcc..']]') or "nil -- not found by installer" | ||
| 680 | vars.MINGW_RC = (result.windres and '[['..result.windres..']]') or "nil -- not found by installer" | ||
| 681 | vars.MINGW_LD = (result.gcc and '[['..result.gcc..']]') or "nil -- not found by installer" | ||
| 682 | vars.MINGW_AR = (result.ar and '[['..result.ar..']]') or "nil -- not found by installer" | ||
| 683 | vars.MINGW_RANLIB = (result.ranlib and '[['..result.ranlib..']]') or "nil -- not found by installer" | ||
| 684 | return true | ||
| 685 | end | ||
| 686 | |||
| 620 | -- *********************************************************** | 687 | -- *********************************************************** |
| 621 | -- Installer script start | 688 | -- Installer script start |
| 622 | -- *********************************************************** | 689 | -- *********************************************************** |
| @@ -765,7 +832,15 @@ if SELFCONTAINED then | |||
| 765 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] | 832 | vars.TREE_ROOT = vars.PREFIX..[[\systree]] |
| 766 | REGISTRY = false | 833 | REGISTRY = false |
| 767 | end | 834 | end |
| 768 | vars.COMPILER_ENV_CMD = (USE_MINGW and "") or (USE_MSVC_MANUAL and "") or get_msvc_env_setup_cmd() | 835 | if USE_MINGW then |
| 836 | vars.COMPILER_ENV_CMD = "" | ||
| 837 | local found, err = find_gcc_suite() | ||
| 838 | if not found then | ||
| 839 | die("Failed to find MinGW/gcc based toolchain, make sure it is in your path: " .. tostring(err)) | ||
| 840 | end | ||
| 841 | else | ||
| 842 | vars.COMPILER_ENV_CMD = (USE_MSVC_MANUAL and "") or get_msvc_env_setup_cmd() | ||
| 843 | end | ||
| 769 | 844 | ||
| 770 | print(S[[ | 845 | print(S[[ |
| 771 | 846 | ||
| @@ -787,7 +862,8 @@ Lua interpreter : $LUA_BINDIR\$LUA_INTERPRETER | |||
| 787 | ]]) | 862 | ]]) |
| 788 | 863 | ||
| 789 | if USE_MINGW then | 864 | if USE_MINGW then |
| 790 | print("Compiler : MinGW (make sure it is in your path before using LuaRocks)") | 865 | print(S[[Compiler : MinGW/gcc (make sure it is in your path before using LuaRocks)]]) |
| 866 | print(S[[ in: $MINGW_BIN_PATH]]) | ||
| 791 | else | 867 | else |
| 792 | if vars.COMPILER_ENV_CMD == "" then | 868 | if vars.COMPILER_ENV_CMD == "" then |
| 793 | print("Compiler : Microsoft (make sure it is in your path before using LuaRocks)") | 869 | print("Compiler : Microsoft (make sure it is in your path before using LuaRocks)") |
| @@ -1013,7 +1089,17 @@ if USE_MINGW and vars.LUA_RUNTIME == "MSVCRT" then | |||
| 1013 | else | 1089 | else |
| 1014 | f:write(" MSVCRT = '"..vars.LUA_RUNTIME.."',\n") | 1090 | f:write(" MSVCRT = '"..vars.LUA_RUNTIME.."',\n") |
| 1015 | end | 1091 | end |
| 1016 | f:write(S" LUALIB = '$LUA_LIBNAME'\n") | 1092 | f:write(S" LUALIB = '$LUA_LIBNAME',\n") |
| 1093 | if USE_MINGW then | ||
| 1094 | f:write(S[[ | ||
| 1095 | CC = $MINGW_CC, | ||
| 1096 | MAKE = $MINGW_MAKE, | ||
| 1097 | RC = $MINGW_RC, | ||
| 1098 | LD = $MINGW_LD, | ||
| 1099 | AR = $MINGW_AR, | ||
| 1100 | RANLIB = $MINGW_RANLIB, | ||
| 1101 | ]]) | ||
| 1102 | end | ||
| 1017 | f:write("}\n") | 1103 | f:write("}\n") |
| 1018 | f:write("verbose = false -- set to 'true' to enable verbose output\n") | 1104 | f:write("verbose = false -- set to 'true' to enable verbose output\n") |
| 1019 | f:close() | 1105 | f:close() |
