assorted-commits Mailing List for Assorted projects (Page 58)
Brought to you by:
yangzhang
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(9) |
Dec
(12) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(86) |
Feb
(265) |
Mar
(96) |
Apr
(47) |
May
(136) |
Jun
(28) |
Jul
(57) |
Aug
(42) |
Sep
(20) |
Oct
(67) |
Nov
(37) |
Dec
(34) |
2009 |
Jan
(39) |
Feb
(85) |
Mar
(96) |
Apr
(24) |
May
(82) |
Jun
(13) |
Jul
(10) |
Aug
(8) |
Sep
(2) |
Oct
(20) |
Nov
(31) |
Dec
(17) |
2010 |
Jan
(16) |
Feb
(11) |
Mar
(17) |
Apr
(53) |
May
(31) |
Jun
(13) |
Jul
(3) |
Aug
(6) |
Sep
(11) |
Oct
(4) |
Nov
(17) |
Dec
(17) |
2011 |
Jan
(3) |
Feb
(19) |
Mar
(5) |
Apr
(17) |
May
(3) |
Jun
(4) |
Jul
(14) |
Aug
(3) |
Sep
(2) |
Oct
(1) |
Nov
(3) |
Dec
(2) |
2012 |
Jan
(3) |
Feb
(7) |
Mar
(1) |
Apr
|
May
(1) |
Jun
|
Jul
(4) |
Aug
(5) |
Sep
(2) |
Oct
(3) |
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
(9) |
Apr
(5) |
May
|
Jun
(2) |
Jul
(1) |
Aug
(10) |
Sep
(1) |
Oct
(2) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
(3) |
Mar
(3) |
Apr
(1) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
(2) |
Oct
|
Nov
|
Dec
|
2015 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2016 |
Jan
(1) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
(5) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(2) |
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <yan...@us...> - 2008-02-22 19:25:30
|
Revision: 477 http://assorted.svn.sourceforge.net/assorted/?rev=477&view=rev Author: yangzhang Date: 2008-02-22 11:25:34 -0800 (Fri, 22 Feb 2008) Log Message: ----------- added some tests Added Paths: ----------- simple-build/trunk/test/ simple-build/trunk/test/cpp/ simple-build/trunk/test/cpp/build simple-build/trunk/test/cpp/myapp.cc simple-build/trunk/test/java/ simple-build/trunk/test/java/MyApp.java simple-build/trunk/test/java/build simple-build/trunk/test/scala/ simple-build/trunk/test/scala/MyApp.scala simple-build/trunk/test/scala/build Added: simple-build/trunk/test/cpp/build =================================================================== --- simple-build/trunk/test/cpp/build (rev 0) +++ simple-build/trunk/test/cpp/build 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,2 @@ +myapp: + srcs: [myapp.cc] Added: simple-build/trunk/test/cpp/myapp.cc =================================================================== --- simple-build/trunk/test/cpp/myapp.cc (rev 0) +++ simple-build/trunk/test/cpp/myapp.cc 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,10 @@ +#include <iostream> + +using namespace std; + +int +main() +{ + cout << "hello, world!" << endl; + return 0; +} Added: simple-build/trunk/test/java/MyApp.java =================================================================== --- simple-build/trunk/test/java/MyApp.java (rev 0) +++ simple-build/trunk/test/java/MyApp.java 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,5 @@ +public class MyApp { + public static void main(String[] args) { + System.out.println("hello, world!"); + } +} Added: simple-build/trunk/test/java/build =================================================================== --- simple-build/trunk/test/java/build (rev 0) +++ simple-build/trunk/test/java/build 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,3 @@ +myapp: + srcs: [MyApp.java] + mainclass: MyApp Added: simple-build/trunk/test/scala/MyApp.scala =================================================================== --- simple-build/trunk/test/scala/MyApp.scala (rev 0) +++ simple-build/trunk/test/scala/MyApp.scala 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,5 @@ +object MyApp { + def main(args: Array[String]) { + println("hello, world!") + } +} Added: simple-build/trunk/test/scala/build =================================================================== --- simple-build/trunk/test/scala/build (rev 0) +++ simple-build/trunk/test/scala/build 2008-02-22 19:25:34 UTC (rev 477) @@ -0,0 +1,3 @@ +myapp: + srcs: [MyApp.scala] + mainclass: MyApp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-21 19:54:30
|
Revision: 476 http://assorted.svn.sourceforge.net/assorted/?rev=476&view=rev Author: yangzhang Date: 2008-02-21 11:54:29 -0800 (Thu, 21 Feb 2008) Log Message: ----------- added start of rand-dist Added Paths: ----------- rand-dist/ rand-dist/trunk/ rand-dist/trunk/src/ rand-dist/trunk/src/Makefile rand-dist/trunk/src/randdist.cc Added: rand-dist/trunk/src/Makefile =================================================================== --- rand-dist/trunk/src/Makefile (rev 0) +++ rand-dist/trunk/src/Makefile 2008-02-21 19:54:29 UTC (rev 476) @@ -0,0 +1,2 @@ +CFLAGS := -Wall -O3 +all: randdist Added: rand-dist/trunk/src/randdist.cc =================================================================== --- rand-dist/trunk/src/randdist.cc (rev 0) +++ rand-dist/trunk/src/randdist.cc 2008-02-21 19:54:29 UTC (rev 476) @@ -0,0 +1,25 @@ +#include <iostream> +#include <vector> +#include <commons/rand.h> + +using namespace std; +using namespace commons; + +int +main(int argc, char **argv) +{ + if (argc < 3) { + fprintf(stderr, "randdist SIZE COUNT\n"); + return 1; + } + + const int size = atoi(argv[1]); + const int count = atoi(argv[2]); + + vector<int> xs(size); + for (int i = 0; i < count; i++) { + xs[i] = r(); + } + + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-21 11:19:25
|
Revision: 475 http://assorted.svn.sourceforge.net/assorted/?rev=475&view=rev Author: yangzhang Date: 2008-02-21 02:47:39 -0800 (Thu, 21 Feb 2008) Log Message: ----------- added rng from rtm's code Added Paths: ----------- cpp-commons/trunk/src/commons/rand.h Added: cpp-commons/trunk/src/commons/rand.h =================================================================== --- cpp-commons/trunk/src/commons/rand.h (rev 0) +++ cpp-commons/trunk/src/commons/rand.h 2008-02-21 10:47:39 UTC (rev 475) @@ -0,0 +1,21 @@ +#ifndef COMMONS_RAND_H_ +#define COMMONS_RAND_H_ + +namespace commons +{ + /** + * TODO: Identify and rename this RNG. + */ + class posix_rand { + private: + unsigned long randx; + public: + posix_rand(long s = 0) { randx = s; } + void seed(long s) { randx = s; } + long abs(long x) { return x & 0x7fffffff; } + long draw() { return randx = randx * 1103515245 + 12345; } + long operator()() { return abs(draw()); } + }; +} + +#endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-20 18:27:50
|
Revision: 474 http://assorted.svn.sourceforge.net/assorted/?rev=474&view=rev Author: yangzhang Date: 2008-02-20 10:27:44 -0800 (Wed, 20 Feb 2008) Log Message: ----------- added more redir Modified Paths: -------------- personal-site/trunk/Makefile Modified: personal-site/trunk/Makefile =================================================================== --- personal-site/trunk/Makefile 2008-02-19 09:09:41 UTC (rev 473) +++ personal-site/trunk/Makefile 2008-02-20 18:27:44 UTC (rev 474) @@ -40,6 +40,7 @@ scp $(REDIR) cs:public_html/ scp $(REDIR) ocf:public_html/ scp $(REDIR) pdos:public_html/ + scp $(REDIR) lin:web_scripts/ clean: rm -rf out This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-19 09:09:36
|
Revision: 473 http://assorted.svn.sourceforge.net/assorted/?rev=473&view=rev Author: yangzhang Date: 2008-02-19 01:09:41 -0800 (Tue, 19 Feb 2008) Log Message: ----------- fixed simplebuild path Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2008-02-19 07:03:19 UTC (rev 472) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2008-02-19 09:09:41 UTC (rev 473) @@ -99,7 +99,7 @@ # my own export SCALA_COMMONS_SRC="$HOME/scom/.." -export SIMPLEBUILD="$GLOBAL_PREFIX/share/simple-build/build-templates" +export SIMPLEBUILD="$GLOBAL_PREFIX/share/simple-build" export CVS_RSH=ssh export EDITOR=vim This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-19 07:03:14
|
Revision: 472 http://assorted.svn.sourceforge.net/assorted/?rev=472&view=rev Author: yangzhang Date: 2008-02-18 23:03:19 -0800 (Mon, 18 Feb 2008) Log Message: ----------- ready to run in josmp Modified Paths: -------------- nano-httpd/trunk/src/nanohttpd.cc Modified: nano-httpd/trunk/src/nanohttpd.cc =================================================================== --- nano-httpd/trunk/src/nanohttpd.cc 2008-02-19 06:45:50 UTC (rev 471) +++ nano-httpd/trunk/src/nanohttpd.cc 2008-02-19 07:03:19 UTC (rev 472) @@ -52,33 +52,33 @@ do { \ char b_[4096]; \ int n_ = snprintf(b_, sizeof(b_), __VA_ARGS__); \ - if (send(s, b_, n_, 0) == 0) panic("XXX"); \ + if (lwip_send(s, b_, n_, 0) == -1) panic("XXX"); \ } while (0); #define SERVER "webserver/1.0" #define PROTOCOL "HTTP/1.0" #define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT" -#define PORT 80 +#define PORT 8000 // XXX void send_headers(int f, int status, char *title, char *extra, char *mime, - int length, time_t date) + int length, int date) { - time_t now; - char timebuf[128]; + //time_t now; + //char timebuf[128]; nprintf(f, "%s %d %s\r\n", PROTOCOL, status, title); nprintf(f, "Server: %s\r\n", SERVER); - now = time(NULL); - strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now)); - nprintf(f, "Date: %s\r\n", timebuf); + //now = time(NULL); + //strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now)); + //nprintf(f, "Date: %s\r\n", timebuf); if (extra) nprintf(f, "%s\r\n", extra); if (mime) nprintf(f, "Content-Type: %s\r\n", mime); if (length >= 0) nprintf(f, "Content-Length: %d\r\n", length); - if (date != -1) - { - strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&date)); - nprintf(f, "Last-Modified: %s\r\n", timebuf); - } + //if (date != -1) + //{ + // strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&date)); + // nprintf(f, "Last-Modified: %s\r\n", timebuf); + //} nprintf(f, "Connection: close\r\n"); nprintf(f, "\r\n"); } @@ -95,6 +95,9 @@ // XXX void send_file(int f, char *path) { + char msg[] = "hello, world!\n"; + send_headers(f, 200, "OK", NULL, "text/plain", sizeof(msg), -1); + if (lwip_send(f, msg, sizeof(msg), 0) == -1) panic("XXX"); // char data[4096]; // int n; // @@ -122,7 +125,7 @@ // char pathbuf[4096]; // int len; - if (recv(f, buf, sizeof(buf), MSG_WAITALL) < 0) return -1; + if (lwip_recv(f, buf, sizeof(buf), 0) < 0) return -1; printf("URL: %s", buf); method = strtok(buf, " "); @@ -200,10 +203,16 @@ int s = lwip_socket(PF_INET, SOCK_STREAM, 0); if (s < 0) panic("XXX"); +#if STANDALONE + int on = 1; + if (setsockopt(s, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0) + panic("XXX"); +#endif + struct sockaddr_in sa; bzero(&sa, sizeof(sa));; sa.sin_family = AF_INET; - sa.sin_port = htons(8000); + sa.sin_port = htons(PORT); sa.sin_addr.s_addr = htonl(INADDR_ANY); cprintf("bind\n"); @@ -218,6 +227,7 @@ cprintf("processing\n"); if (process(t) < 0) panic("XXX"); + lwip_close(t); } return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-19 06:45:46
|
Revision: 471 http://assorted.svn.sourceforge.net/assorted/?rev=471&view=rev Author: yangzhang Date: 2008-02-18 22:45:50 -0800 (Mon, 18 Feb 2008) Log Message: ----------- added nano httpd (a ripoff of the sanos example web server) Added Paths: ----------- nano-httpd/ nano-httpd/trunk/ nano-httpd/trunk/README nano-httpd/trunk/src/ nano-httpd/trunk/src/Makefile nano-httpd/trunk/src/nanohttpd.cc Added: nano-httpd/trunk/README =================================================================== --- nano-httpd/trunk/README (rev 0) +++ nano-httpd/trunk/README 2008-02-19 06:45:50 UTC (rev 471) @@ -0,0 +1 @@ +janky little web server Added: nano-httpd/trunk/src/Makefile =================================================================== --- nano-httpd/trunk/src/Makefile (rev 0) +++ nano-httpd/trunk/src/Makefile 2008-02-19 06:45:50 UTC (rev 471) @@ -0,0 +1,8 @@ +all: nanohttpd +nanohttpd: nanohttpd.cc + g++ -Wall -g3 -o $@ $< +run: nanohttpd + ./nanohttpd +clean: + rm -f nanohttpd +.PHONY: clean run Added: nano-httpd/trunk/src/nanohttpd.cc =================================================================== --- nano-httpd/trunk/src/nanohttpd.cc (rev 0) +++ nano-httpd/trunk/src/nanohttpd.cc 2008-02-19 06:45:50 UTC (rev 471) @@ -0,0 +1,223 @@ +// Derived from: +// +// http://www.jbox.dk/sanos/webserver.htm +// +// Example HTTP request +// +// GET / HTTP/1.1 +// User-Agent: Opera/9.25 (Windows NT 5.1; U; en) +// Host: harvard:8000 +// Accept: text/html, application/xml;q=0.9, application/xhtml+xml, image/png, image/jpeg, image/gif, image/x-xbitmap, */*;q=0.1 +// Accept-Language: en-US,en;q=0.9 +// Accept-Charset: iso-8859-1, utf-8, utf-16, *;q=0.1 +// Accept-Encoding: deflate, gzip, x-gzip, identity, *;q=0 +// Connection: Keep-Alive + +#define STANDALONE 1 + +extern "C" { +#include <sys/types.h> +#include <sys/socket.h> +#include <arpa/inet.h> +#include <strings.h> +} + +#if STANDALONE +#include <iostream> +#include <cstdio> + +using namespace std; + +#define lwip_accept accept +#define lwip_bind bind +#define lwip_close close +#define lwip_connect connect +#define lwip_listen listen +#define lwip_socket socket +#define lwip_send send +#define lwip_recv recv + +#define cprintf printf + +void +panic(char *s) +{ + cerr << s << endl; + exit(1); +} + +#endif + +#define nprintf(s, ...) \ + do { \ + char b_[4096]; \ + int n_ = snprintf(b_, sizeof(b_), __VA_ARGS__); \ + if (send(s, b_, n_, 0) == 0) panic("XXX"); \ + } while (0); + +#define SERVER "webserver/1.0" +#define PROTOCOL "HTTP/1.0" +#define RFC1123FMT "%a, %d %b %Y %H:%M:%S GMT" +#define PORT 80 + +void send_headers(int f, int status, char *title, char *extra, char *mime, + int length, time_t date) +{ + time_t now; + char timebuf[128]; + + nprintf(f, "%s %d %s\r\n", PROTOCOL, status, title); + nprintf(f, "Server: %s\r\n", SERVER); + now = time(NULL); + strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&now)); + nprintf(f, "Date: %s\r\n", timebuf); + if (extra) nprintf(f, "%s\r\n", extra); + if (mime) nprintf(f, "Content-Type: %s\r\n", mime); + if (length >= 0) nprintf(f, "Content-Length: %d\r\n", length); + if (date != -1) + { + strftime(timebuf, sizeof(timebuf), RFC1123FMT, gmtime(&date)); + nprintf(f, "Last-Modified: %s\r\n", timebuf); + } + nprintf(f, "Connection: close\r\n"); + nprintf(f, "\r\n"); +} + +void send_error(int f, int status, char *title, char *extra, char *text) +{ + send_headers(f, status, title, extra, "text/html", -1, -1); + nprintf(f, "<HTML><HEAD><TITLE>%d %s</TITLE></HEAD>\r\n", status, title); + nprintf(f, "<BODY><H4>%d %s</H4>\r\n", status, title); + nprintf(f, "%s\r\n", text); + nprintf(f, "</BODY></HTML>\r\n"); +} + +// XXX +void send_file(int f, char *path) +{ +// char data[4096]; +// int n; +// +// FILE *file = fopen(path, "r"); +// if (!file) +// send_error(f, 403, "Forbidden", NULL, "Access denied."); +// else +// { +// int length = S_ISREG(statbuf->st_mode) ? statbuf->st_size : -1; +// send_headers(f, 200, "OK", NULL, get_mime_type(path), length, statbuf->st_mtime); +// +// while ((n = fread(data, 1, sizeof(data), file)) > 0) fwrite(data, 1, n, f); +// fclose(file); +// } +} + +int +process(int f) +{ + char buf[4096]; + char *method; + char *path; + char *protocol; +// struct stat statbuf; +// char pathbuf[4096]; +// int len; + + if (recv(f, buf, sizeof(buf), MSG_WAITALL) < 0) return -1; + printf("URL: %s", buf); + + method = strtok(buf, " "); + path = strtok(NULL, " "); + protocol = strtok(NULL, "\r"); + if (!method || !path || !protocol) return -1; + + if (strcasecmp(method, "GET") != 0) + send_error(f, 501, "Not supported", NULL, "Method is not supported."); +// else if (stat(path, &statbuf) < 0) +// send_error(f, 404, "Not Found", NULL, "File not found."); +// else if (S_ISDIR(statbuf.st_mode)) +// { +// len = strlen(path); +// if (len == 0 || path[len - 1] != '/') +// { +// snprintf(pathbuf, sizeof(pathbuf), "Location: %s/", path); +// send_error(f, 302, "Found", pathbuf, "Directories must end with a slash."); +// } +// else +// { +// snprintf(pathbuf, sizeof(pathbuf), "%sindex.html", path); +// if (stat(pathbuf, &statbuf) >= 0) +// send_file(f, pathbuf, &statbuf); +// else +// { +// DIR *dir; +// struct dirent *de; +// +// send_headers(f, 200, "OK", NULL, "text/html", -1, statbuf.st_mtime); +// nprintf(f, "<HTML><HEAD><TITLE>Index of %s</TITLE></HEAD>\r\n<BODY>", path); +// nprintf(f, "<H4>Index of %s</H4>\r\n<PRE>\n", path); +// nprintf(f, "Name Last Modified Size\r\n"); +// nprintf(f, "<HR>\r\n"); +// if (len > 1) nprintf(f, "<A HREF=\"..\">..</A>\r\n"); +// +// dir = opendir(path); +// while ((de = readdir(dir)) != NULL) +// { +// char timebuf[32]; +// struct tm *tm; +// +// strcpy(pathbuf, path); +// strcat(pathbuf, de->d_name); +// +// stat(pathbuf, &statbuf); +// tm = gmtime(&statbuf.st_mtime); +// strftime(timebuf, sizeof(timebuf), "%d-%b-%Y %H:%M:%S", tm); +// +// nprintf(f, "<A HREF=\"%s%s\">", de->d_name, S_ISDIR(statbuf.st_mode) ? "/" : ""); +// nprintf(f, "%s%s", de->d_name, S_ISDIR(statbuf.st_mode) ? "/</A>" : "</A> "); +// if (de->d_namlen < 32) nprintf(f, "%*s", 32 - de->d_namlen, ""); +// +// if (S_ISDIR(statbuf.st_mode)) +// nprintf(f, "%s\r\n", timebuf); +// else +// nprintf(f, "%s %10d\r\n", timebuf, statbuf.st_size); +// } +// closedir(dir); +// +// nprintf(f, "</PRE>\r\n<HR>\r\n<ADDRESS>%s</ADDRESS>\r\n</BODY></HTML>\r\n", SERVER); +// } +// } +// } + else + send_file(f, path); // , &statbuf); + + return 0; +} + +int +main() +{ + cprintf("socket\n"); + int s = lwip_socket(PF_INET, SOCK_STREAM, 0); + if (s < 0) panic("XXX"); + + struct sockaddr_in sa; + bzero(&sa, sizeof(sa));; + sa.sin_family = AF_INET; + sa.sin_port = htons(8000); + sa.sin_addr.s_addr = htonl(INADDR_ANY); + + cprintf("bind\n"); + if (bind(s, (struct sockaddr*) &sa, sizeof(sa)) != 0) panic("XXX"); + cprintf("listen\n"); + if (listen(s, 1) != 0) panic("XXX"); + + while (true) { + cprintf("accept\n"); + int t = accept(s, NULL, NULL); + if (t < 0) panic("XXX"); + + cprintf("processing\n"); + if (process(t) < 0) panic("XXX"); + } + return 0; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-19 04:01:41
|
Revision: 470 http://assorted.svn.sourceforge.net/assorted/?rev=470&view=rev Author: yangzhang Date: 2008-02-18 19:58:19 -0800 (Mon, 18 Feb 2008) Log Message: ----------- more md-array fun Modified Paths: -------------- sandbox/trunk/src/c/mdarray.c Modified: sandbox/trunk/src/c/mdarray.c =================================================================== --- sandbox/trunk/src/c/mdarray.c 2008-02-19 00:13:41 UTC (rev 469) +++ sandbox/trunk/src/c/mdarray.c 2008-02-19 03:58:19 UTC (rev 470) @@ -1,18 +1,48 @@ -int xss[3][5]; +#include <stdio.h> +enum { outer = 3, inner = 5 }; + +// This is an Array[outer, Array[inner, Int]] +int xss[outer][inner]; + int main() { - // Don't work. + // These don't work. // int **yss = xss; - // int *yss = xss; - // int **yss = xss; - // int **yss = &&xss[0]; - int (*yss)[5] = xss; + // int **yss = &xss[0]; + // int **yss = &&xss[0][0]; - int sum = 0; - for (int i = 0; i < 3; i++) - for (int j = 0; j < 5; j++) - sum += yss[i][j]; - return sum; + // This is a Pointer[Array[inner, Int]]. + int (*yss)[inner] = xss; + + { + // This is safe. + printf("method 0: indexing\n"); + int sum = 0; + for (int i = 0; i < outer; i++) { + printf("outer visiting: %p\n", &yss[i]); + for (int j = 0; j < inner; j++) { + printf("inner visiting: %p\n", &yss[i][j]); + sum += yss[i][j]; + } + } + printf("sum = %d\n", sum); + } + + { + // This method is wrong, running off into segfault land. + printf("method 1: pointers\n"); + int sum = 0; + for (int (*p)[5] = yss; p < yss + outer; p++) { + printf("outer visiting: %p\n", p); + for (int *q = *p; q < q + inner; q++) { + printf("inner visiting: %p\n", q); + sum += *q; + } + } + printf("sum = %d\n", sum); + } + + return 0; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-19 00:13:42
|
Revision: 469 http://assorted.svn.sourceforge.net/assorted/?rev=469&view=rev Author: yangzhang Date: 2008-02-18 16:13:41 -0800 (Mon, 18 Feb 2008) Log Message: ----------- added multidim array/pointer test Added Paths: ----------- sandbox/trunk/src/c/mdarray.c Added: sandbox/trunk/src/c/mdarray.c =================================================================== --- sandbox/trunk/src/c/mdarray.c (rev 0) +++ sandbox/trunk/src/c/mdarray.c 2008-02-19 00:13:41 UTC (rev 469) @@ -0,0 +1,18 @@ +int xss[3][5]; + +int +main() +{ + // Don't work. + // int **yss = xss; + // int *yss = xss; + // int **yss = xss; + // int **yss = &&xss[0]; + int (*yss)[5] = xss; + + int sum = 0; + for (int i = 0; i < 3; i++) + for (int j = 0; j < 5; j++) + sum += yss[i][j]; + return sum; +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-18 20:04:43
|
Revision: 468 http://assorted.svn.sourceforge.net/assorted/?rev=468&view=rev Author: yangzhang Date: 2008-02-18 12:04:44 -0800 (Mon, 18 Feb 2008) Log Message: ----------- java-reactor: done, son! Added Paths: ----------- java-reactor/ java-reactor/trunk/ java-reactor/trunk/src/ java-reactor/trunk/src/build java-reactor/trunk/src/reactor/ java-reactor/trunk/src/reactor/Reactor.java java-reactor/trunk/src/reactor/ReactorHandler.java java-reactor/trunk/src/reactor/ReactorTask.java java-reactor/trunk/src/reactor/ReactorTest.java java-reactor/trunk/src/reactor/Session.java Added: java-reactor/trunk/src/build =================================================================== --- java-reactor/trunk/src/build (rev 0) +++ java-reactor/trunk/src/build 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,2 @@ +java-reactor: + srcs: [reactor/Reactor.java] Added: java-reactor/trunk/src/reactor/Reactor.java =================================================================== --- java-reactor/trunk/src/reactor/Reactor.java (rev 0) +++ java-reactor/trunk/src/reactor/Reactor.java 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,96 @@ +package reactor; + +import java.net.InetSocketAddress; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.util.ArrayList; +import java.util.List; +import java.util.PriorityQueue; +import java.util.Set; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; + + +public class Reactor { + + private final Selector selector; + private final List<Session> sessions = new ArrayList<Session>(); + private boolean doShutdown = false; + private final PriorityQueue<ReactorTask> tasks = new PriorityQueue<ReactorTask>(); + + public Reactor() throws Exception { + selector = Selector.open(); + } + + public Session register(InetSocketAddress remoteSa, + InetSocketAddress localSa, ReactorHandler handler) { + Session session = new Session(remoteSa, localSa, handler, sessions + .size(), selector); + sessions.add(session); + return session; + } + + public void react() throws Exception { + while (true) { + if (doShutdown) + break; + + int updated; + if (tasks.isEmpty()) { + updated = selector.select(); + } else { + long t = tasks.peek().getDelay(TimeUnit.MILLISECONDS); + updated = t > 0 ? selector.select(t) : 0; + } + + if (updated > 0) { + Set<SelectionKey> keys = selector.selectedKeys(); + for (SelectionKey key : keys) { + if (key.isValid()) { + if (key.isReadable()) { + ((Session) key.attachment()).read(key); + } else if (key.isWritable()) { + ((Session) key.attachment()).write(key); + } + } + } + keys.clear(); + } else { + // TODO impose limit on # things to run at once (perhaps even + // specify costs) + while (!tasks.isEmpty() + && tasks.peek().getDelay(TimeUnit.MILLISECONDS) == 0L) { + ReactorTask task = tasks.remove(); + task.run(); + } + } + } + selector.close(); + } + + public ScheduledFuture<?> schedule(Runnable r, long delay, TimeUnit units) { + ReactorTask task = new ReactorTask(r, System.currentTimeMillis() + + units.toMillis(delay), this); + tasks.add(task); + return task; + } + + public ScheduledFuture<?> scheduleWithFixedDelay(final Runnable r, + final long initialDelay, final long delay, final TimeUnit units) { + return schedule(new Runnable() { + public void run() { + r.run(); + Reactor.this.schedule(this, delay, units); + } + }, initialDelay, units); + } + + public boolean cancel(ReactorTask task) { + return tasks.remove(task); + } + + public void shutdown() { + doShutdown = true; + } + +} Added: java-reactor/trunk/src/reactor/ReactorHandler.java =================================================================== --- java-reactor/trunk/src/reactor/ReactorHandler.java (rev 0) +++ java-reactor/trunk/src/reactor/ReactorHandler.java 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,11 @@ +package reactor; + +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; + + +public interface ReactorHandler { + + public void handle(Session session, InetSocketAddress src, ByteBuffer buf); + +} Added: java-reactor/trunk/src/reactor/ReactorTask.java =================================================================== --- java-reactor/trunk/src/reactor/ReactorTask.java (rev 0) +++ java-reactor/trunk/src/reactor/ReactorTask.java 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,95 @@ +package reactor; + +import java.util.concurrent.Delayed; +import java.util.concurrent.ExecutionException; +import java.util.concurrent.ScheduledFuture; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; + +import sun.reflect.generics.reflectiveObjects.NotImplementedException; + +public class ReactorTask implements ScheduledFuture<Void> { + + private final Runnable r; + private final long time; + private final Reactor reactor; + + private static enum TaskState { + WAITING, RUNNING, DONE, CANCELLED + }; + + private TaskState state = TaskState.WAITING; + + public ReactorTask(Runnable r, long time, Reactor reactor) { + this.r = r; + this.time = time; + this.reactor = reactor; + } + + public void run() { + if (state != TaskState.CANCELLED) { + assert state == TaskState.WAITING; + state = TaskState.RUNNING; + try { + r.run(); + } catch (Exception ex) { + } + state = TaskState.DONE; + } + } + + @Override + public boolean cancel(boolean mayInterruptIfRunning) { + if (state == TaskState.WAITING) { + state = TaskState.CANCELLED; + boolean b = reactor.cancel(this); + assert b; + return true; + } else { + return false; + } + } + + @Override + public Void get() throws InterruptedException, ExecutionException { + // TODO is this correct? + return null; + } + + @Override + public Void get(long timeout, TimeUnit unit) throws InterruptedException, + ExecutionException, TimeoutException { + throw new NotImplementedException(); + } + + @Override + public boolean isCancelled() { + return state == TaskState.CANCELLED; + } + + @Override + public boolean isDone() { + return state == TaskState.DONE; + } + + @Override + public long getDelay(TimeUnit units) { + long delay = time - System.currentTimeMillis(); + return delay > 0 ? TimeUnit.MILLISECONDS.convert(delay, units) : 0; + } + + @Override + public int compareTo(Delayed o) { + if (false && o instanceof ReactorTask) { + ReactorTask other = (ReactorTask) o; + System.out.println(time + " vs " + other.time + " " + + getDelay(TimeUnit.MILLISECONDS) + " vs " + + other.getDelay(TimeUnit.MILLISECONDS)); + return Long.valueOf(time).compareTo(other.time); + } else { + return Long.valueOf(getDelay(TimeUnit.MILLISECONDS)).compareTo( + o.getDelay(TimeUnit.MILLISECONDS)); + } + } + +} Added: java-reactor/trunk/src/reactor/ReactorTest.java =================================================================== --- java-reactor/trunk/src/reactor/ReactorTest.java (rev 0) +++ java-reactor/trunk/src/reactor/ReactorTest.java 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,105 @@ +package reactor; + +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetAddress; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; + + +public class ReactorTest { + ExecutorService e; + + public ReactorTest() { + e = Executors.newCachedThreadPool(); + } + + public void spawn(final Runnable r) { + e.submit(new Runnable() { + public void run() { + try { + r.run(); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + private Runnable makeRunnable(final int i) { + return new Runnable() { + public void run() { + System.out.println(i); + } + }; + } + + public void test() throws Exception { + InetAddress localhost = InetAddress.getLocalHost(); + int serverPort = 11111, clientPort = 22222; + final InetSocketAddress serverSa, clientSa; + serverSa = new InetSocketAddress(localhost, serverPort); + clientSa = new InetSocketAddress(localhost, clientPort); + + final ReactorHandler handler = new ReactorHandler() { + public void handle(Session service, InetSocketAddress src, + ByteBuffer buf) { + System.out.println("received: " + buf); + } + }; + + spawn(new Runnable() { + public void run() { + try { + Reactor r = new Reactor(); + r.register(null, serverSa, handler); + + for (int i = 0; i < 10; i++) + r.schedule(makeRunnable(i), 200 * i, + TimeUnit.MILLISECONDS); + + Thread.sleep(1000); + r.react(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + spawn(new Runnable() { + public void run() { + try { + Reactor r = new Reactor(); + ByteBuffer writeBuf = ByteBuffer.allocate(5); + Session s = r.register(null, clientSa, handler); + Thread.sleep(2000); + s.send(writeBuf, clientSa); + r.react(); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + + spawn(new Runnable() { + public void run() { + try { + byte[] writeBuf = new byte[] { 0, 1, 2, 3 }; + Thread.sleep(3000); + new DatagramSocket().send(new DatagramPacket(writeBuf, + writeBuf.length, serverSa)); + } catch (Exception ex) { + ex.printStackTrace(); + } + } + }); + } + + public static void main(String args[]) throws Exception { + new ReactorTest().test(); + } + +} Added: java-reactor/trunk/src/reactor/Session.java =================================================================== --- java-reactor/trunk/src/reactor/Session.java (rev 0) +++ java-reactor/trunk/src/reactor/Session.java 2008-02-18 20:04:44 UTC (rev 468) @@ -0,0 +1,121 @@ +package reactor; + +import java.io.IOException; +import java.net.DatagramSocket; +import java.net.InetSocketAddress; +import java.nio.ByteBuffer; +import java.nio.channels.DatagramChannel; +import java.nio.channels.SelectionKey; +import java.nio.channels.Selector; +import java.util.ArrayList; +import java.util.List; + + +public class Session { + + public final DatagramChannel channel; + public final ReactorHandler handler; + public final InetSocketAddress remoteSa, localSa; + public final int index; + // public final ByteBuffer readBuf = ByteBuffer.allocate(4096); + public final ByteBuffer readBuf = ByteBuffer.allocateDirect(4096); + public final List<ByteBuffer> pendingWrites = new ArrayList<ByteBuffer>(); + + public Session(InetSocketAddress remoteSa, InetSocketAddress localSa, + ReactorHandler handler, int index, Selector selector) { + this.handler = handler; + this.remoteSa = remoteSa; + this.localSa = localSa; + this.index = index; + + try { + channel = DatagramChannel.open(); + channel.configureBlocking(false); + DatagramSocket socket = channel.socket(); + socket.setReuseAddress(true); + if (localSa != null) + socket.bind(localSa); + if (remoteSa != null) + channel.connect(remoteSa); + + channel.register(selector, SelectionKey.OP_READ, this); + } catch (Exception ex) { + throw new RuntimeException(ex); + } + } + + // read messages is the priority + public void read(SelectionKey key) throws Exception { + while (true) { + try { + InetSocketAddress srcSa; + + if (remoteSa == null) { + srcSa = (InetSocketAddress) channel.receive(readBuf); + } else { + int numRead = channel.read(readBuf); + if (numRead == -1) { + // Remote entity shut the socket down + // cleanly. + // Do + // the same from our end and cancel the + // channel. + key.channel().close(); + key.cancel(); + } + // TODO also handle numRead == 0 + srcSa = remoteSa; + } + + if (srcSa == null) { + break; + } + + // after channel wrote to buf, set lim = pos, then pos = 0 + readBuf.flip(); + // callback + handler.handle(this, srcSa, readBuf); + // recycle buffer + readBuf.clear(); + } catch (IOException e) { + // The remote forcibly closed the connection, cancel + // the selection key and close the channel. + key.cancel(); + channel.close(); + } + } + } + + public void write(SelectionKey key) throws Exception { + // Write until there's not more data ... + while (!pendingWrites.isEmpty()) { + ByteBuffer buf = (ByteBuffer) pendingWrites.get(0); + channel.write(buf); + if (buf.remaining() > 0) { + // ... or the socket's buffer fills up + break; + } + pendingWrites.remove(0); + } + + if (pendingWrites.isEmpty()) { + // We wrote away all data, so we're no longer + // interested + // in writing on this socket. Switch back to waiting + // for + // data. + key.interestOps(SelectionKey.OP_READ); + } + } + + public void send(ByteBuffer writeBuf, InetSocketAddress dst) + throws Exception { + int bytes = channel.send(writeBuf, dst); + assert bytes == writeBuf.limit(); + } + + public void close() throws Exception { + channel.close(); + } + +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-18 19:57:30
|
Revision: 467 http://assorted.svn.sourceforge.net/assorted/?rev=467&view=rev Author: yangzhang Date: 2008-02-18 11:57:27 -0800 (Mon, 18 Feb 2008) Log Message: ----------- added java support Modified Paths: -------------- simple-build/trunk/src/SimpleBuild.scala simple-build/trunk/src/build-templates/scala simple-build/trunk/src/setup.bash Added Paths: ----------- simple-build/trunk/src/build-templates/java simple-build/trunk/src/capture-javac-deps Removed Paths: ------------- simple-build/trunk/src/capture-scala-deps Modified: simple-build/trunk/src/SimpleBuild.scala =================================================================== --- simple-build/trunk/src/SimpleBuild.scala 2008-02-16 21:59:33 UTC (rev 466) +++ simple-build/trunk/src/SimpleBuild.scala 2008-02-18 19:57:27 UTC (rev 467) @@ -14,6 +14,7 @@ "c" -> "c", "cc" -> "cpp", "cpp" -> "cpp", + "java" -> "java", "scala" -> "scala" ) def err(x: AnyRef) { Console.err println x } @@ -35,6 +36,11 @@ "mainclass" -> "symbol", "classpath" -> "list|srcdir|:", "srcs" -> "list|srcdir| " + ), + "java" -> Map( + "mainclass" -> "symbol", + "classpath" -> "list|srcdir|:", + "srcs" -> "list|srcdir| " ) ) val ids = Iterator from 0 Copied: simple-build/trunk/src/build-templates/java (from rev 456, simple-build/trunk/src/build-templates/scala) =================================================================== --- simple-build/trunk/src/build-templates/java (rev 0) +++ simple-build/trunk/src/build-templates/java 2008-02-18 19:57:27 UTC (rev 467) @@ -0,0 +1,39 @@ +# Output locations. + +SCRIPT := $(OUTDIR)/$(TARGET) +ifeq (,$(VERSION)) + JAR := $(OUTDIR)/$(TARGET).jar +else + JAR := $(OUTDIR)/$(TARGET)-$(VERSION).jar +endif +CLASSDIR := $(OUTDIR)/$(TARGET)-classes + +# Flags. + +JAVACFLAGS:= -deprecation -unchecked -sourcepath $(SRCPATH) -d $(CLASSDIR) -cp $(CLASSPATH) +JAVAC := capture-javac-deps 2 $(JAR) $(OUTDIR)/.deps javac -verbose + +$(TARGET): $(SCRIPT) $(JAR) + +$(SCRIPT): $(MAKEFILE_LIST) + mkdir -p $(@D) + if [ ! -z "$(MAINCLASS)" ]; then \ + echo "#!/usr/bin/env bash\n\nJAVA_OPTS=\"$(JRUNFLAGS) \$${JAVA_OPTS:-}\" exec java -cp $(JAR):$(CLASSPATH) $(MAINCLASS) \"\$$@\"" > $(SCRIPT) ;\ + chmod +x $(SCRIPT) ;\ + fi + +$(JAR): $(SRCS) + mkdir -p $(CLASSDIR) + $(JAVAC) $(JAVACFLAGS) $< + jar cf $@ -C $(CLASSDIR) . + +-include $(OUTDIR)/.deps + +install: $(TARGET) + mkdir -p $(BINDIR) + cp $(SCRIPT) $(BINDIR) + +clean: + rm -rf $(SCRIPT) $(JAR) $(CLASSDIR) + +.PHONY: $(TARGET) clean Modified: simple-build/trunk/src/build-templates/scala =================================================================== --- simple-build/trunk/src/build-templates/scala 2008-02-16 21:59:33 UTC (rev 466) +++ simple-build/trunk/src/build-templates/scala 2008-02-18 19:57:27 UTC (rev 467) @@ -12,14 +12,16 @@ SRCPATH := $(SRCPATH):$(SCALA_COMMONS_SRC) SFLAGS := -deprecation -unchecked -sourcepath $(SRCPATH) -d $(CLASSDIR) -cp $(CLASSPATH) -SCALAC := capture-scala-deps $(JAR) $(OUTDIR)/.deps fsc -verbose +SCALAC := capture-javac-deps 1 $(JAR) $(OUTDIR)/.deps fsc -verbose $(TARGET): $(SCRIPT) $(JAR) $(SCRIPT): $(MAKEFILE_LIST) mkdir -p $(@D) - echo "#!/usr/bin/env bash\n\nJAVA_OPTS=\"$(JRUNFLAGS) \$${JAVA_OPTS:-}\" exec scala -cp $(JAR):$(CLASSPATH) $(MAINCLASS) \"\$$@\"" > $(SCRIPT) - chmod +x $(SCRIPT) + if [ ! -z "$(MAINCLASS)" ]; then \ + echo "#!/usr/bin/env bash\n\nJAVA_OPTS=\"$(JRUNFLAGS) \$${JAVA_OPTS:-}\" exec scala -cp $(JAR):$(CLASSPATH) $(MAINCLASS) \"\$$@\"" > $(SCRIPT) ;\ + chmod +x $(SCRIPT) ;\ + fi $(JAR): $(SRCS) mkdir -p $(CLASSDIR) Copied: simple-build/trunk/src/capture-javac-deps (from rev 456, simple-build/trunk/src/capture-scala-deps) =================================================================== --- simple-build/trunk/src/capture-javac-deps (rev 0) +++ simple-build/trunk/src/capture-javac-deps 2008-02-18 19:57:27 UTC (rev 467) @@ -0,0 +1,50 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset + +verbosefd="$1" +target="$2" +depsfile="$3" +shift; shift; shift + +# Get the top-level source files. This is no longer used. +mainsrcs=() +for i in "$@" ; do + if [[ "${i%.scala}" != "$i" ]] + then mainsrcs=( "${mainsrcs[@]:-$i}" "$i" ) + fi +done + +generate-deps() { + while read line ; do + if [[ "${line#[}" == "$line" ]] ; then + # Line doesn't start with '[' (normal output). + echo "$line" + else + # Line starts with '[' (verbose output). + echo "$line" 1>&3 + fi + done 3> >( + { + # Parse just the verbose output and emit the deps file. + echo "$target: \\" + sed -n ' + /^\[loaded source file / { + s/^\[loaded source file \(.*\) in [[:digit:]]*ms\]/\1/ + p + } + ' | sed ' + { s/^/\t/; s/$/ \\/ } + $ { a\\t + } + ' + } > "$depsfile" + ) +} + +# Run the compiler. Verbose output can come from either stdout or stderr. +case $verbosefd in + 1 ) "$@" 1> >( generate-deps ) ;; + 2 ) "$@" 2> >( generate-deps ) ;; + * ) echo "bad verbosefd: $verbosefd"; exit 1 ;; +esac Deleted: simple-build/trunk/src/capture-scala-deps =================================================================== --- simple-build/trunk/src/capture-scala-deps 2008-02-16 21:59:33 UTC (rev 466) +++ simple-build/trunk/src/capture-scala-deps 2008-02-18 19:57:27 UTC (rev 467) @@ -1,41 +0,0 @@ -#!/usr/bin/env bash - -set -o errexit -o nounset - -target="$1" -depsfile="$2" -shift; shift - -# Get the top-level source files. This is no longer used. -mainsrcs=() -for i in "$@" ; do - if [[ "${i%.scala}" != "$i" ]] - then mainsrcs=( "${mainsrcs[@]:-$i}" "$i" ) - fi -done - -# Run the compiler. -"$@" | while read line ; do - if [[ "${line#[}" == "$line" ]] ; then - # Line doesn't start with '[' (normal output). - echo "$line" - else - # Line starts with '[' (verbose output). - echo "$line" 1>&3 - fi -done 3> >( - { - # Parse just the verbose output and emit the deps file. - echo "$target: \\" - sed -n ' - /^\[loaded source file / { - s/^\[loaded source file \(.*\) in [[:digit:]]*ms\]/\1/ - p - } - ' | sed ' - { s/^/\t/; s/$/ \\/ } - $ { a\\t - } - ' - } > "$depsfile" -) Modified: simple-build/trunk/src/setup.bash =================================================================== --- simple-build/trunk/src/setup.bash 2008-02-16 21:59:33 UTC (rev 466) +++ simple-build/trunk/src/setup.bash 2008-02-18 19:57:27 UTC (rev 467) @@ -3,4 +3,5 @@ pkg=simple-build . simple-setup.bash -install bin/ build.bash capture-scala-deps +install bin/ build.bash capture-javac-deps +install share/$pkg/ build-templates This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:59:29
|
Revision: 466 http://assorted.svn.sourceforge.net/assorted/?rev=466&view=rev Author: yangzhang Date: 2008-02-16 13:59:33 -0800 (Sat, 16 Feb 2008) Log Message: ----------- updated readme Modified Paths: -------------- simple-build/trunk/README Modified: simple-build/trunk/README =================================================================== --- simple-build/trunk/README 2008-02-16 21:46:24 UTC (rev 465) +++ simple-build/trunk/README 2008-02-16 21:59:33 UTC (rev 466) @@ -1,4 +1,46 @@ +Overview +-------- + +Keep your builds as simple as possible. Never repeat yourself. Separation of +rules from declared goals. + +Eventually aims to be a complete solution for software configuration, building, +installation and distribution. + +Current features: + +- automatic dependency tracking for C/C++ and Scala + - only specify top-level source files + - simple-build uses the compiler to generate dependency files that are + included into the Makefile for fine-grained dependency tracking + - very useful for when you are working across multiple projects (in my case, + the culprits are often C++ Commons, Scala Commons, etc.) + +Planned features: + +- out-of-the-box support for C, C++, Java, Scala +- software deployment + - installation + - web publishing + - workspace setup (e.g. for experiments with large datasets) +- documentation generation that respects existing platforms/conventions + - doxygen for C/C++ + - epydoc for Python + - scaladoc for Scala + - javadoc for Java +- distribution and packaging that respects existing platforms/conventions + - autotools for C/C++ + - more, stronger heuristics than autoscan + - generate acinclude.m4 + - setuptools/pypi for Python + - sbaz for Scala + - jars for Java +- continuous build and continuous testing + - maven for Java/Scala +- somehow merge with simple-setup (generate simple-setup files too?) +- stronger inference (e.g. mainclass inference, library test inference) + Requirements -------------- +------------ -jyaml-1.3.jar +- jyaml-1.3.jar This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:46:18
|
Revision: 465 http://assorted.svn.sourceforge.net/assorted/?rev=465&view=rev Author: yangzhang Date: 2008-02-16 13:46:24 -0800 (Sat, 16 Feb 2008) Log Message: ----------- moved to simple-build Added Paths: ----------- numa-bench/trunk/tools/build Removed Paths: ------------- numa-bench/trunk/tools/Makefile Deleted: numa-bench/trunk/tools/Makefile =================================================================== --- numa-bench/trunk/tools/Makefile 2008-02-16 21:44:10 UTC (rev 464) +++ numa-bench/trunk/tools/Makefile 2008-02-16 21:46:24 UTC (rev 465) @@ -1,12 +0,0 @@ -COMMONS := $(wildcard commons/*.scala) - -all: out/PlotHist.class - -out/PlotHist.class: PlotHist.scala $(COMMONS) - mkdir -p out - fsc -d out $^ - -clean: - rm -rf out - -.PHONY: clean Added: numa-bench/trunk/tools/build =================================================================== --- numa-bench/trunk/tools/build (rev 0) +++ numa-bench/trunk/tools/build 2008-02-16 21:46:24 UTC (rev 465) @@ -0,0 +1,3 @@ +plot-hist: + srcs: [PlotHist.scala] + mainclass: PlotHist This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:44:07
|
Revision: 464 http://assorted.svn.sourceforge.net/assorted/?rev=464&view=rev Author: yangzhang Date: 2008-02-16 13:44:10 -0800 (Sat, 16 Feb 2008) Log Message: ----------- moved to simple-build Added Paths: ----------- hash-dist/trunk/src/build Removed Paths: ------------- hash-dist/trunk/src/Makefile Deleted: hash-dist/trunk/src/Makefile =================================================================== --- hash-dist/trunk/src/Makefile 2008-02-16 21:42:15 UTC (rev 463) +++ hash-dist/trunk/src/Makefile 2008-02-16 21:44:10 UTC (rev 464) @@ -1,12 +0,0 @@ -COMMONS_SRCS := $(wildcard commons/*.scala) - -all: out/HashDist.class - -out/HashDist.class: HashDist.scala $(COMMONS_SRCS) - mkdir -p out - fsc -d out $^ - -clean: - rm -rf out - -.PHONY: clean Added: hash-dist/trunk/src/build =================================================================== --- hash-dist/trunk/src/build (rev 0) +++ hash-dist/trunk/src/build 2008-02-16 21:44:10 UTC (rev 464) @@ -0,0 +1,3 @@ +hash-dist: + srcs: [HashDist.scala] + mainclass: HashDist This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:42:14
|
Revision: 463 http://assorted.svn.sourceforge.net/assorted/?rev=463&view=rev Author: yangzhang Date: 2008-02-16 13:42:15 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added simple-build-related vars Modified Paths: -------------- shell-tools/trunk/src/bash-commons/bashrc.bash Modified: shell-tools/trunk/src/bash-commons/bashrc.bash =================================================================== --- shell-tools/trunk/src/bash-commons/bashrc.bash 2008-02-16 21:42:07 UTC (rev 462) +++ shell-tools/trunk/src/bash-commons/bashrc.bash 2008-02-16 21:42:15 UTC (rev 463) @@ -96,6 +96,11 @@ export GLOBAL_PKG="/opt" export GLOBAL_TOAST_PREFIX="/usr/local" +# my own + +export SCALA_COMMONS_SRC="$HOME/scom/.." +export SIMPLEBUILD="$GLOBAL_PREFIX/share/simple-build/build-templates" + export CVS_RSH=ssh export EDITOR=vim export GREP_OPTIONS=--color This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:42:02
|
Revision: 462 http://assorted.svn.sourceforge.net/assorted/?rev=462&view=rev Author: yangzhang Date: 2008-02-16 13:42:07 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added is-empty, rm-empty Modified Paths: -------------- shell-tools/trunk/src/bash-commons/common.bash Modified: shell-tools/trunk/src/bash-commons/common.bash =================================================================== --- shell-tools/trunk/src/bash-commons/common.bash 2008-02-16 21:41:42 UTC (rev 461) +++ shell-tools/trunk/src/bash-commons/common.bash 2008-02-16 21:42:07 UTC (rev 462) @@ -350,6 +350,18 @@ fi } +is-empty() { + [[ -f "$1" && "$( stat -c%s "$1" )" == 0 ]] +} + +rm-empty() { + for i in "$@" ; do + if is-empty "$i" + then rm "$i" + fi + done +} + #if ! is_declared indent ; then # noindent #else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:41:36
|
Revision: 461 http://assorted.svn.sourceforge.net/assorted/?rev=461&view=rev Author: yangzhang Date: 2008-02-16 13:41:42 -0800 (Sat, 16 Feb 2008) Log Message: ----------- imported mergedep Added Paths: ----------- cpp-commons/trunk/mergedep.pl Added: cpp-commons/trunk/mergedep.pl =================================================================== --- cpp-commons/trunk/mergedep.pl (rev 0) +++ cpp-commons/trunk/mergedep.pl 2008-02-16 21:41:42 UTC (rev 461) @@ -0,0 +1,86 @@ +#!/usr/bin/perl +# Copyright 2003 Bryan Ford +# Distributed under the GNU General Public License. +# +# Usage: mergedep <main-depfile> [<new-depfiles> ...] +# +# This script merges the contents of all <new-depfiles> specified +# on the command line into the single file <main-depfile>, +# which may or may not previously exist. +# Dependencies in the <new-depfiles> will override +# any existing dependencies for the same targets in <main-depfile>. +# The <new-depfiles> are deleted after <main-depfile> is updated. +# +# The <new-depfiles> are typically generated by GCC with the -MD option, +# and the <main-depfile> is typically included from a Makefile, +# as shown here for GNU 'make': +# +# .deps: $(wildcard *.d) +# perl mergedep $@ $^ +# -include .deps +# +# This script properly handles multiple dependencies per <new-depfile>, +# including dependencies having no target, +# so it is compatible with GCC3's -MP option. +# + +sub readdeps { + my $filename = shift; + + open(DEPFILE, $filename) or return 0; + while (<DEPFILE>) { + if (/([^:]*):([^\\:]*)([\\]?)$/) { + my $target = $1; + my $deplines = $2; + my $slash = $3; + while ($slash ne '') { + $_ = <DEPFILE>; + defined($_) or die + "Unterminated dependency in $filename"; + /(^[ \t][^\\]*)([\\]?)$/ or die + "Bad continuation line in $filename"; + $deplines = "$deplines\\\n$1"; + $slash = $2; + } + #print "DEPENDENCY [[$target]]: [[$deplines]]\n"; + $dephash{$target} = $deplines; + } elsif (/^[#]?[ \t]*$/) { + # ignore blank lines and comments + } else { + die "Bad dependency line in $filename: $_"; + } + } + close DEPFILE; + return 1; +} + + +if ($#ARGV < 0) { + print "Usage: mergedep <main-depfile> [<new-depfiles> ..]\n"; + exit(1); +} + +%dephash = (); + +# Read the main dependency file +$maindeps = $ARGV[0]; +readdeps($maindeps); + +# Read and merge in the new dependency files +foreach $i (1 .. $#ARGV) { + readdeps($ARGV[$i]) or die "Can't open $ARGV[$i]"; +} + +# Update the main dependency file +open(DEPFILE, ">$maindeps.tmp") or die "Can't open output file $maindeps.tmp"; +foreach $target (keys %dephash) { + print DEPFILE "$target:$dephash{$target}"; +} +close DEPFILE; +rename("$maindeps.tmp", "$maindeps") or die "Can't overwrite $maindeps"; + +# Finally, delete the new dependency files +foreach $i (1 .. $#ARGV) { + unlink($ARGV[$i]) or print "Error removing $ARGV[$i]\n"; +} + Property changes on: cpp-commons/trunk/mergedep.pl ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:40:19
|
Revision: 460 http://assorted.svn.sourceforge.net/assorted/?rev=460&view=rev Author: yangzhang Date: 2008-02-16 13:40:25 -0800 (Sat, 16 Feb 2008) Log Message: ----------- removed commons symlink from src makefile Modified Paths: -------------- hash-join/trunk/src/Makefile Modified: hash-join/trunk/src/Makefile =================================================================== --- hash-join/trunk/src/Makefile 2008-02-16 21:39:51 UTC (rev 459) +++ hash-join/trunk/src/Makefile 2008-02-16 21:40:25 UTC (rev 460) @@ -1,5 +1,5 @@ TARGET := hashjoin -SRCS := hashjoin.cc $(wildcard commons/*.h) +SRCS := hashjoin.cc export TARGET ### begin common makefrag This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:39:51
|
Revision: 459 http://assorted.svn.sourceforge.net/assorted/?rev=459&view=rev Author: yangzhang Date: 2008-02-16 13:39:51 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added rel2abs(path) Modified Paths: -------------- scala-commons/trunk/src/commons/Path.scala Modified: scala-commons/trunk/src/commons/Path.scala =================================================================== --- scala-commons/trunk/src/commons/Path.scala 2008-02-16 21:39:45 UTC (rev 458) +++ scala-commons/trunk/src/commons/Path.scala 2008-02-16 21:39:51 UTC (rev 459) @@ -9,4 +9,6 @@ if (path.last == sep) path + relpath else path + sep + relpath } + def rel2abs(dir: String, path: String) = + if (path startsWith "/") path else dir / path } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:39:41
|
Revision: 458 http://assorted.svn.sourceforge.net/assorted/?rev=458&view=rev Author: yangzhang Date: 2008-02-16 13:39:45 -0800 (Sat, 16 Feb 2008) Log Message: ----------- renamed one of the multimaps to orderedMultimap Modified Paths: -------------- scala-commons/trunk/src/commons/Collections.scala Modified: scala-commons/trunk/src/commons/Collections.scala =================================================================== --- scala-commons/trunk/src/commons/Collections.scala 2008-02-16 21:38:54 UTC (rev 457) +++ scala-commons/trunk/src/commons/Collections.scala 2008-02-16 21:39:45 UTC (rev 458) @@ -633,7 +633,7 @@ dst } - def multimap[a,b](xs: List[(a,b)]) = { + def orderedMultimap[a,b](xs: List[(a,b)]) = { val h = new mut.HashMap[a, mut.ArrayBuffer[b]] { override def default(k: a) = { this(k) = new mut.ArrayBuffer[b] This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:38:55
|
Revision: 457 http://assorted.svn.sourceforge.net/assorted/?rev=457&view=rev Author: yangzhang Date: 2008-02-16 13:38:54 -0800 (Sat, 16 Feb 2008) Log Message: ----------- moved scala tools to simple-build Added Paths: ----------- hash-join/trunk/tools/build hash-join/trunk/tools/run.bash Removed Paths: ------------- hash-join/trunk/tools/Makefile Deleted: hash-join/trunk/tools/Makefile =================================================================== --- hash-join/trunk/tools/Makefile 2008-02-16 21:37:39 UTC (rev 456) +++ hash-join/trunk/tools/Makefile 2008-02-16 21:38:54 UTC (rev 457) @@ -1,37 +0,0 @@ -COMMONS_SRCS := $(wildcard commons/*.scala) -DBPREP_SRCS := DbPrep.scala $(COMMONS_SRCS) -LOGPROC_SRCS := LogProc.scala $(COMMONS_SRCS) -TITLES_SRCS := Titles.scala $(COMMONS_SRCS) -log := log-josmp -rep := 1 - -FSC = mkdir -p out && fsc -deprecation -d out $^ - -all: out/DbPrep.class out/LogProc.class - -out/DbPrep.class: $(DBPREP_SRCS) - $(FSC) - -out/LogProc.class: $(LOGPROC_SRCS) - $(FSC) - -out/Titles.class: $(TITLES_SRCS) - $(FSC) - -prep: out/DbPrep.class - scala -cp out DbPrep $(rep) - -proc: out/LogProc.class - mkdir -p data - egrep 'cpus|time: ' $(log) | \ - sed 's/ time: /: /' | \ - scala -cp out LogProc " cpus" - -titles: out/Titles.class - cat ../src/movies.dat | tr '\0' '\n' | scala -cp out Titles > titles.txt - # head -c 1024 movies.dat | tr '\0' '\n' | scala -cp out Titles > titles.txt - -clean: - rm -rf out - -.PHONY: clean run prep proc Added: hash-join/trunk/tools/build =================================================================== --- hash-join/trunk/tools/build (rev 0) +++ hash-join/trunk/tools/build 2008-02-16 21:38:54 UTC (rev 457) @@ -0,0 +1,11 @@ +prep: + mainclass: DbPrep + srcs: [DbPrep.scala] + +proc: + mainclass: LogProc + srcs: [LogProc.scala] + +titles: + mainclass: Titles + srcs: [Titles.scala] Added: hash-join/trunk/tools/run.bash =================================================================== --- hash-join/trunk/tools/run.bash (rev 0) +++ hash-join/trunk/tools/run.bash 2008-02-16 21:38:54 UTC (rev 457) @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset + +make -s + +prep() { + out/prep "${@:-10}" +} + +proc() { + mkdir -p data + + egrep 'cpus|time: ' $1 | + sed 's/ time: /: /' | + out/proc ' cpus' +} + +titles() { + cat ../src/movies.dat | + tr '\0' '\n' | + out/titles > titles.txt +} + +"$@" Property changes on: hash-join/trunk/tools/run.bash ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 21:37:39
|
Revision: 456 http://assorted.svn.sourceforge.net/assorted/?rev=456&view=rev Author: yangzhang Date: 2008-02-16 13:37:39 -0800 (Sat, 16 Feb 2008) Log Message: ----------- added simple-build! Added Paths: ----------- simple-build/ simple-build/trunk/ simple-build/trunk/README simple-build/trunk/example.build simple-build/trunk/src/ simple-build/trunk/src/Makefile simple-build/trunk/src/SimpleBuild.scala simple-build/trunk/src/build simple-build/trunk/src/build-templates/ simple-build/trunk/src/build-templates/Makefile simple-build/trunk/src/build-templates/common.mk simple-build/trunk/src/build-templates/cpp simple-build/trunk/src/build-templates/scala simple-build/trunk/src/build-templates/scala.mk.part simple-build/trunk/src/build-templates/variant.mk simple-build/trunk/src/build.bash simple-build/trunk/src/capture-scala-deps simple-build/trunk/src/setup.bash Added: simple-build/trunk/README =================================================================== --- simple-build/trunk/README (rev 0) +++ simple-build/trunk/README 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,4 @@ +Requirements +------------- + +jyaml-1.3.jar Added: simple-build/trunk/example.build =================================================================== --- simple-build/trunk/example.build (rev 0) +++ simple-build/trunk/example.build 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,39 @@ +template: assorted + +hash-join + inherits c++-program + name: Hash-Join + hashjoin <- hashjoin.cc + +hashjoin-tools inherits scala-program + prep <- DbPrep.scala + proc <- LogProc.scala + titles <- Titles.scala + +web(graphs) inherits assorted-project-website + index.html <- README + analysis.html <- doc/analysis.txt + graphs/ <- graphs + +# Standard commands include: +# - doc: generate doxygen, epydoc, scaladoc, javadoc, etc. based on what it +# detects. +# - dist: tar.gz containing autotools, setuptools, etc. +# - + +AssortedProjectWebsite(webdir): + mkdir -p webdir + publish: + ssh asdf + +everything is a goal + inherited goals + rules are lexically scoped (applicable only within defining goal) + +c++-program(name) inherits c++-project(name) +c++-library(name) inherits c++-project(name) +c++-project(name) + gen-autotools + build + doc + asdf Added: simple-build/trunk/src/Makefile =================================================================== --- simple-build/trunk/src/Makefile (rev 0) +++ simple-build/trunk/src/Makefile 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,8 @@ +all: meta/SimpleBuild.class + +meta/SimpleBuild.class: SimpleBuild.scala + mkdir -p meta + fsc -deprecation -unchecked -d meta -cp jyaml-1.3.jar SimpleBuild.scala -sourcepath ~/scom/.. + +run: meta/SimpleBuild.class + scala -cp meta:jyaml-1.3.jar SimpleBuild Added: simple-build/trunk/src/SimpleBuild.scala =================================================================== --- simple-build/trunk/src/SimpleBuild.scala (rev 0) +++ simple-build/trunk/src/SimpleBuild.scala 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,164 @@ +import _root_.commons.Collections._ +import _root_.commons.Control._ +import _root_.commons.Io._ +import _root_.commons.Path._ +import _root_.scala.collection.mutable._ +import _root_.org.ho.yaml._ +import _root_.scala.collection.jcl +import _root_.java.util.regex._ +import _root_.java.io.File + +object SimpleBuild { + case class HandledException(e: Exception) extends Exception(e) + val ext2template = Map( + "c" -> "c", + "cc" -> "cpp", + "cpp" -> "cpp", + "scala" -> "scala" + ) + def err(x: AnyRef) { Console.err println x } + def doOrDie[a](f: => a)(mkmsg: Exception => String) = { + try { f } catch { + case e: Exception => { + err(mkmsg(e)) + throw HandledException(e) + } + } + } + val structspec = """ + mainclass: required symbol + classpath: optional list of paths relative to srcdir joined by ':' default [] + srcs: required list of files relative to srcdir joined by ' ' + """ + val structs = Map( + "scala" -> Map( + "mainclass" -> "symbol", + "classpath" -> "list|srcdir|:", + "srcs" -> "list|srcdir| " + ) + ) + val ids = Iterator from 0 + val basedir = System getenv "SIMPLEBUILD" + val pwd = new File(System getProperty "user.dir").getCanonicalPath + def templateByFilename(s: String) = { + val name = ext2template(s split "\\." last) + val fname = basedir / "build-templates" / name + val template = using (TextReader(fname)) (_ read) + val struct = structs(name) + (template, struct) + } + def instantiate(template: String, aggs: MultiMap[String,String]) = { + val internalVars = new HashMap[String,String] + val tid = ids.next + def substVars(s: String) = + (s /: internalVars.elements) { case (s,(from,to)) => + s replaceAll ("\\$\\(" + from + "\\)", "\\$(" + to + ")") + } + val newLines0 = for (line <- template split "\n") yield { + if (line contains " := ") { + // Assignment. + val Seq(lhs, rhs) = line split " := " + val newLhs = lhs.trim + "_" + tid + val newRhs = substVars(rhs) + internalVars += (lhs.trim -> newLhs) + newLhs + " := " + newRhs + } else { + // Everything else. + substVars(line) + } + } + val goal = Pattern compile "^(\\w+):" + val newLines1 = + for (line <- newLines0) yield { + val m = goal matcher line + if (m find) { + val replacement = "$1-\\$(TARGET_" + tid + ")" + val newLine = m replaceFirst (replacement + ":") + val hd = (newLine split ":")(0) + aggs add (m group 1, hd) + newLine + } else { + line + } + } + newLines1 mkString "\n" + } + def emitMakeFrag(target: String, rules: String) { + using (TextWriter(target + ".mk")) (_ println rules) + } + implicit def node2map(n: YamlNode) = n.asInstanceOf[YamlMap] + implicit def node2seq(n: YamlNode) = n.asInstanceOf[YamlSeq] + implicit def node2str(n: YamlNode) = n.asInstanceOf[YamlStr] + implicit def node2nil(n: YamlNode) = n.asInstanceOf[YamlNil] + abstract class YamlNode + case class YamlSeq(xs: Seq[YamlNode]) extends YamlNode + case class YamlMap(m: Map[YamlNode,YamlNode]) extends YamlNode + case class YamlStr(s: String) extends YamlNode + case class YamlNil extends YamlNode + def yaml(s: String) = { + def r(x: AnyRef): YamlNode = { + x match { + case null => YamlNil() + case x: java.util.HashMap[_,_] => YamlMap(Map({ + val m = x.asInstanceOf[java.util.HashMap[AnyRef,AnyRef]] + for ((a,b) <- new jcl.HashMap(m)) + yield (r(a), r(b)) + } toStream: _*)) + case x: java.util.ArrayList[_] => YamlSeq( + new jcl.ArrayList(x.asInstanceOf[java.util.ArrayList[String]]) map r + ) + case x: String => YamlStr(x) + } + } + r(Yaml.load(s)) + } + def main(args: Array[String]) { + try { + val rawfname = if (args.length > 0) args(0) else "build" + val infile = new File(rawfname).getCanonicalFile + val fname = infile.getPath + val srcdir = infile.getParent + // Read build file. + val contents = doOrDie { + using (TextReader(fname)) (_.read) + } { + e => "could not open file: " + fname + } + val build = yaml(contents) + // For each target, emit a make frag. + val aggs = multimap(List[(String,String)]()) + val targets = for ((target, attrs) <- build.m) yield { + val srcs = attrs.m(YamlStr("srcs")).xs + val (template,struct) = templateByFilename(srcs(0).s) + val hdrs = ( + for ((k,v) <- attrs.m.elements ++ List((YamlStr("target"), target)) + if v.isInstanceOf[YamlStr] || v.isInstanceOf[YamlSeq]) + yield k.s.toUpperCase + " := " + (v match { + case YamlSeq(xs) => xs map (_.s) map (rel2abs(srcdir,_)) mkString (struct(k.s) split "|" last) + case YamlStr(s) => s + }) + ) mkString "\n" + val site = "PREFIX := /opt/" + target.s + "\nBINDIR := $(PREFIX)/bin\n" + val rules = instantiate(site + '\n' + hdrs + "\n\n" + template, aggs) + emitMakeFrag(target.s, rules) + target.s + } + // Makefiles. + using (TextWriter("GNUmakefile")) { w => + w println "OUTDIR := " + pwd / "out" + w println "SRCDIR := " + srcdir + w println "SRCPATH := " + srcdir + w println ("all: " + (targets mkString " ")) + w println(targets map ("include "+_+".mk") mkString "\n") + w println ((for ((k,vs) <- aggs) yield (k + ": " + (vs mkString " "))) mkString "\n") + w println ("clean:\n\trm -rf out") + w println ("GNUmakefile: " + srcdir + "/build\n\tbuild.bash build") + w println (".PHONY: clean") + } + } catch { + // Catch-all for handled exceptions (the rest should be displayed in + // their full ugly glory). + case HandledException(e) => () + } + } +} Added: simple-build/trunk/src/build =================================================================== --- simple-build/trunk/src/build (rev 0) +++ simple-build/trunk/src/build 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,8 @@ +simple-build: + mainclass: SimpleBuild + srcs: [SimpleBuild.scala] + classpath: [jyaml-1.3.jar] + +#hashjoin: +# srcs: [hashjoin.cc] +# libs: [pthreads] Added: simple-build/trunk/src/build-templates/Makefile =================================================================== --- simple-build/trunk/src/build-templates/Makefile (rev 0) +++ simple-build/trunk/src/build-templates/Makefile 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,9 @@ +TARGET := asdf +SRCS := src/asdf.c +OUTDIR := out +include common.mk + +TARGET := Asdf +SRCDIR := . +SRCS := Asdf.scala +include scala.mk Added: simple-build/trunk/src/build-templates/common.mk =================================================================== --- simple-build/trunk/src/build-templates/common.mk (rev 0) +++ simple-build/trunk/src/build-templates/common.mk 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,12 @@ +VARIANT := dbg +VARIANT_CFLAGS := -g3 +include variant.mk + +VARIANT := opt +VARIANT_CFLAGS := -O3 +include variant.mk + +clean: + rm -rf $(OUTDIR) + +.PHONY: clean Added: simple-build/trunk/src/build-templates/cpp =================================================================== --- simple-build/trunk/src/build-templates/cpp (rev 0) +++ simple-build/trunk/src/build-templates/cpp 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,7 @@ +[instantiate variant.mk] + VARIANT := dbg + VARIANT_CFLAGS := -g3 + +[instantiate variant.mk] + VARIANT := opt + VARIANT_CFLAGS := -O3 Added: simple-build/trunk/src/build-templates/scala =================================================================== --- simple-build/trunk/src/build-templates/scala (rev 0) +++ simple-build/trunk/src/build-templates/scala 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,38 @@ +# Output locations. + +SCRIPT := $(OUTDIR)/$(TARGET) +ifeq (,$(VERSION)) + JAR := $(OUTDIR)/$(TARGET).jar +else + JAR := $(OUTDIR)/$(TARGET)-$(VERSION).jar +endif +CLASSDIR := $(OUTDIR)/$(TARGET)-classes + +# Flags. + +SRCPATH := $(SRCPATH):$(SCALA_COMMONS_SRC) +SFLAGS := -deprecation -unchecked -sourcepath $(SRCPATH) -d $(CLASSDIR) -cp $(CLASSPATH) +SCALAC := capture-scala-deps $(JAR) $(OUTDIR)/.deps fsc -verbose + +$(TARGET): $(SCRIPT) $(JAR) + +$(SCRIPT): $(MAKEFILE_LIST) + mkdir -p $(@D) + echo "#!/usr/bin/env bash\n\nJAVA_OPTS=\"$(JRUNFLAGS) \$${JAVA_OPTS:-}\" exec scala -cp $(JAR):$(CLASSPATH) $(MAINCLASS) \"\$$@\"" > $(SCRIPT) + chmod +x $(SCRIPT) + +$(JAR): $(SRCS) + mkdir -p $(CLASSDIR) + $(SCALAC) $(SFLAGS) $< + jar cf $@ -C $(CLASSDIR) . + +-include $(OUTDIR)/.deps + +install: $(TARGET) + mkdir -p $(BINDIR) + cp $(SCRIPT) $(BINDIR) + +clean: + rm -rf $(SCRIPT) $(JAR) $(CLASSDIR) + +.PHONY: $(TARGET) clean Added: simple-build/trunk/src/build-templates/scala.mk.part =================================================================== --- simple-build/trunk/src/build-templates/scala.mk.part (rev 0) +++ simple-build/trunk/src/build-templates/scala.mk.part 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,14 @@ +# Global environment variable (if missing, then Scala Commons should be +# available on the classpath). + +SCALA_COMMONS_SRC := ~/scom + +# Project settings. + +TARGET := myapp +MAINCLASS := myapp.MyApp +OUTDIR := out +SRCPATH := . +SRCS := MyApp.scala Other.scala +JRUNFLAGS := -Xmx512M +CLASSPATH := Added: simple-build/trunk/src/build-templates/variant.mk =================================================================== --- simple-build/trunk/src/build-templates/variant.mk (rev 0) +++ simple-build/trunk/src/build-templates/variant.mk 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,34 @@ +OUTDIR := $(OUTDIR)/$(VARIANT) +CFLAGS := $(CFLAGS) $(CFLAGS) +CXXFLAGS := $(CXXFLAGS) $(CXXFLAGS) +CPPFLAGS := $(CPPFLAGS) +LDFLAGS := $(LDFLAGS) $(LIBS) + +OBJS := $(foreach src,$(SRCS),$(OUTDIR)/$(patsubst %.c,%.o,$(src))) + +CC := gcc +CXX := g++ + +$(VARIANT): $(OUTDIR)/$(TARGET) + +$(OUTDIR)/$(TARGET): $(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ + +$(OUTDIR)/%.o: %.c + mkdir -p $(@D) + $(CC) $(CPPFLAGS) $(CFLAGS) -MD -c -o $@ $< + +$(OUTDIR)/%.o: %.cc + mkdir -p $(@D) + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -c -o $@ $< + +$(OUTDIR)/.deps: $(shell find $(OUTDIR) -name '*.d' 2> /dev/null || true) + mkdir -p $(OUTDIR) + [ "$^" ] && cat $^ > $@ + +-include $(OUTDIR)/.deps + +clean: + rm -rf $(OUTDIR) + +.PHONY: clean Added: simple-build/trunk/src/build.bash =================================================================== --- simple-build/trunk/src/build.bash (rev 0) +++ simple-build/trunk/src/build.bash 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +. common.bash + +userfiles=( AUTHORS ChangeLog NEWS README ) + +build() { + # XXX fix this path (assume it's installed) + "$( dirname "$0" )/out/simple-build" "$@" +} + +gnu-proj() { + # Find all includes. + # Generate rules. + touch -a "${userfiles[@]}" + autoreconf -iv +} + +clean() { + [ -f Makefile ] && make -s distclean + rm -rf aclocal.m4 config.h.in configure COPYING INSTALL install-sh missing depcomp autom4te.cache Makefile.in + rm-empty "${userfiles[@]}" +} + +"$@" Property changes on: simple-build/trunk/src/build.bash ___________________________________________________________________ Name: svn:executable + * Added: simple-build/trunk/src/capture-scala-deps =================================================================== --- simple-build/trunk/src/capture-scala-deps (rev 0) +++ simple-build/trunk/src/capture-scala-deps 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,41 @@ +#!/usr/bin/env bash + +set -o errexit -o nounset + +target="$1" +depsfile="$2" +shift; shift + +# Get the top-level source files. This is no longer used. +mainsrcs=() +for i in "$@" ; do + if [[ "${i%.scala}" != "$i" ]] + then mainsrcs=( "${mainsrcs[@]:-$i}" "$i" ) + fi +done + +# Run the compiler. +"$@" | while read line ; do + if [[ "${line#[}" == "$line" ]] ; then + # Line doesn't start with '[' (normal output). + echo "$line" + else + # Line starts with '[' (verbose output). + echo "$line" 1>&3 + fi +done 3> >( + { + # Parse just the verbose output and emit the deps file. + echo "$target: \\" + sed -n ' + /^\[loaded source file / { + s/^\[loaded source file \(.*\) in [[:digit:]]*ms\]/\1/ + p + } + ' | sed ' + { s/^/\t/; s/$/ \\/ } + $ { a\\t + } + ' + } > "$depsfile" +) Property changes on: simple-build/trunk/src/capture-scala-deps ___________________________________________________________________ Name: svn:executable + * Added: simple-build/trunk/src/setup.bash =================================================================== --- simple-build/trunk/src/setup.bash (rev 0) +++ simple-build/trunk/src/setup.bash 2008-02-16 21:37:39 UTC (rev 456) @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +pkg=simple-build +. simple-setup.bash + +install bin/ build.bash capture-scala-deps Property changes on: simple-build/trunk/src/setup.bash ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-16 04:46:41
|
Revision: 455 http://assorted.svn.sourceforge.net/assorted/?rev=455&view=rev Author: yangzhang Date: 2008-02-15 20:46:41 -0800 (Fri, 15 Feb 2008) Log Message: ----------- added basic autotools Added Paths: ----------- hash-join/trunk/Makefile.am hash-join/trunk/configure.ac Added: hash-join/trunk/Makefile.am =================================================================== --- hash-join/trunk/Makefile.am (rev 0) +++ hash-join/trunk/Makefile.am 2008-02-16 04:46:41 UTC (rev 455) @@ -0,0 +1,2 @@ +bin_PROGRAMS = hashjoin +hashjoin_SOURCES = src/hashjoin.cc Added: hash-join/trunk/configure.ac =================================================================== --- hash-join/trunk/configure.ac (rev 0) +++ hash-join/trunk/configure.ac 2008-02-16 04:46:41 UTC (rev 455) @@ -0,0 +1,35 @@ +# TODO: header-checking does nothing +# TODO: replace with simple-build +# -*- Autoconf -*- +# Process this file with autoconf to produce a configure script. + +AC_PREREQ(2.61) +AC_INIT(hash-join, 0.1, gmail:yaaang) +AM_INIT_AUTOMAKE(cppcommons, 0.1) +AC_CONFIG_SRCDIR([src/hashjoin.cc]) +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CXX + +# Checks for libraries. +#### AC_CHECK_LIB([profile], [main]) +AC_CHECK_LIB([pthread], [pthread_create]) + +# Checks for header files. +AC_CHECK_HEADERS([fcntl.h sys/time.h]) +AC_CHECK_HEADERS([boost/any.h]) +AC_CHECK_HEADERS([commons/check.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_HEADER_STDBOOL +AC_C_CONST +AC_C_INLINE +AC_TYPE_SIZE_T + +# Checks for library functions. +AC_HEADER_STDC +AC_CHECK_FUNCS([strchr]) + +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-15 18:46:57
|
Revision: 454 http://assorted.svn.sourceforge.net/assorted/?rev=454&view=rev Author: yangzhang Date: 2008-02-15 10:47:01 -0800 (Fri, 15 Feb 2008) Log Message: ----------- moved cppcommons.cpp to test/all.cc Added Paths: ----------- cpp-commons/trunk/src/test/all.cc Removed Paths: ------------- cpp-commons/trunk/src/commons/cppcommons.cpp Deleted: cpp-commons/trunk/src/commons/cppcommons.cpp =================================================================== --- cpp-commons/trunk/src/commons/cppcommons.cpp 2008-02-15 18:46:09 UTC (rev 453) +++ cpp-commons/trunk/src/commons/cppcommons.cpp 2008-02-15 18:47:01 UTC (rev 454) @@ -1,35 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Yang Zhang * - * gmail:yaaang * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU Library General Public License as * - * published by the Free Software Foundation; either version 2 of the * - * License, or (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <commons/boost/threads.h> -#include <commons/check.h> -#include <commons/cpuid.h> -#include <commons/files.h> -#include <commons/hash.h> -#include <commons/strings.h> -#include <commons/time.h> -#include <commons/threads.h> -#include <commons/x86asm.h> - Copied: cpp-commons/trunk/src/test/all.cc (from rev 446, cpp-commons/trunk/src/commons/cppcommons.cpp) =================================================================== --- cpp-commons/trunk/src/test/all.cc (rev 0) +++ cpp-commons/trunk/src/test/all.cc 2008-02-15 18:47:01 UTC (rev 454) @@ -0,0 +1,35 @@ +/*************************************************************************** + * Copyright (C) 2007 by Yang Zhang * + * gmail:yaaang * + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU Library General Public License as * + * published by the Free Software Foundation; either version 2 of the * + * License, or (at your option) any later version. * + * * + * This program is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this program; if not, write to the * + * Free Software Foundation, Inc., * + * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * + ***************************************************************************/ + + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif + +#include <commons/boost/threads.h> +#include <commons/check.h> +#include <commons/cpuid.h> +#include <commons/files.h> +#include <commons/hash.h> +#include <commons/strings.h> +#include <commons/time.h> +#include <commons/threads.h> +#include <commons/x86asm.h> + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <yan...@us...> - 2008-02-15 18:46:08
|
Revision: 453 http://assorted.svn.sourceforge.net/assorted/?rev=453&view=rev Author: yangzhang Date: 2008-02-15 10:46:09 -0800 (Fri, 15 Feb 2008) Log Message: ----------- added simple-setup to cpp-commons Added Paths: ----------- cpp-commons/trunk/setup.bash Added: cpp-commons/trunk/setup.bash =================================================================== --- cpp-commons/trunk/setup.bash (rev 0) +++ cpp-commons/trunk/setup.bash 2008-02-15 18:46:09 UTC (rev 453) @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +pkg=cpp-commons +. simple-setup.bash +version=0.1 +install include/ src/commons Property changes on: cpp-commons/trunk/setup.bash ___________________________________________________________________ Name: svn:executable + * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |