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