[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: compiling SableCc natively



I've included the separate buildexe.xml file, that I've used to build
sablecc.exe. It definitely needs some cleaning up as well. (I'm not an Ant
exegete. I've only started using Ant a few weeks ago.). I'm almost
completely sure that the same target will build unmodified both on Linux and
win2K. There is, most likely, no need for separate targets.

And the targets should probably be integrated into the mainstream build.xml.

And the lines like:

<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.parser.Parser.parser.dat -o
res/parserself.o -c src/org/sablecc/sablecc/parser/parser.dat"/>
</exec>

should, along your suggestions, be simplified to:

<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.parser.parser.dat -o
res/parserself.o -c src/org/sablecc/sablecc/parser/parser.dat"/>
</exec>

By the way, there are potentially two "parser.o" files; there is the
parser/parser.dat file and the parser.txt file. I've called the first one
parserself.o and the second parser.o. It actually doesn't matter much,
because the *.o filenames have no incidence on the resource resolution
process. It is the parameter after --resource that matters:

--resource org.sablecc.sablecc.parser.parser.dat

"org.sablecc.sablecc.parser.parser.dat" is what matters.

If you entered changes into CVS, feel free to let me know.
<project name="sablecc" default="dist" basedir=".">

<!--
===================================================================
 INITIALIZE FOLDERS
===================================================================
 -->
  <target name="init">
  <tstamp/>
    <mkdir dir="cls"/>
    <mkdir dir="doc"/>
    <mkdir dir="doc/api"/>
    <mkdir dir="obj"/>
    <mkdir dir="exe"/>
    <mkdir dir="res"/>
    <mkdir dir="dist"/>
    <mkdir dir="obj/org"/>
    <mkdir dir="obj/org/sablecc"/>
    <mkdir dir="obj/org/sablecc/sablecc"/>
    <mkdir dir="obj/org/sablecc/sablecc/analysis"/>
    <mkdir dir="obj/org/sablecc/sablecc/lexer"/>
    <mkdir dir="obj/org/sablecc/sablecc/node"/>
    <mkdir dir="obj/org/sablecc/sablecc/parser"/>
    <mkdir dir="obj/gnu"/>
    <mkdir dir="obj/gnu/getopt"/>
  </target>

<!--
===================================================================
 CREATE CLASS FILES
===================================================================
 -->

<target name="cls-compile" depends="init">
    <property name="build.compiler" value="jikes"/>
        <javac srcdir="src" destdir="cls" includes="
			**/*.java"/>
  </target>

<!--
===================================================================
 CREATE EXECUTABLE GCJ
===================================================================
 -->

<target name="gcj-compile" depends="init">
        <apply failonerror='true' executable='gcj' dest='obj'>
            <arg value='-fCLASSPATH=cls/'/>
            <arg value='-c'/>
            <arg value='-Os'/>
            <srcfile/>
            <arg value='-o'/>
            <targetfile/>
            <fileset dir='src/'>
	</fileset>
            <mapper type='glob' from='*.java' to='*.o'/>
        </apply>
</target>

<target name="compile-resources">
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.parser.Parser.parser.dat -o res/parserself.o -c src/org/sablecc/sablecc/parser/parser.dat"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.alternatives.txt -o res/alternatives.o -c src/org/sablecc/sablecc/alternatives.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.analyses.txt -o res/analyses.o -c src/org/sablecc/sablecc/analyses.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.errorrecovery.txt -o res/errorrecovery.o -c src/org/sablecc/sablecc/errorrecovery.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.lexer.txt -o res/lexer.o -c src/org/sablecc/sablecc/lexer.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.parser.txt -o res/parser.o -c src/org/sablecc/sablecc/parser.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.productions.txt -o res/productions.o -c src/org/sablecc/sablecc/productions.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.tokens.txt -o res/tokens.o -c src/org/sablecc/sablecc/tokens.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.tools.txt -o res/tools.o -c src/org/sablecc/sablecc/tools.txt"/>
	</exec>
  	<exec executable="gcj">
		<arg line="--resource org.sablecc.sablecc.ResourceReader.utils.txt -o res/utils.o -c src/org/sablecc/sablecc/utils.txt"/>
	</exec>
</target>

  <target name="link">
        <apply failonerror="true" executable="gcj" parallel="true">
            <fileset dir="obj/" includes="**/*.o"/>
            <arg value="--main=org.sablecc.sablecc.SableCC"/>
            <arg value="res/*.o"/>
            <arg value='-s'/>
            <arg value='-Os'/>
            <arg line="-o exe/sablecc"/>
            <srcfile/>
       </apply>
    </target>

<target name="compress">
	<exec executable="upx">
		<arg line="-9 exe\sablecc*.*"/>
	</exec>
</target>

<target name="dist" depends="init,compile-resources,cls-compile,gcj-compile,link,compress">
  <zip zipfile="dist/sablecc-dist-${DSTAMP}.zip" basedir="exe"/>
</target>

<!--
===================================================================
 CLEAN
===================================================================
 -->

  <target name="clean">
           <delete dir="doc/api"/>
           <delete dir="obj"/>
           <delete dir="exe"/>
           <delete dir="res"/>
           <delete dir="dist"/>
  	 <delete dir="cls"/>
  </target>
</project>