aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsharpobject <sharpobject@gmail.com>2021-01-03 20:11:59 +0900
committersharpobject <sharpobject@gmail.com>2021-01-03 21:28:32 +0900
commit0f97b892681839cebf0863a3a15b3be0c68419e8 (patch)
tree8dbb826c06ffce6ad2d7401ac57fce0a82bc1670
parent0068685158947e966572b4a41e4f66688495b02b (diff)
downloadluarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.tar.gz
luarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.tar.bz2
luarocks-0f97b892681839cebf0863a3a15b3be0c68419e8.zip
Handle MACOSX versions >10 or with 2 dots
Fixes #1238.
-rw-r--r--src/luarocks/build.lua12
-rw-r--r--src/luarocks/core/cfg.lua18
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")
9local dir = require("luarocks.dir") 9local dir = require("luarocks.dir")
10local deps = require("luarocks.deps") 10local deps = require("luarocks.deps")
11local cfg = require("luarocks.core.cfg") 11local cfg = require("luarocks.core.cfg")
12local vers = require("luarocks.core.vers")
12local repos = require("luarocks.repos") 13local repos = require("luarocks.repos")
13local writer = require("luarocks.manif.writer") 14local writer = require("luarocks.manif.writer")
14local deplocks = require("luarocks.deplocks") 15local deplocks = require("luarocks.deplocks")
@@ -82,9 +83,6 @@ end
82 83
83local function check_macosx_deployment_target(rockspec) 84local 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
16local util = require("luarocks.core.util") 16local util = require("luarocks.core.util")
17local persist = require("luarocks.core.persist") 17local persist = require("luarocks.core.persist")
18local sysdetect = require("luarocks.core.sysdetect") 18local sysdetect = require("luarocks.core.sysdetect")
19local 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