added calccdeps

alfons-task
Nathan DECHER 4 years ago
parent 8762bc6f41
commit e989098eed
  1. 8
      util.moon

@ -43,7 +43,7 @@ flatten= (tab) ->
return {tab} if (type tab)!='table'
out={}
for e in *tab
if (type e)=='table' and e[1]
if (type e)=='table'
insert out, v for v in *flatten e
else
insert out, e
@ -80,6 +80,11 @@ popen= (c, args, mode='r', params={}) ->
print escaped if params.print
io.popen escaped, mode
calccdeps= (infile, includesys=false) ->
data=(popen 'cc', {includesys and '-M' or '-MM', infile})\read '*a'
rawdeps=data\gsub('\\\n', '')\match ':(.+)'
[dep for dep in rawdeps\gmatch '%S+' when dep!=infile]
-- file matcher
wildcard= (pattern) ->
prefix, suffix=pattern\match '^(.*)%*%*(.*)$'
@ -164,6 +169,7 @@ sortedpairs= (table, cmp) ->
-- command functions
:run, :popen
:calccdeps
-- string functions
:patsubst, :match, :isglob

Loading…
Cancel
Save