From 0f97b892681839cebf0863a3a15b3be0c68419e8 Mon Sep 17 00:00:00 2001 From: sharpobject Date: Sun, 3 Jan 2021 20:11:59 +0900 Subject: Handle MACOSX versions >10 or with 2 dots Fixes #1238. --- src/luarocks/build.lua | 12 +++++------- 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") local dir = require("luarocks.dir") local deps = require("luarocks.deps") local cfg = require("luarocks.core.cfg") +local vers = require("luarocks.core.vers") local repos = require("luarocks.repos") local writer = require("luarocks.manif.writer") local deplocks = require("luarocks.deplocks") @@ -82,9 +83,6 @@ end local function check_macosx_deployment_target(rockspec) local target = rockspec.build.macosx_deployment_target - local function minor(version) - return tonumber(version and version:match("^[^.]+%.([^.]+)")) - end local function patch_variable(var) if rockspec.variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then 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) end if cfg.is_platform("macosx") and rockspec:format_is_at_least("3.0") and target then local version = util.popen_read("sw_vers -productVersion") - local versionminor = minor(version) - local targetminor = minor(target) - if targetminor > versionminor then - return nil, ("This rock requires Mac OSX 10.%d, and you are running 10.%d."):format(targetminor, versionminor) + if version:match("^%d+%.%d+%.%d+$") or version:match("^%d+%.%d+$") then + if vers.compare_versions(target, version) then + return nil, ("This rock requires Mac OSX %s, and you are running %s."):format(targetversion, version) + end end patch_variable("CC") 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 local util = require("luarocks.core.util") local persist = require("luarocks.core.persist") local sysdetect = require("luarocks.core.sysdetect") +local vers = require("luarocks.core.vers") -------------------------------------------------------------------------------- @@ -457,16 +458,19 @@ local function make_defaults(lua_version, target_cpu, platforms, home) defaults.arch = "macosx-"..target_cpu defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" local version = util.popen_read("sw_vers -productVersion") - version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 - if version >= 10 then - version = 8 - elseif version >= 5 then - version = 5 + if not (version:match("^%d+%.%d+%.%d+$") or version:match("^%d+%.%d+$")) then + version = "10.3" + end + version = vers.parse_version(version) + if version >= vers.parse_version("10.10") then + version = vers.parse_version("10.8") + elseif version >= vers.parse_version("10.5") then + version = vers.parse_version("10.5") else defaults.gcc_rpath = false end - defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" - defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET=10."..version.." gcc" + defaults.variables.CC = "env MACOSX_DEPLOYMENT_TARGET="..tostring(version).." gcc" + defaults.variables.LD = "env MACOSX_DEPLOYMENT_TARGET="..tostring(version).." gcc" defaults.web_browser = "open" end -- cgit v1.2.3-55-g6feb