diff options
| author | sharpobject <sharpobject@gmail.com> | 2021-01-03 20:11:59 +0900 |
|---|---|---|
| committer | sharpobject <sharpobject@gmail.com> | 2021-01-03 21:28:32 +0900 |
| commit | 0f97b892681839cebf0863a3a15b3be0c68419e8 (patch) | |
| tree | 8dbb826c06ffce6ad2d7401ac57fce0a82bc1670 /src | |
| parent | 0068685158947e966572b4a41e4f66688495b02b (diff) | |
| download | luarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.tar.gz luarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.tar.bz2 luarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.zip | |
Handle MACOSX versions >10 or with 2 dots
Fixes #1238.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/build.lua | 12 | ||||
| -rw-r--r-- | src/luarocks/core/cfg.lua | 18 |
2 files changed, 16 insertions, 14 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index c410fbde..0e8e7f58 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -9,6 +9,7 @@ local fs = require("luarocks.fs") | |||
| 9 | local dir = require("luarocks.dir") | 9 | local dir = require("luarocks.dir") |
| 10 | local deps = require("luarocks.deps") | 10 | local deps = require("luarocks.deps") |
| 11 | local cfg = require("luarocks.core.cfg") | 11 | local cfg = require("luarocks.core.cfg") |
| 12 | local vers = require("luarocks.core.vers") | ||
| 12 | local repos = require("luarocks.repos") | 13 | local repos = require("luarocks.repos") |
| 13 | local writer = require("luarocks.manif.writer") | 14 | local writer = require("luarocks.manif.writer") |
| 14 | local deplocks = require("luarocks.deplocks") | 15 | local deplocks = require("luarocks.deplocks") |
| @@ -82,9 +83,6 @@ end | |||
| 82 | 83 | ||
| 83 | local function check_macosx_deployment_target(rockspec) | 84 | local function check_macosx_deployment_target(rockspec) |
| 84 | local target = rockspec.build.macosx_deployment_target | 85 | local target = rockspec.build.macosx_deployment_target |
| 85 | local function minor(version) | ||
| 86 | return tonumber(version and version:match("^[^.]+%.([^.]+)")) | ||
| 87 | end | ||
| 88 | local function patch_variable(var) | 86 | local function patch_variable(var) |
| 89 | if rockspec.variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then | 87 | if rockspec.variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then |
| 90 | rockspec.variables[var] = (rockspec.variables[var]):gsub("MACOSX_DEPLOYMENT_TARGET=[^ ]*", "MACOSX_DEPLOYMENT_TARGET="..target) | 88 | rockspec.variables[var] = (rockspec.variables[var]):gsub("MACOSX_DEPLOYMENT_TARGET=[^ ]*", "MACOSX_DEPLOYMENT_TARGET="..target) |
| @@ -94,10 +92,10 @@ local function check_macosx_deployment_target(rockspec) | |||
| 94 | end | 92 | end |
| 95 | if cfg.is_platform("macosx") and rockspec:format_is_at_least("3.0") and target then | 93 | if cfg.is_platform("macosx") and rockspec:format_is_at_least("3.0") and target then |
| 96 | local version = util.popen_read("sw_vers -productVersion") | 94 | local version = util.popen_read("sw_vers -productVersion") |
| 97 | local versionminor = minor(version) | 95 | if version:match("^%d+%.%d+%.%d+$") or version:match("^%d+%.%d+$") then |
| 98 | local targetminor = minor(target) | 96 | if vers.compare_versions(target, version) then |
| 99 | if targetminor > versionminor then | 97 | return nil, ("This rock requires Mac OSX %s, and you are running %s."):format(targetversion, version) |
| 100 | return nil, ("This rock requires Mac OSX 10.%d, and you are running 10.%d."):format(targetminor, versionminor) | 98 | end |
| 101 | end | 99 | end |
| 102 | patch_variable("CC") | 100 | patch_variable("CC") |
| 103 | patch_variable("LD") | 101 | patch_variable("LD") |
diff --git a/src/luarocks/core/cfg.lua b/src/luarocks/core/cfg.lua index fada3048..4ac5ee28 100644 --- a/src/luarocks/core/cfg.lua +++ b/src/luarocks/core/cfg.lua | |||
| @@ -16,6 +16,7 @@ local next, table, pairs, require, os, pcall, ipairs, package, tonumber, type, a | |||
| 16 | local util = require("luarocks.core.util") | 16 | local util = require("luarocks.core.util") |
| 17 | local persist = require("luarocks.core.persist") | 17 | local persist = require("luarocks.core.persist") |
| 18 | local sysdetect = require("luarocks.core.sysdetect") | 18 | local sysdetect = require("luarocks.core.sysdetect") |
| 19 | local vers = require("luarocks.core.vers") | ||
| 19 | 20 | ||
| 20 | -------------------------------------------------------------------------------- | 21 | -------------------------------------------------------------------------------- |
| 21 | 22 | ||
| @@ -457,16 +458,19 @@ local function make_defaults(lua_version, target_cpu, platforms, home) | |||
| 457 | defaults.arch = "macosx-"..target_cpu | 458 | defaults.arch = "macosx-"..target_cpu |
| 458 | defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" | 459 | defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" |
| 459 | local version = util.popen_read("sw_vers -productVersion") | 460 | local version = util.popen_read("sw_vers -productVersion") |
| 460 | version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 | 461 | if not (version:match("^%d+%.%d+%.%d+$") or version:match("^%d+%.%d+$")) then |
| 461 | if version >= 10 then | 462 | version = "10.3" |
| 462 | version = 8 | 463 | end |
| 463 | elseif version >= 5 then | 464 | version = vers.parse_version(version) |
| 464 | version = 5 | 465 | if version >= vers.parse_version("10.10") then |
| 466 | version = vers.parse_version("10.8") | ||
| 467 | elseif version >= vers.parse_version("10.5") then | ||
| 468 | version = vers.parse_version("10.5") | ||
| 465 | else | 469 | else |
| 466 | defaults.gcc_rpath = false | 470 | defaults.gcc_rpath = false |
| 467 | end | 471 | end |
| 468 | defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" | 472 | defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET="..tostring(version).." gcc" |
| 469 | defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" | 473 | defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET="..tostring(version).." gcc" |
| 470 | defaults.web_browser = "open" | 474 | defaults.web_browser = "open" |
| 471 | end | 475 | end |
| 472 | 476 | ||
