diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-29 12:51:28 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-11-29 12:51:28 -0200 |
| commit | e95bfca9f1f1e417a2f554cb756cd44a7eb105cb (patch) | |
| tree | 9164a20aa734a4a95c1d99220e5e743a19054a37 | |
| parent | c27d9ace24f4773da4e6d3680d60769aa1f33197 (diff) | |
| download | luarocks-e95bfca9f1f1e417a2f554cb756cd44a7eb105cb.tar.gz luarocks-e95bfca9f1f1e417a2f554cb756cd44a7eb105cb.tar.bz2 luarocks-e95bfca9f1f1e417a2f554cb756cd44a7eb105cb.zip | |
Add explicit macosx_deployment_target option for Mac users.
| -rw-r--r-- | src/luarocks/build.lua | 30 | ||||
| -rw-r--r-- | src/luarocks/cfg.lua | 6 | ||||
| -rw-r--r-- | src/luarocks/util.lua | 14 |
3 files changed, 47 insertions, 3 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 68f20264..dd0b4441 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
| @@ -149,6 +149,31 @@ local function install_default_docs(name, version) | |||
| 149 | end | 149 | end |
| 150 | end | 150 | end |
| 151 | 151 | ||
| 152 | local function check_macosx_deployment_target(rockspec) | ||
| 153 | local target = rockspec.build.macosx_deployment_target | ||
| 154 | local function minor(version) | ||
| 155 | return tonumber(version and version:match("^[^.]+%.([^.]+)")) | ||
| 156 | end | ||
| 157 | local function patch_variable(var, target) | ||
| 158 | if rockspec.variables[var]:match("MACOSX_DEPLOYMENT_TARGET") then | ||
| 159 | rockspec.variables[var] = (rockspec.variables[var]):gsub("MACOSX_DEPLOYMENT_TARGET=[^ ]*", "MACOSX_DEPLOYMENT_TARGET="..target) | ||
| 160 | else | ||
| 161 | rockspec.variables[var] = "env MACOSX_DEPLOYMENT_TARGET="..target.." "..rockspec.variables[var] | ||
| 162 | end | ||
| 163 | end | ||
| 164 | if cfg.platforms.macosx and deps.format_is_at_least(rockspec, "3.0") and target then | ||
| 165 | local version = util.popen_read("sw_vers -productVersion") | ||
| 166 | local versionminor = minor(version) | ||
| 167 | local targetminor = minor(target) | ||
| 168 | if targetminor > versionminor then | ||
| 169 | return nil, ("This rock requires Mac OSX 10.%d, and you are running 10.%d."):format(targetminor, versionminor) | ||
| 170 | end | ||
| 171 | patch_variable("CC", target) | ||
| 172 | patch_variable("LD", target) | ||
| 173 | end | ||
| 174 | return true | ||
| 175 | end | ||
| 176 | |||
| 152 | --- Build and install a rock given a rockspec. | 177 | --- Build and install a rock given a rockspec. |
| 153 | -- @param rockspec_file string: local or remote filename of a rockspec. | 178 | -- @param rockspec_file string: local or remote filename of a rockspec. |
| 154 | -- @param need_to_fetch boolean: true if sources need to be fetched, | 179 | -- @param need_to_fetch boolean: true if sources need to be fetched, |
| @@ -244,6 +269,11 @@ function build.build_rockspec(rockspec_file, need_to_fetch, minimal_mode, deps_m | |||
| 244 | end | 269 | end |
| 245 | end | 270 | end |
| 246 | 271 | ||
| 272 | ok, err = check_macosx_deployment_target(rockspec) | ||
| 273 | if not ok then | ||
| 274 | return nil, err | ||
| 275 | end | ||
| 276 | |||
| 247 | if build_spec.type ~= "none" then | 277 | if build_spec.type ~= "none" then |
| 248 | 278 | ||
| 249 | -- Temporary compatibility | 279 | -- Temporary compatibility |
diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index 4fb1b23b..6706468c 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua | |||
| @@ -76,8 +76,8 @@ end | |||
| 76 | -- so that this detection does not run every time. When it is | 76 | -- so that this detection does not run every time. When it is |
| 77 | -- performed, we use the Unix way to identify the system, | 77 | -- performed, we use the Unix way to identify the system, |
| 78 | -- even on Windows (assuming UnxUtils or Cygwin). | 78 | -- even on Windows (assuming UnxUtils or Cygwin). |
| 79 | local system = site_config.LUAROCKS_UNAME_S or io.popen("uname -s"):read("*l") | 79 | local system = site_config.LUAROCKS_UNAME_S or util.popen_read("uname -s") |
| 80 | local proc = site_config.LUAROCKS_UNAME_M or io.popen("uname -m"):read("*l") | 80 | local proc = site_config.LUAROCKS_UNAME_M or util.popen_read("uname -m") |
| 81 | if proc:match("i[%d]86") then | 81 | if proc:match("i[%d]86") then |
| 82 | cfg.target_cpu = "x86" | 82 | cfg.target_cpu = "x86" |
| 83 | elseif proc:match("amd64") or proc:match("x86_64") then | 83 | elseif proc:match("amd64") or proc:match("x86_64") then |
| @@ -531,7 +531,7 @@ if cfg.platforms.macosx then | |||
| 531 | defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" | 531 | defaults.variables.LIBFLAG = "-bundle -undefined dynamic_lookup -all_load" |
| 532 | defaults.variables.STAT = "/usr/bin/stat" | 532 | defaults.variables.STAT = "/usr/bin/stat" |
| 533 | defaults.variables.STATFLAG = "-f '%A'" | 533 | defaults.variables.STATFLAG = "-f '%A'" |
| 534 | local version = io.popen("sw_vers -productVersion"):read("*l") | 534 | local version = util.popen_read("sw_vers -productVersion") |
| 535 | version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 | 535 | version = tonumber(version and version:match("^[^.]+%.([^.]+)")) or 3 |
| 536 | if version >= 10 then | 536 | if version >= 10 then |
| 537 | version = 8 | 537 | version = 8 |
diff --git a/src/luarocks/util.lua b/src/luarocks/util.lua index c06c8354..8c4bd974 100644 --- a/src/luarocks/util.lua +++ b/src/luarocks/util.lua | |||
| @@ -9,6 +9,20 @@ local util = {} | |||
| 9 | 9 | ||
| 10 | local unpack = unpack or table.unpack | 10 | local unpack = unpack or table.unpack |
| 11 | 11 | ||
| 12 | --- Run a process and read a its output. | ||
| 13 | -- Equivalent to io.popen(cmd):read("*l"), except that it | ||
| 14 | -- closes the fd right away. | ||
| 15 | -- @param cmd string: The command to execute | ||
| 16 | -- @param spec string: "*l" by default, to read a single line. | ||
| 17 | -- May be used to read more, passing, for instance, "*a". | ||
| 18 | -- @return string: the output of the program. | ||
| 19 | function popen_read(cmd, spec) | ||
| 20 | local fd = io.open(cmd) | ||
| 21 | local out = fd:read(spec or "*l") | ||
| 22 | fd:close() | ||
| 23 | return out | ||
| 24 | end | ||
| 25 | |||
| 12 | local scheduled_functions = {} | 26 | local scheduled_functions = {} |
| 13 | local debug = require("debug") | 27 | local debug = require("debug") |
| 14 | 28 | ||
