From 02dd4e1301ea11d60be2e36d66392d367c8e2c5b Mon Sep 17 00:00:00 2001 From: Hisham Date: Wed, 19 Oct 2016 15:18:37 -0400 Subject: Add format-check function in rockspec table. This avoids sprinkling the luarocks.deps dependency everywhere. --- src/luarocks/build.lua | 4 ++-- src/luarocks/build/cmake.lua | 3 +-- src/luarocks/fetch.lua | 7 ++++--- src/luarocks/fetch/git.lua | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 1d2925f9..790efef8 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua @@ -161,7 +161,7 @@ local function check_macosx_deployment_target(rockspec) rockspec.variables[var] = "env MACOSX_DEPLOYMENT_TARGET="..target.." "..rockspec.variables[var] end end - if cfg.platforms.macosx and deps.format_is_at_least(rockspec, "3.0") and target then + if cfg.platforms.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) @@ -431,7 +431,7 @@ function build.command(flags, name, version) if not ok then return nil, err, cfg.errorcodes.PERMISSIONDENIED end ok, err = do_build(name, version, deps.get_deps_mode(flags), flags["only-deps"]) if not ok then return nil, err end - local name, version = ok, err + name, version = ok, err if flags["only-deps"] then return name, version end diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.lua index 43702979..8ee6b6b2 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.lua @@ -5,7 +5,6 @@ local cmake = {} local fs = require("luarocks.fs") local util = require("luarocks.util") local cfg = require("luarocks.core.cfg") -local deps = require("luarocks.deps") --- Driver function for the "cmake" build back-end. -- @param rockspec table: the loaded rockspec. @@ -54,7 +53,7 @@ function cmake.run(rockspec) end local do_build, do_install - if deps.format_is_at_least(rockspec, "3.0") then + if rockspec:format_is_at_least("3.0") then do_build = (build.build_pass == nil) and true or build.build_pass do_install = (build.install_pass == nil) and true or build.install_pass else diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 9bf1922a..37db78f4 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -208,6 +208,7 @@ function fetch.load_local_rockspec(filename, quick) return nil, "Rockspec format "..rockspec.rockspec_format.." is not supported, please upgrade LuaRocks." end end + rockspec.format_is_at_least = deps.format_is_at_least util.platform_overrides(rockspec.build) util.platform_overrides(rockspec.dependencies) @@ -247,12 +248,12 @@ function fetch.load_local_rockspec(filename, quick) rockspec.source.dir = rockspec.source.dir or rockspec.source.module or ( (filebase:match("%.lua$") or filebase:match("%.c$")) - and (deps.format_is_at_least(rockspec, "3.0") + and (rockspec:format_is_at_least("3.0") and (fetch.is_basic_protocol(protocol) and "." or base) or ".") ) or base - rockspec.rocks_provided = (deps.format_is_at_least(rockspec, "3.0") + rockspec.rocks_provided = (rockspec:format_is_at_least("3.0") and cfg.rocks_provided_3_0 or cfg.rocks_provided) @@ -363,7 +364,7 @@ function fetch.get_sources(rockspec, extract, dest_dir) -- with rockspecs newer than 3.0. local dir_count, found_dir = 0 - if not rockspec.source.dir_set and deps.format_is_at_least(rockspec, "3.0") then + if not rockspec.source.dir_set and rockspec:format_is_at_least("3.0") then local files = fs.list_dir() for _, f in ipairs(files) do if fs.is_dir(f) then diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index eaba7ffd..72da4974 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua @@ -110,7 +110,7 @@ function git.get_sources(rockspec, extract, dest_dir, depth) end -- Fetching git submodules is supported only when rockspec format is >= 3.0. - if deps.format_is_at_least(rockspec, "3.0") then + if rockspec:format_is_at_least("3.0") then command = {fs.Q(git_cmd), "submodule", "update", "--init", "--recursive"} if git_supports_shallow_submodules(git_cmd) then -- cgit v1.2.3-55-g6feb