diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/core/cfg.lua | 41 |
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 | ||
| 50 | local function detect_sysconfdir() | 51 | local function detect_sysconfdir() |
| @@ -70,7 +71,11 @@ end | |||
| 70 | 71 | ||
| 71 | local function set_confdirs(cfg, platforms, hardcoded_sysconfdir) | 72 | local 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 | ||
| 172 | local function make_platforms(system) | 178 | local 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 |
