mirror of
https://codeberg.org/1414codeforge/yui.git
synced 2024-12-23 00:48:28 +01:00
[crush] Update crush.lua to latest version.
This commit is contained in:
parent
432e913f4b
commit
4d2083d143
59
crush.lua
59
crush.lua
@ -1,13 +1,39 @@
|
||||
--- Crush
|
||||
--
|
||||
-- The uncomplicated dependency system for LÖVE.
|
||||
--
|
||||
-- @module crush
|
||||
-- @copyright 2022 The DoubleFourteen Code Forge
|
||||
-- @author Lorenzo Cogotti
|
||||
-- @author Andrea Pasquini
|
||||
--
|
||||
--- crush - The uncomplicated dependency system for LÖVE.
|
||||
--
|
||||
-- Author: Lorenzo Cogotti
|
||||
-- Copyright: 2022 The DoubleFourteen Code Forge
|
||||
-- License: MIT (see LICENSE file for details)
|
||||
|
||||
local io = require 'io'
|
||||
local os = require 'os'
|
||||
|
||||
-- Lua version check
|
||||
|
||||
local function check_version()
|
||||
-- Generic Lua version check - 5.2 required
|
||||
if _VERSION then
|
||||
local maj, min = _VERSION:match("Lua (%d+)%.(%d+)")
|
||||
|
||||
if maj and min then
|
||||
maj, min = tonumber(maj), tonumber(min)
|
||||
if maj > 5 or (maj == 5 and min >= 2) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- LuaJIT check - 2.0.0 required (technically 2.0.0_beta11)
|
||||
if jit and jit.version_num and jit.version_num >= 20000 then
|
||||
return true
|
||||
end
|
||||
|
||||
return false
|
||||
end
|
||||
|
||||
if not check_version() then
|
||||
error("Unsupported Lua version!\nSorry, crush requires Lua 5.2 or LuaJIT 2.0.0.")
|
||||
end
|
||||
|
||||
-- System specific functions
|
||||
--
|
||||
-- Portions of this code are based on work from the LuaRocks project.
|
||||
@ -16,11 +42,6 @@
|
||||
-- LuaRocks website: https://luarocks.org
|
||||
-- LuaRocks sources: https://github.com/luarocks/luarocks
|
||||
|
||||
local io = require 'io'
|
||||
local os = require 'os'
|
||||
|
||||
|
||||
|
||||
local is_windows = package.config:sub(1,1) == "\\"
|
||||
|
||||
local is_directory
|
||||
@ -30,10 +51,6 @@ local chdir
|
||||
local mkdir
|
||||
|
||||
if is_windows then
|
||||
-- ---------------
|
||||
-- NOTE: untested!
|
||||
-- ---------------
|
||||
|
||||
-- local
|
||||
function is_directory(path)
|
||||
local fh, _, code = io.open(path, 'r')
|
||||
@ -184,7 +201,11 @@ local function fetch(dep)
|
||||
fullcmd = chdir("lib", quiet(cmd))
|
||||
end
|
||||
|
||||
if not os.execute(fullcmd) then
|
||||
-- On success, os.execute() returns:
|
||||
-- true on regular Lua
|
||||
-- 0 on LuaJIT (actual OS error code)
|
||||
local code = os.execute(fullcmd)
|
||||
if code ~= true and code ~= 0 then
|
||||
error(dep.name..": Dependency fetch failed ("..cmd..").")
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user