Mercurial Hosting > luan
comparison scripts/mmake.luan @ 308:869d2263de5d
move scripts
git-svn-id: https://luan-java.googlecode.com/svn/trunk@309 21e917c8-12df-6dd8-5cb6-c86387c605b9
author | fschmidt@gmail.com <fschmidt@gmail.com@21e917c8-12df-6dd8-5cb6-c86387c605b9> |
---|---|
date | Tue, 23 Dec 2014 05:48:49 +0000 |
parents | dist/scripts/mmake.luan@073044e3ac03 |
children | fed1893821bf |
comparison
equal
deleted
inserted
replaced
307:4bf49f0a46b3 | 308:869d2263de5d |
---|---|
1 import "luan:Table" | |
2 import "luan:Io" | |
3 import "luan:String" | |
4 import "luan:Time" | |
5 | |
6 compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " ) | |
7 | |
8 function mmake(dir) | |
9 local java = {} | |
10 local dirs = {} | |
11 for _, file in ipairs(dir.children()) do | |
12 local name = file.name() | |
13 if name.match ".java$" ~= nil then | |
14 java[#java+1] = name.sub(1,-6) | |
15 end | |
16 if file.is_directory() and mmake(file) then | |
17 dirs[#dirs+1] = name | |
18 end | |
19 end | |
20 if #java == 0 and #dirs == 0 then | |
21 return false; | |
22 end | |
23 local out = dir.child("Makefile").text_writer() | |
24 out.write( header() ) | |
25 for _, s in ipairs(java) do | |
26 out.write( "\\\n\t\t", s , ".class" ) | |
27 end | |
28 for _, s in ipairs(dirs) do | |
29 out.write( "\n\tcd ", s, "; make all" ) | |
30 end | |
31 out.write "\n\nclean:\n\trm -f *.class\n" | |
32 for _, s in ipairs(dirs) do | |
33 out.write( "\tcd ", s, "; make clean\n" ) | |
34 end | |
35 out.close() | |
36 print(dir.to_string()) | |
37 return true | |
38 end | |
39 | |
40 | |
41 function header() | |
42 return %> | |
43 # Makefile created on <%=Time.format(Time.now())%> by Mmake | |
44 | |
45 .SUFFIXES: .java .class | |
46 | |
47 .java.class: | |
48 <%=compiler%> $< | |
49 | |
50 all: <% | |
51 end | |
52 | |
53 mmake(Io.schemes.file ".") |