Mercurial Hosting > luan
changeset 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 | 1fada5587469 |
children | 55b4b077e5cc |
files | core/src/luan/impl/ForStmt.java core/src/luan/modules/IoLuan.java core/src/luan/modules/Utils.java dist/jars/luan-core-trunk.jar dist/jars/luan-logging-trunk.jar dist/jars/luan-lucene-trunk.jar dist/jars/luan-mail-trunk.jar dist/jars/luan-web-trunk.jar dist/scripts/luan.sh dist/scripts/mmake.luan dist/scripts/mmake.sh |
diffstat | 11 files changed, 68 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
diff -r 1fada5587469 -r 97d175772fed core/src/luan/impl/ForStmt.java --- a/core/src/luan/impl/ForStmt.java Sun Oct 05 09:11:10 2014 +0000 +++ b/core/src/luan/impl/ForStmt.java Mon Oct 06 04:07:56 2014 +0000 @@ -22,8 +22,8 @@ } @Override public void eval(LuanStateImpl luan) throws LuanException { - LuanFunction iter = luan.bit(se).checkFunction( iterExpr.eval(luan) ); LuanBit bit = luan.bit(iterExpr.se()); + LuanFunction iter = bit.checkFunction( iterExpr.eval(luan) ); String name = iterExpr.se().text(); try { while(true) {
diff -r 1fada5587469 -r 97d175772fed core/src/luan/modules/IoLuan.java --- a/core/src/luan/modules/IoLuan.java Sun Oct 05 09:11:10 2014 +0000 +++ b/core/src/luan/modules/IoLuan.java Mon Oct 06 04:07:56 2014 +0000 @@ -367,7 +367,7 @@ } public boolean exists() { - return Utils.exists(file); + return file.exists(); } @Override LuanTable table() {
diff -r 1fada5587469 -r 97d175772fed core/src/luan/modules/Utils.java --- a/core/src/luan/modules/Utils.java Sun Oct 05 09:11:10 2014 +0000 +++ b/core/src/luan/modules/Utils.java Mon Oct 06 04:07:56 2014 +0000 @@ -51,7 +51,7 @@ copyAll(in,out); return out.toByteArray(); } - +/* public static boolean exists(File file) { try { return file.exists() && file.getName().equals(file.getCanonicalFile().getName()); @@ -59,12 +59,12 @@ throw new RuntimeException(e); } } - +*/ public static File toFile(String path) { if( path.contains("//") ) return null; File file = new File(path); - return exists(file) ? file : null; + return file.exists() ? file : null; } public static URL toUrl(String path) {
diff -r 1fada5587469 -r 97d175772fed dist/jars/luan-core-trunk.jar Binary file dist/jars/luan-core-trunk.jar has changed
diff -r 1fada5587469 -r 97d175772fed dist/jars/luan-logging-trunk.jar Binary file dist/jars/luan-logging-trunk.jar has changed
diff -r 1fada5587469 -r 97d175772fed dist/jars/luan-lucene-trunk.jar Binary file dist/jars/luan-lucene-trunk.jar has changed
diff -r 1fada5587469 -r 97d175772fed dist/jars/luan-mail-trunk.jar Binary file dist/jars/luan-mail-trunk.jar has changed
diff -r 1fada5587469 -r 97d175772fed dist/jars/luan-web-trunk.jar Binary file dist/jars/luan-web-trunk.jar has changed
diff -r 1fada5587469 -r 97d175772fed dist/scripts/luan.sh --- a/dist/scripts/luan.sh Sun Oct 05 09:11:10 2014 +0000 +++ b/dist/scripts/luan.sh Mon Oct 06 04:07:56 2014 +0000 @@ -1,5 +1,7 @@ +CURRDIR=`pwd` cd `dirname $0`/../.. HOME=`pwd` +cd $CURRDIR . luan-cp.sh $HOME
diff -r 1fada5587469 -r 97d175772fed dist/scripts/mmake.luan --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dist/scripts/mmake.luan Mon Oct 06 04:07:56 2014 +0000 @@ -0,0 +1,54 @@ +import "Table" +import "Io" +import "String" +import "Java" +import "java.util.Date" + +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 <%=Date.new()%> by Mmake + +.SUFFIXES: .java .class + +.java.class: + javac -g -encoding UTF8 $< + +all: <% +end + +mmake(Io.File ".")