diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/mmake.luan	Tue Dec 23 05:48:49 2014 +0000
@@ -0,0 +1,53 @@
+import "luan:Table"
+import "luan:Io"
+import "luan:String"
+import "luan:Time"
+
+compiler = Table.concat( { "javac -g -encoding UTF8", ... }, " " )
+
+function mmake(dir)
+	local java = {}
+	local dirs = {}
+	for _, file in ipairs(dir.children()) do
+		local name = file.name()
+		if name.match ".java$" ~= nil then
+			java[#java+1] = name.sub(1,-6)
+		end
+		if file.is_directory() and mmake(file) then
+			dirs[#dirs+1] = name
+		end
+	end
+	if #java == 0 and #dirs == 0 then
+		return false;
+	end
+	local out = dir.child("Makefile").text_writer()
+	out.write( header() )
+	for _, s in ipairs(java) 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 ".")