1
0
mirror of https://github.com/natnat-mc/moonbuild synced 2026-05-23 19:49:40 +02:00

added calccdeps

This commit is contained in:
Nathan DECHER
2020-09-13 00:51:44 +02:00
parent 8762bc6f41
commit e989098eed
+7 -1
View File
@@ -43,7 +43,7 @@ flatten= (tab) ->
return {tab} if (type tab)!='table' return {tab} if (type tab)!='table'
out={} out={}
for e in *tab for e in *tab
if (type e)=='table' and e[1] if (type e)=='table'
insert out, v for v in *flatten e insert out, v for v in *flatten e
else else
insert out, e insert out, e
@@ -80,6 +80,11 @@ popen= (c, args, mode='r', params={}) ->
print escaped if params.print print escaped if params.print
io.popen escaped, mode 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 -- file matcher
wildcard= (pattern) -> wildcard= (pattern) ->
prefix, suffix=pattern\match '^(.*)%*%*(.*)$' prefix, suffix=pattern\match '^(.*)%*%*(.*)$'
@@ -164,6 +169,7 @@ sortedpairs= (table, cmp) ->
-- command functions -- command functions
:run, :popen :run, :popen
:calccdeps
-- string functions -- string functions
:patsubst, :match, :isglob :patsubst, :match, :isglob