Mercurial Hosting > luan
view scripts/mmake.luan @ 333:2b72947d421a
README.md edited online with Bitbucket
author | Hugo Teixeira <hugo.tech@gmail.com> |
---|---|
date | Wed, 25 Mar 2015 04:27:56 +0000 |
parents | 7f7708e8fdd4 |
children |
line wrap: on
line source
local Luan = require "luan:Luan" local ipairs = Luan.ipairs local Table = require "luan:Table" local Io = require "luan:Io" local print = Io.print local String = require "luan:String" local Time = require "luan:Time" compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " ) function mmake(dir) local javas = {} local dirs = {} for _, file in ipairs(dir.children()) do local name = file.name() if name.match ".java$" ~= nil then javas[#javas+1] = name.sub(1,-6) end if file.is_directory() and mmake(file) then dirs[#dirs+1] = name end end if #javas == 0 and #dirs == 0 then return false; end local out = dir.child("Makefile").text_writer() out.write( header() ) for _, s in ipairs(javas) do out.write( "\\\n\t\t", s , ".class" ) end for _, s in ipairs(dirs) do out.write( "\n\tcd ", s, "; make all" ) end out.write "\n\nclean:\n\trm -f *.class\n" for _, s in ipairs(dirs) do out.write( "\tcd ", s, "; make clean\n" ) end out.close() print(dir.to_string()) return true end function header() return %> # Makefile created on <%=Time.format(Time.now())%> by Mmake .SUFFIXES: .java .class .java.class: <%=compiler%> $< all: <% end mmake(Io.schemes.file ".")