Mercurial Hosting > luan
comparison scripts/mmake.luan @ 320:fed1893821bf
remove global namespace
git-svn-id: https://luan-java.googlecode.com/svn/trunk@321 21e917c8-12df-6dd8-5cb6-c86387c605b9
| author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
|---|---|
| date | Fri, 06 Feb 2015 21:54:41 +0000 |
| parents | 869d2263de5d |
| children | 7f7708e8fdd4 |
comparison
equal
deleted
inserted
replaced
| 319:f6db49c294a7 | 320:fed1893821bf |
|---|---|
| 1 import "luan:Luan" | |
| 1 import "luan:Table" | 2 import "luan:Table" |
| 2 import "luan:Io" | 3 import "luan:Io" |
| 3 import "luan:String" | 4 import "luan:String" |
| 4 import "luan:Time" | 5 import "luan:Time" |
| 5 | 6 |
| 7 local ipairs = Luan.ipairs | |
| 8 local print = Io.print | |
| 9 | |
| 10 | |
| 6 compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " ) | 11 compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " ) |
| 7 | 12 |
| 8 function mmake(dir) | 13 function mmake(dir) |
| 9 local java = {} | 14 local javas = {} |
| 10 local dirs = {} | 15 local dirs = {} |
| 11 for _, file in ipairs(dir.children()) do | 16 for _, file in ipairs(dir.children()) do |
| 12 local name = file.name() | 17 local name = file.name() |
| 13 if name.match ".java$" ~= nil then | 18 if name.match ".java$" ~= nil then |
| 14 java[#java+1] = name.sub(1,-6) | 19 javas[#javas+1] = name.sub(1,-6) |
| 15 end | 20 end |
| 16 if file.is_directory() and mmake(file) then | 21 if file.is_directory() and mmake(file) then |
| 17 dirs[#dirs+1] = name | 22 dirs[#dirs+1] = name |
| 18 end | 23 end |
| 19 end | 24 end |
| 20 if #java == 0 and #dirs == 0 then | 25 if #javas == 0 and #dirs == 0 then |
| 21 return false; | 26 return false; |
| 22 end | 27 end |
| 23 local out = dir.child("Makefile").text_writer() | 28 local out = dir.child("Makefile").text_writer() |
| 24 out.write( header() ) | 29 out.write( header() ) |
| 25 for _, s in ipairs(java) do | 30 for _, s in ipairs(javas) do |
| 26 out.write( "\\\n\t\t", s , ".class" ) | 31 out.write( "\\\n\t\t", s , ".class" ) |
| 27 end | 32 end |
| 28 for _, s in ipairs(dirs) do | 33 for _, s in ipairs(dirs) do |
| 29 out.write( "\n\tcd ", s, "; make all" ) | 34 out.write( "\n\tcd ", s, "; make all" ) |
| 30 end | 35 end |
