mirror of
https://github.com/natnat-mc/moonbuild
synced 2026-05-25 02:49:39 +02:00
min and max were broken, fixed them
This commit is contained in:
+20
-13
@@ -127,12 +127,11 @@ class BuildObject
|
|||||||
for i=1, #@outs
|
for i=1, #@outs
|
||||||
return true if not otimes[i]
|
return true if not otimes[i]
|
||||||
|
|
||||||
(max itimes)>=(min otimes)
|
(max itimes)>(min otimes)
|
||||||
|
|
||||||
error "Need Lua >=5.2" if setfenv
|
error "Need Lua >=5.2" if setfenv
|
||||||
|
|
||||||
targets = {}
|
local targets, defaulttarget
|
||||||
defaulttarget = 'all'
|
|
||||||
|
|
||||||
buildscope =
|
buildscope =
|
||||||
default: (target) ->
|
default: (target) ->
|
||||||
@@ -158,14 +157,25 @@ setmetatable buildscope,
|
|||||||
return global if global
|
return global if global
|
||||||
(...) -> Command k, ...
|
(...) -> Command k, ...
|
||||||
|
|
||||||
file = first {'Build.moon', 'Buildfile.moon', 'Build', 'Buildfile'}, exists
|
loadtargets = ->
|
||||||
error "No Build.moon or Buildfile found" unless file
|
targets = {}
|
||||||
buildfn = loadwithscope file, buildscope
|
defaulttarget = 'all'
|
||||||
error "Failed to load build function" unless buildfn
|
file = first {'Build.moon', 'Buildfile.moon', 'Build', 'Buildfile'}, exists
|
||||||
ok, err = pcall buildfn
|
error "No Build.moon or Buildfile found" unless file
|
||||||
|
buildfn = loadwithscope file, buildscope
|
||||||
|
error "Failed to load build function" unless buildfn
|
||||||
|
buildfn!
|
||||||
|
|
||||||
|
buildtargets = ->
|
||||||
|
if #args.targets==0
|
||||||
|
BuildObject\build defaulttarget
|
||||||
|
for target in *args.targets
|
||||||
|
BuildObject\build target
|
||||||
|
|
||||||
|
ok, err = pcall loadtargets
|
||||||
unless ok
|
unless ok
|
||||||
if err
|
if err
|
||||||
io.stderr\write err, '\n'
|
io.stderr\write "Error while loading build file: ", err, '\n'
|
||||||
else
|
else
|
||||||
io.stderr\write "Unknown error\n"
|
io.stderr\write "Unknown error\n"
|
||||||
os.exit 1
|
os.exit 1
|
||||||
@@ -197,7 +207,4 @@ if args.deps
|
|||||||
io.write "\n"
|
io.write "\n"
|
||||||
os.exit 0
|
os.exit 0
|
||||||
|
|
||||||
if #args.targets==0
|
buildtargets!
|
||||||
BuildObject\build defaulttarget
|
|
||||||
for target in *args.targets
|
|
||||||
BuildObject\build target
|
|
||||||
|
|||||||
+35
-26
@@ -394,7 +394,7 @@ min = function(table, cmp)
|
|||||||
local val = table[1]
|
local val = table[1]
|
||||||
for i = 2, #table do
|
for i = 2, #table do
|
||||||
local elem = table[i]
|
local elem = table[i]
|
||||||
if cmp(val, elem) then
|
if cmp(elem, val) then
|
||||||
val = elem
|
val = elem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -410,7 +410,7 @@ max = function(table, cmp)
|
|||||||
local val = table[1]
|
local val = table[1]
|
||||||
for i = 2, #table do
|
for i = 2, #table do
|
||||||
local elem = table[i]
|
local elem = table[i]
|
||||||
if not cmp(val, elem) then
|
if not cmp(elem, val) then
|
||||||
val = elem
|
val = elem
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -959,7 +959,7 @@ do
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return (max(itimes)) >= (min(otimes))
|
return (max(itimes)) > (min(otimes))
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
_base_0.__index = _base_0
|
_base_0.__index = _base_0
|
||||||
@@ -1034,8 +1034,7 @@ end
|
|||||||
if setfenv then
|
if setfenv then
|
||||||
error("Need Lua >=5.2")
|
error("Need Lua >=5.2")
|
||||||
end
|
end
|
||||||
local targets = { }
|
local targets, defaulttarget
|
||||||
local defaulttarget = 'all'
|
|
||||||
local buildscope = {
|
local buildscope = {
|
||||||
default = function(target)
|
default = function(target)
|
||||||
defaulttarget = target.name
|
defaulttarget = target.name
|
||||||
@@ -1073,23 +1072,40 @@ setmetatable(buildscope, {
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
local file = first({
|
local loadtargets
|
||||||
'Build.moon',
|
loadtargets = function()
|
||||||
'Buildfile.moon',
|
targets = { }
|
||||||
'Build',
|
defaulttarget = 'all'
|
||||||
'Buildfile'
|
local file = first({
|
||||||
}, exists)
|
'Build.moon',
|
||||||
if not (file) then
|
'Buildfile.moon',
|
||||||
error("No Build.moon or Buildfile found")
|
'Build',
|
||||||
|
'Buildfile'
|
||||||
|
}, exists)
|
||||||
|
if not (file) then
|
||||||
|
error("No Build.moon or Buildfile found")
|
||||||
|
end
|
||||||
|
local buildfn = loadwithscope(file, buildscope)
|
||||||
|
if not (buildfn) then
|
||||||
|
error("Failed to load build function")
|
||||||
|
end
|
||||||
|
return buildfn()
|
||||||
end
|
end
|
||||||
local buildfn = loadwithscope(file, buildscope)
|
local buildtargets
|
||||||
if not (buildfn) then
|
buildtargets = function()
|
||||||
error("Failed to load build function")
|
if #args.targets == 0 then
|
||||||
|
BuildObject:build(defaulttarget)
|
||||||
|
end
|
||||||
|
local _list_0 = args.targets
|
||||||
|
for _index_0 = 1, #_list_0 do
|
||||||
|
local target = _list_0[_index_0]
|
||||||
|
BuildObject:build(target)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
local ok, err = pcall(buildfn)
|
local ok, err = pcall(loadtargets)
|
||||||
if not (ok) then
|
if not (ok) then
|
||||||
if err then
|
if err then
|
||||||
io.stderr:write(err, '\n')
|
io.stderr:write("Error while loading build file: ", err, '\n')
|
||||||
else
|
else
|
||||||
io.stderr:write("Unknown error\n")
|
io.stderr:write("Unknown error\n")
|
||||||
end
|
end
|
||||||
@@ -1130,11 +1146,4 @@ if args.deps then
|
|||||||
end
|
end
|
||||||
os.exit(0)
|
os.exit(0)
|
||||||
end
|
end
|
||||||
if #args.targets == 0 then
|
return buildtargets()
|
||||||
BuildObject:build(defaulttarget)
|
|
||||||
end
|
|
||||||
local _list_0 = args.targets
|
|
||||||
for _index_0 = 1, #_list_0 do
|
|
||||||
local target = _list_0[_index_0]
|
|
||||||
BuildObject:build(target)
|
|
||||||
end
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ min = (table, cmp=(a, b) -> a<b) ->
|
|||||||
val = table[1]
|
val = table[1]
|
||||||
for i=2, #table
|
for i=2, #table
|
||||||
elem = table[i]
|
elem = table[i]
|
||||||
if cmp val, elem
|
if cmp elem, val
|
||||||
val = elem
|
val = elem
|
||||||
val
|
val
|
||||||
|
|
||||||
@@ -20,7 +20,7 @@ max = (table, cmp=(a, b) -> a<b) ->
|
|||||||
val = table[1]
|
val = table[1]
|
||||||
for i=2, #table
|
for i=2, #table
|
||||||
elem = table[i]
|
elem = table[i]
|
||||||
if not cmp val, elem
|
if not cmp elem, val
|
||||||
val = elem
|
val = elem
|
||||||
val
|
val
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user