aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSutou Kouhei <kou@cozmixng.org>2020-10-29 03:51:11 +0900
committerGitHub <noreply@github.com>2020-10-28 15:51:11 -0300
commitd2c3b57b324f06d17cd2c594e26b143dfe3a8133 (patch)
treea73c2da21d06c7a0e4656812385f6350fbccb6ca /src
parent9d30bec0afe93a7a2284ae8adeeb03b2b36709dc (diff)
downloadluarocks-d2c3b57b324f06d17cd2c594e26b143dfe3a8133.tar.gz
luarocks-d2c3b57b324f06d17cd2c594e26b143dfe3a8133.tar.bz2
luarocks-d2c3b57b324f06d17cd2c594e26b143dfe3a8133.zip
Add support for MSYS2 + Mingw-w64 (#1231)
Currently, LuaRocks supports: * (a) Lua interpreters built for MSYS2 (Lua interpreters depend on msys-2.0.dll). (the "msys" platform) * (b) Lua interpreters built by MinGW (Lua interpreters don't depend on msys-2.0.dll). (the "mingw" platform) This change adds support for (c) Lua interpreters built as native Windows application by MSYS2 + Mingw-w64 (Lua interpreters don't depend on msys-2.0.dll). (the "msys2_mingw_w64" platform) Here are differences between (a), (b) and (c): * (a) can't work without MSYS2 (msys-2.0.dll) * (b) can work without MSYS2 * (c) can work without MSYS2 but is generally used with MSYS2 because MSYS2 provides packages of useful libraries such as libxml2. This change assumes that users use (c) with MSYS2. But this change still uses win32/tools provided by LuaRocks not MSYS2. MSYS2 has LuaRocks package: https://github.com/msys2/MINGW-packages/tree/master/mingw-w64-lua-luarocks It applies a patch to support (c). If this change is merged into LuaRocks, MSYS2 doesn't need to have a patch for LuaRocks.
Diffstat (limited to 'src')
-rw-r--r--src/luarocks/core/cfg.lua41
1 files changed, 36 insertions, 5 deletions
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua
index 9bfa8040..b3ff6cb3 100644
--- a/src/luarocks/core/cfg.lua
+++ b/src/luarocks/core/cfg.lua
@@ -45,6 +45,7 @@ local platform_order = {
45 "windows", 45 "windows",
46 "win32", 46 "win32",
47 "mingw32", 47 "mingw32",
48 "msys2_mingw_w64",
48} 49}
49 50
50local function detect_sysconfdir() 51local function detect_sysconfdir()
@@ -70,7 +71,11 @@ end
70 71
71local function set_confdirs(cfg, platforms, hardcoded_sysconfdir) 72local function set_confdirs(cfg, platforms, hardcoded_sysconfdir)
72 local sysconfdir = os.getenv("LUAROCKS_SYSCONFDIR") or hardcoded_sysconfdir 73 local sysconfdir = os.getenv("LUAROCKS_SYSCONFDIR") or hardcoded_sysconfdir
73 if platforms.windows then 74 local windows_style = platforms.windows
75 if platforms.msys2_mingw_w64 then
76 windows_style = false
77 end
78 if windows_style then
74 cfg.home = os.getenv("APPDATA") or "c:" 79 cfg.home = os.getenv("APPDATA") or "c:"
75 cfg.home_tree = cfg.home.."/luarocks" 80 cfg.home_tree = cfg.home.."/luarocks"
76 cfg.homeconfdir = cfg.home_tree 81 cfg.homeconfdir = cfg.home_tree
@@ -167,6 +172,7 @@ local platform_sets = {
167 linux = { unix = true, linux = true }, 172 linux = { unix = true, linux = true },
168 mingw = { windows = true, win32 = true, mingw32 = true, mingw = true }, 173 mingw = { windows = true, win32 = true, mingw32 = true, mingw = true },
169 msys = { unix = true, cygwin = true, msys = true }, 174 msys = { unix = true, cygwin = true, msys = true },
175 msys2_mingw_w64 = { windows = true, win32 = true, mingw32 = true, mingw = true, msys = true, msys2_mingw_w64 = true },
170} 176}
171 177
172local function make_platforms(system) 178local function make_platforms(system)
@@ -416,6 +422,29 @@ local function make_defaults(lua_version, target_cpu, platforms, home)
416 lib = { "lib?.so", "?.dll", "lib?.dll" }, 422 lib = { "lib?.so", "?.dll", "lib?.dll" },
417 include = { "?.h" } 423 include = { "?.h" }
418 } 424 }
425 if platforms.mingw then
426 -- MSYS2 can build Windows programs that depend on
427 -- msys-2.0.dll (based on Cygwin) but MSYS2 is also designed
428 -- for building native Windows programs by MinGW. These
429 -- programs don't depend on msys-2.0.dll.
430 local pipe = io.popen("cygpath --windows %MINGW_PREFIX%")
431 local mingw_prefix = pipe:read("*l")
432 pipe:close()
433 defaults.external_deps_dirs = { mingw_prefix, "c:/windows/system32" }
434 defaults.makefile = "Makefile"
435 defaults.cmake_generator = "MSYS Makefiles"
436 defaults.local_cache = home.."/.cache/luarocks"
437 defaults.variables.MAKE = "make"
438 defaults.variables.CC = "gcc"
439 defaults.variables.RC = "windres"
440 defaults.variables.LD = "gcc"
441 defaults.variables.MT = nil
442 defaults.variables.AR = "ar"
443 defaults.variables.RANLIB = "ranlib"
444 defaults.variables.LUALIB = "liblua"..lua_version..".dll.a"
445 defaults.variables.CFLAGS = "-O2 -fPIC"
446 defaults.variables.LIBFLAG = "-shared"
447 end
419 end 448 end
420 449
421 if platforms.bsd then 450 if platforms.bsd then
@@ -600,12 +629,14 @@ function cfg.init(detected, warning)
600 -- running from the Development Command prompt for VS 2017 629 -- running from the Development Command prompt for VS 2017
601 system = "windows" 630 system = "windows"
602 else 631 else
603 local fd = io.open("/bin/sh", "r") 632 local msystem = os.getenv("MSYSTEM")
604 if fd then 633 if msystem == nil then
605 fd:close() 634 system = "mingw"
635 elseif msystem == "MSYS" then
606 system = "msys" 636 system = "msys"
607 else 637 else
608 system = "mingw" 638 -- MINGW32 or MINGW64
639 system = "msys2_mingw_w64"
609 end 640 end
610 end 641 end
611 end 642 end