Commit 0928c428 authored by Anders Blomdell's avatar Anders Blomdell
Browse files

Made ant tasks short-circuit if target already exists.

parent 380bdf74
...@@ -4,10 +4,6 @@ export LABCOMM=java -jar $(LABCOMM_JAR) ...@@ -4,10 +4,6 @@ export LABCOMM=java -jar $(LABCOMM_JAR)
all: $(SUBDIRS:%=make-%) all: $(SUBDIRS:%=make-%)
.PHONY: make-compiler
make-compiler:
cd compiler ; ant jar
.PHONY: make-% .PHONY: make-%
make-%: make-%:
LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e
...@@ -15,10 +11,6 @@ make-%: ...@@ -15,10 +11,6 @@ make-%:
.PHONY: test .PHONY: test
test: $(SUBDIRS:%=test-%) test: $(SUBDIRS:%=test-%)
.PHONY: test-compiler
test-compiler:
$(MAKE) -C test compiler_errors
.PHONY: test-% .PHONY: test-%
test-%: test-%:
LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e test LD_LIBRARY_PATH=`pwd`/lib/c $(MAKE) -C $* -e test
...@@ -26,10 +18,6 @@ test-%: ...@@ -26,10 +18,6 @@ test-%:
.PHONY: clean .PHONY: clean
clean: $(SUBDIRS:%=clean-%) clean: $(SUBDIRS:%=clean-%)
.PHONY: clean-compiler
clean-compiler:
cd compiler ; ant clean
.PHONY: clean-% .PHONY: clean-%
clean-%: clean-%:
$(MAKE) -C $* -e clean $(MAKE) -C $* -e clean
...@@ -37,10 +25,6 @@ clean-%: ...@@ -37,10 +25,6 @@ clean-%:
.PHONY: distclean .PHONY: distclean
distclean: $(SUBDIRS:%=distclean-%) distclean: $(SUBDIRS:%=distclean-%)
.PHONY: distclean-compiler
distclean-compiler:
cd compiler ; ant clean
.PHONY: distclean-% .PHONY: distclean-%
distclean-%: distclean-%:
$(MAKE) -C $* -e distclean $(MAKE) -C $* -e distclean
all:
%:
ant $*
...@@ -6,17 +6,11 @@ ...@@ -6,17 +6,11 @@
gen - generates java files gen - generates java files
cleanGen - removes all generated files and their class files cleanGen - removes all generated files and their class files
--> -->
<project name="LabComm" default="build" basedir="."> <project name="LabComm" default="all" basedir=".">
<!-- "package" is the directory where generated files will be stored -->
<property name="package" value="AST"/>
<!-- "tools" is the directory where generators and libraries are located. --> <!-- "tools" is the directory where generators and libraries are located. -->
<property name="tools" value="tools"/> <property name="tools" value="tools"/>
<!-- "test" is the directory where tests are located. -->
<property name="test" value="../test"/>
<!-- "jflex" is an ant task class for the scanner generator in JFlex.jar --> <!-- "jflex" is an ant task class for the scanner generator in JFlex.jar -->
<taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/> <taskdef name="jflex" classname="JFlex.anttask.JFlexTask" classpath="tools/JFlex.jar"/>
<!-- "beaver" is an ant task class for the parser generator in beaver.jar --> <!-- "beaver" is an ant task class for the parser generator in beaver.jar -->
...@@ -25,80 +19,19 @@ ...@@ -25,80 +19,19 @@
<taskdef name="jastadd" classname="jastadd.JastAddTask" <taskdef name="jastadd" classname="jastadd.JastAddTask"
classpath="tools/jastadd2.jar"/> classpath="tools/jastadd2.jar"/>
<target name="jastadd.cu">
<!-- compile sources --> <uptodate property="jastadd.u">
<target name="test" depends="jar"> <srcfiles dir='.'>
<echo message = "Running tests"/> <include name="${version}/*.ast"/>
<exec executable="./run" dir="../test"> <include name="${version}/*.jrag"/>
<env key="PYTHONPATH" value="../lib/python"/> <include name="${version}/*.jadd"/>
<!--arg value="hej"/--> </srcfiles>
</exec> <mapper type="merge"
</target> to="${outdir}/${package_path}/jastadd.uptodate"/>
</uptodate>
<!-- remove generated source files and .class files -->
<target name="clean" depends="cleanGen">
<!-- delete all .class files recursively -->
<delete dir="gen"/>
<delete>
<fileset dir="." includes="**/*.class"/>
<fileset dir="." includes="gen"/>
<fileset dir="." includes="labcomm_compiler.jar"/>
</delete>
</target>
<!-- remove generated source files and their .class files -->
<target name="cleanGen">
<delete dir="${package}"/>
</target>
<target name="jar_version" depends="build">
<jar destfile="labcomm${version}_compiler.jar">
<fileset dir="gen"
includes="se/lth/control/labcomm${version}/compiler/*.class"/>
<zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
<manifest>
<attribute name="Main-Class"
value="se.lth.control.labcomm${version}.compiler.LabComm"/>
</manifest>
</jar>
</target>
<target name="jar" depends="build">
<antcall target="jar_version">
<param name="version" value="2006"/>
</antcall>
<antcall target="jar_version">
<param name="version" value="2014"/>
</antcall>
<jar destfile="labcomm_compiler.jar">
<fileset dir="gen" includes="**/*.class"/>
<zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
<manifest>
<attribute name="Main-Class" value="LabComm"/>
</manifest>
</jar>
</target> </target>
<!-- generate compiler source files --> <target name="jastadd" depends="jastadd.cu" unless="jastadd.u">
<target name="gen_compiler_version">
<local name="package"/>
<local name="package_path"/>
<property name="package" value="se.lth.control.labcomm${version}.compiler"/>
<loadresource property="package_path">
<propertyresource name="package"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="." to="/"/>
</tokenfilter>
</filterchain>
</loadresource>
<mkdir dir="${outdir}"/>
<!-- create AST node types and weave aspect modules -->
<echo message = "Running JastAdd"/> <echo message = "Running JastAdd"/>
<jastadd package="${package}" rewrite="true" beaver="true" <jastadd package="${package}" rewrite="true" beaver="true"
novisitcheck="true" lazyMaps="true" outdir="${outdir}"> novisitcheck="true" lazyMaps="true" outdir="${outdir}">
...@@ -108,21 +41,59 @@ ...@@ -108,21 +41,59 @@
<include name="${version}/*.jadd"/> <include name="${version}/*.jadd"/>
</fileset> </fileset>
</jastadd> </jastadd>
<touch file="${outdir}/${package_path}/jastadd.uptodate"/>
</target>
<!-- generate the scanner --> <target name="scanner.cu">
<echo message = "Running jflex -> ${package} ${package_path}"/> <uptodate property="scanner.u">
<srcfiles dir='.'>
<include name="${version}/LabCommScanner.flex"/>
<!--include name="${tools}/JFlex.jar"/-->
</srcfiles>
<mapper type="merge"
to="./gen/se/lth/control/labcomm${version}/compiler/LabCommScanner.java"/>
</uptodate>
</target>
<target name="scanner" depends="scanner.cu" unless="scanner.u">
<echo message = "Generating scanner ${version}"/>
<echo message = "Running jflex -> ${package} ${outdir}/${package_path}"/>
<jflex file="${version}/LabCommScanner.flex" <jflex file="${version}/LabCommScanner.flex"
outdir="${outdir}/${package_path}" nobak="yes"/> outdir="${outdir}/${package_path}" nobak="yes"/>
</target>
<target name="parser.1.cu">
<uptodate property="parser.1.u">
<srcfiles dir='.'>
<include name="${version}/*.parser"/>
</srcfiles>
<mapper type="merge"
to="${outdir}/${package_path}/LabCommParser.all"/>
</uptodate>
</target>
<target name="parser.1" depends="parser.1.cu" unless="parser.1.u">
<!-- generate the parser phase 1, create a full .lalr specification <!-- generate the parser phase 1, create a full .lalr specification
from fragments--> from fragments-->
<echo message = "Running parser phase 1"/> <echo message = "Joining parser fragments"/>
<concat destfile="${outdir}/${package_path}/LabCommParser.all" binary="true"> <concat destfile="${outdir}/${package_path}/LabCommParser.all" binary="true">
<fileset dir="."> <fileset dir=".">
<include name="${version}/*.parser"/> <include name="${version}/*.parser"/>
</fileset> </fileset>
</concat> </concat>
</target>
<target name="parser.2.cu">
<uptodate property="parser.2.u">
<srcfiles dir='.'>
<include name="${outdir}/${package_path}/LabCommParser.all"/>
</srcfiles>
<mapper type="merge"
to="${outdir}/${package_path}/LabCommParser.beaver"/>
</uptodate>
</target>
<target name="parser.2" depends="parser.1, parser.2.cu" unless="parser.2.u">
<!-- generate the parser phase 2, translating .lalr to .beaver --> <!-- generate the parser phase 2, translating .lalr to .beaver -->
<echo message = "translating .lalr to .beaver"/> <echo message = "translating .lalr to .beaver"/>
<java fork="true" dir="${basedir}" <java fork="true" dir="${basedir}"
...@@ -130,43 +101,165 @@ ...@@ -130,43 +101,165 @@
<arg line="${outdir}/${package_path}/LabCommParser.all <arg line="${outdir}/${package_path}/LabCommParser.all
${outdir}/${package_path}/LabCommParser.beaver"/> ${outdir}/${package_path}/LabCommParser.beaver"/>
</java> </java>
</target>
<target name="parser.3.cu">
<uptodate property="parser.3.u">
<srcfiles dir='.'>
<include name="${outdir}/${package_path}/LabCommParser.beaver"/>
</srcfiles>
<mapper type="merge"
to="${outdir}/${package_path}/LabCommParser.java"/>
</uptodate>
</target>
<!-- generate the parser phase 3, translating .beaver to .java --> <target name="parser.3" depends="parser.2, parser.3.cu" unless="parser.3.u">
<echo message = "translating .beaver to .java"/> <echo message = "translating .beaver to .java"/>
<beaver file="${outdir}/${package_path}/LabCommParser.beaver" <beaver file="${outdir}/${package_path}/LabCommParser.beaver"
terminalNames="yes" compress="yes" useSwitch="yes"/> terminalNames="yes" compress="yes" useSwitch="yes"/>
</target>
<echo message = "compiling .java"/> <target name="all.version" depends="jastadd, scanner, parser.3">
<!-- </target>
<javac debug="true" srcdir="." destdir="${outdir}"
includes="${version}/*.java ${outdir}/${package_path}/*.java" <target name="compile.cu">
<uptodate property="compile.u">
<srcfiles dir='.'>
<include name="*.java"/>
<include name="2006/*.java"/>
<include name="2014/*.java"/>
<include name="${outdir}/**/*.java"/>
</srcfiles>
<mapper type="merge"
to="${outdir}/compile.uptodate"/>
</uptodate>
</target>
<target name="compile" depends="compile.cu" unless="compile.u">
<echo message = "compiling"/>
<javac debug="true" srcdir="." destdir="gen"
includes="*.java 2006/*.java 2014/*.java gen/**/*.java"
classpath="gen:${tools}/beaver-rt.jar:${tools}/junit.jar" classpath="gen:${tools}/beaver-rt.jar:${tools}/junit.jar"
includeantruntime="false" includeantruntime="false"
fork="true" memoryMaximumSize="128M"> fork="true" memoryMaximumSize="128M">
<!- -compilerarg value="-Xlint"/- -> <!--compilerarg value="-Xlint"/-->
</javac> </javac>
--> <touch file="${outdir}/compile.uptodate"/>
</target>
<target name="jar.version.cu">
<uptodate property="jar.version.u">
<srcfiles dir=".">
<include name="${outdir}/${package_path}/*.class"/>
</srcfiles>
<mapper type="merge"
to="labcomm${version}_compiler.jar"/>
</uptodate>
</target>
<target name="jar.version" depends="jar.version.cu" unless="jar.version.u">
<echo message = "Generating labcomm${version}_compiler.jar"/>
<jar destfile="labcomm${version}_compiler.jar">
<fileset dir="${outdir}"
includes="${package_path}/*.class"/>
<zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
<manifest>
<attribute name="Main-Class"
value="${package}.LabComm"/>
</manifest>
</jar>
</target> </target>
<target name="build"> <target name="jar.all.cu">
<antcall target="gen_compiler_version"> <uptodate property="jar.all.u">
<srcfiles dir=".">
<include name="${outdir}/**/*.class"/>
</srcfiles>
<mapper type="merge"
to="labcomm_compiler.jar"/>
</uptodate>
</target>
<target name="jar.all" depends="jar.all.cu" unless="jar.all.u">
<echo message = "Generating labcomm_compiler.jar"/>
<jar destfile="labcomm_compiler.jar">
<fileset dir="${outdir}"
includes="**/*.class"/>
<zipfileset src="tools/beaver-rt.jar" includes="beaver/*.class"/>
<manifest>
<attribute name="Main-Class"
value="LabComm"/>
</manifest>
</jar>
</target>
<target name="do.version">
<!-- Wrapper that sets up package and package_path based on ${version} -->
<local name="package"/>
<local name="package_path"/>
<property name="package" value="se.lth.control.labcomm${version}.compiler"/>
<loadresource property="package_path">
<propertyresource name="package"/>
<filterchain>
<tokenfilter>
<filetokenizer/>
<replacestring from="." to="/"/>
</tokenfilter>
</filterchain>
</loadresource>
<echo>${do} ${version} ${outdir}</echo>
<mkdir dir="${outdir}"/>
<antcall target="${do}">
<param name="version" value="${version}"/>
<param name="outdir" value="${outdir}"/>
<param name="package" value="${package}"/>
<param name="package_path" value="${package_path}"/>
</antcall>
</target>
<target name="all">
<antcall target="do.version">
<param name="do" value="all.version"/>
<param name="version" value="2006"/> <param name="version" value="2006"/>
<param name="outdir" value="gen"/> <param name="outdir" value="gen"/>
</antcall> </antcall>
<antcall target="gen_compiler_version"> <antcall target="do.version">
<param name="do" value="all.version"/>
<param name="version" value="2014"/> <param name="version" value="2014"/>
<param name="outdir" value="gen"/> <param name="outdir" value="gen"/>
</antcall> </antcall>
<echo message = "compiling main"/> <antcall target="compile">
<javac debug="true" srcdir="." destdir="gen" <param name="outdir" value="gen"/>
includes="*.java 2006/*.java 2014/*.java gen/**/*.java" </antcall>
classpath="gen:${tools}/beaver-rt.jar:${tools}/junit.jar" <antcall target="do.version">
includeantruntime="false" <param name="do" value="jar.version"/>
fork="true" memoryMaximumSize="128M"> <param name="version" value="2006"/>
<!--compilerarg value="-Xlint"/--> <param name="outdir" value="gen"/>
</javac> </antcall>
<antcall target="do.version">
<param name="do" value="jar.version"/>
<param name="version" value="2014"/>
<param name="outdir" value="gen"/>
</antcall>
<antcall target="jar.all">
<param name="outdir" value="gen"/>
</antcall>
</target> </target>
<target name="clean">
<delete dir="gen"/>
</target>
<target name="distclean" depends="clean">
<delete>
<fileset dir="." includes="labcomm*_compiler.jar"/>
</delete>
</target>
<target name="test">
<echo>No tests defined yet</echo>
</target>
</project> </project>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment