Mercurial Hosting > luan
comparison core/src/luan/modules/mmake.luan @ 348:6fd016d35ec1 0.2
improve Hosting and fix mmake
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 12 Apr 2015 08:35:23 -0600 |
| parents | scripts/mmake.luan@7f7708e8fdd4 |
| children | 92c3d22745b8 |
comparison
equal
deleted
inserted
replaced
| 347:612a283b3d14 | 348:6fd016d35ec1 |
|---|---|
| 1 local Luan = require "luan:Luan" | |
| 2 local ipairs = Luan.ipairs | |
| 3 local Table = require "luan:Table" | |
| 4 local Io = require "luan:Io" | |
| 5 local print = Io.print | |
| 6 local String = require "luan:String" | |
| 7 local Time = require "luan:Time" | |
| 8 | |
| 9 | |
| 10 compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " ) | |
| 11 | |
| 12 function mmake(dir) | |
| 13 local javas = {} | |
| 14 local dirs = {} | |
| 15 for _, file in ipairs(dir.children()) do | |
| 16 local name = file.name() | |
| 17 if name.match ".java$" ~= nil then | |
| 18 javas[#javas+1] = name.sub(1,-6) | |
| 19 end | |
| 20 if file.is_directory() and mmake(file) then | |
| 21 dirs[#dirs+1] = name | |
| 22 end | |
| 23 end | |
| 24 if #javas == 0 and #dirs == 0 then | |
| 25 return false; | |
| 26 end | |
| 27 local out = dir.child("Makefile").text_writer() | |
| 28 out.write( header() ) | |
| 29 for _, s in ipairs(javas) do | |
| 30 out.write( "\\\n\t\t", s , ".class" ) | |
| 31 end | |
| 32 for _, s in ipairs(dirs) do | |
| 33 out.write( "\n\tcd ", s, "; make all" ) | |
| 34 end | |
| 35 out.write "\n\nclean:\n\trm -f *.class\n" | |
| 36 for _, s in ipairs(dirs) do | |
| 37 out.write( "\tcd ", s, "; make clean\n" ) | |
| 38 end | |
| 39 out.close() | |
| 40 print(dir.to_string()) | |
| 41 return true | |
| 42 end | |
| 43 | |
| 44 | |
| 45 function header() | |
| 46 return %> | |
| 47 # Makefile created on <%=Time.format(Time.now())%> by Mmake | |
| 48 | |
| 49 .SUFFIXES: .java .class | |
| 50 | |
| 51 .java.class: | |
| 52 <%=compiler%> $< | |
| 53 | |
| 54 all: <% | |
| 55 end | |
| 56 | |
| 57 mmake(Io.schemes.file ".") |
