Commits

Meikel Brandmeyer committed ec11767

Switch to Makefile instead of ant

Comments (0)

Files changed (9)

+PROJECT := lazy-map
+
+SRCDIR  := src
+DISTDIR := dist
+
+JAVASRC != cd ${SRCDIR} && find * -type f -name \*.java
+CLJSRC  != cd ${SRCDIR} && find * -type f \( -name \*.clj -and -not -name \*.gen.clj \)
+GCCLJSRC!= cd ${SRCDIR} && find * -type f -name \*.gen.clj
+DIRS    != cd ${SRCDIR} && find * -type d
+
+VERSION != shtool version -d short version.txt
+JAR     := ${PROJECT}-${VERSION}.jar
+TGZ     := ${PROJECT}-${VERSION}.tar.gz
+
+all: jar
+
+release: jar tarball
+
+jar: ${JAR}
+
+tarball: ${TGZ}
+
+test: jar
+	env CLASSPATH=${JAR}:$${CLASSPATH} prove t
+
+doc: compile
+	( cat README.txt.in; \
+	  java clojure.lang.Script gen-docs.clj ) > README.txt
+
+clean:
+	rm -rf ${DISTDIR} ${JAR} ${TGZ} README.txt
+
+compile: ${CLJSRC:C/^/dist\//} ${GCCLJSRC:R:R:C/^/dist\//:C/$/.class/}
+
+.for _clj in ${CLJSRC}
+dist/${_clj}: src/${_clj} ${DISTDIR}
+	shtool install -c src/${_clj} dist/${_clj}
+.endfor
+
+.for _clj in ${GCCLJSRC}
+dist/${_clj:R:R}.class: src/${_clj} ${DISTDIR}
+	java clojure.lang.Script gen-class.clj -- ${DISTDIR} ${_clj}
+.endfor
+
+${JAR}: doc compile
+	cp README.txt ${DISTDIR}
+	cp LICENSE ${DISTDIR}
+	jar cf ${JAR} -C ${DISTDIR} .
+
+${TGZ}: doc
+	shtool tarball -c "gzip -9" -o ${TGZ} \
+		-e '\.DS_Store,${DISTDIR},\.jar,\.hg,\.tar\.gz' .
+
+${DISTDIR}:
+	shtool mkdir -p ${DISTDIR}
+	@for dir in ${DIRS}; do \
+		echo shtool mkdir -p ${DISTDIR}/$${dir}; \
+		shtool mkdir -p ${DISTDIR}/$${dir}; \
+	done
+
+.PHONY: all release jar tarball test doc clean compile
+          ______                     ______  ___
+          ___  / ______ __________  ____   |/  /_____ ________
+          __  /  _  __ `/__  /_  / / /_  /|_/ /_  __ `/__  __ \
+          _  /___/ /_/ /__  /_  /_/ /_  /  / / / /_/ /__  /_/ /
+          /_____/\__,_/ _____/\__, / /_/  /_/  \__,_/ _  .___/
+                             /____/                   /_/
+
+LazyMap is a transparent wrapper around the map types of Clojure. It works
+similar to lazy-cons for lists: the value associated with a key via lazy-assoc
+is not evaluated until it is actually accessed. So if the value is dissoc'd
+before it is accessed the code necessary to generate the value is not executed
+at all.
+
+Meikel Brandmeyer <mb@kotka.de>,
+Frankfurt am Main, 2008
+
+Reference Documentation in alphabetical order:
+

build.xml

-<project name="lazymap" default="jar">
-
-	<description>
-		Build with "ant jar".
-	</description>
-
-	<property name="src" location="src"/>
-	<property name="build" location="dist"/>
-	<property name="jar" location="lazymap.jar"/>
-
-	<target name="init">
-		<tstamp/>
-		<mkdir dir="${build}"/>
-	</target>
-
-	<target name="java.compile" depends="init"
-		description="Compile Java sources.">
-		<javac srcdir="${src}" includes="**/*.java" destdir="${build}"
-			includeJavaRuntime="yes" debug="true"/>
-	</target>
-
-	<target name="clj.compile" depends="init"
-		description="Compile Clojure sources.">
-		<copy todir="${build}">
-			<fileset dir="src" includes="**/*.clj" excludes="**/*.gen.clj"/>
-		</copy>
-		<java classname="clojure.lang.Script">
-			<arg value="genclasses.clj"/>
-		</java>
-	</target>
-
-	<target name="jar" depends="java.compile,clj.compile"
-		description="Create jar file.">
-		<jar jarfile="${jar}" basedir="${build}">
-			<manifest>
-				<attribute name="Class-Path" value="."/>
-			</manifest>
-		</jar>
-	</target>
-
-	<target name="clean"
-		description="Remove autogenerated files and directories.">
-		<delete dir="${build}"/>
-		<delete file="${jar}"/>
-	</target>
-
-</project>
-<!-- vim: set ts=4 sw=4 : -->
+;-
+; Copyright 2008 (c) Meikel Brandmeyer.
+; All rights reserved.
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+; THE SOFTWARE.
+
+(def *builddir* (first *command-line-args*))
+
+(doseq c (rest *command-line-args*)
+  (load-file (str "src/" c)))
+;-
+; Copyright 2008 (c) Meikel Brandmeyer.
+; All rights reserved.
+;
+; Permission is hereby granted, free of charge, to any person obtaining a copy
+; of this software and associated documentation files (the "Software"), to deal
+; in the Software without restriction, including without limitation the rights
+; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+; copies of the Software, and to permit persons to whom the Software is
+; furnished to do so, subject to the following conditions:
+;
+; The above copyright notice and this permission notice shall be included in
+; all copies or substantial portions of the Software.
+;
+; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+; THE SOFTWARE.
+
+(require 'de.kotka.lazymap)
+
+(let [c  (proxy [java.util.Comparator] []
+           (compare
+             [a b]
+             (let [as (str a)
+                   bs (str b)]
+               (. as compareTo bs))))
+      vs (map (fn [[n v]] v) (ns-publics (find-ns 'de.kotka.lazymap)))]
+  (doseq v (sort c vs)
+    (let [d ((meta v) :doc)]
+      (when d (print-doc v)))))

genclasses.clj

-;-
-; Copyright 2008 (c) Meikel Brandmeyer.
-; All rights reserved.
-;
-; Permission is hereby granted, free of charge, to any person obtaining a copy
-; of this software and associated documentation files (the "Software"), to deal
-; in the Software without restriction, including without limitation the rights
-; to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-; copies of the Software, and to permit persons to whom the Software is
-; furnished to do so, subject to the following conditions:
-;
-; The above copyright notice and this permission notice shall be included in
-; all copies or substantial portions of the Software.
-;
-; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-; IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-; FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-; AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-; LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-; THE SOFTWARE.
-
-(let [classes ["LazyMapEntry"
-               "LazyMapSeq"
-               "LazyMapClass"]]
-  (doseq cf classes
-    (load-file (str "src/de/kotka/lazymap/" cf ".gen.clj"))))

src/de/kotka/lazymap/LazyMapClass.gen.clj

 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(gen-and-save-class "dist" 'de.kotka.lazymap.LazyMapClass
+(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapClass
   :init         'init
   :state        'theMap
-  :methods      [['lazyAssoc [Object Object] de.kotka.lazymap.LazyMapClass]]
+  :methods      [['lazyAssoc [Object Object] clojure.lang.IPersistentMap]]
   :implements   [clojure.lang.IPersistentMap clojure.lang.IFn]
   :constructors {[clojure.lang.IPersistentMap] []})

src/de/kotka/lazymap/LazyMapEntry.gen.clj

 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(gen-and-save-class "dist" 'de.kotka.lazymap.LazyMapEntry
+(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapEntry
   :init         'init
   :state        'theState
   :methods      [['getRawValue [] clojure.lang.Delay]]

src/de/kotka/lazymap/LazyMapSeq.gen.clj

 ; OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 ; THE SOFTWARE.
 
-(gen-and-save-class "dist" 'de.kotka.lazymap.LazyMapSeq
+(gen-and-save-class *builddir* 'de.kotka.lazymap.LazyMapSeq
   :init         'init
   :state        'theSeq
   :implements   [clojure.lang.ISeq]