stronger heptc and clean_heptc

It may be symlinked.
Moreover, when heptc is called with java as first param, it will set the
right target and call javac right after
master
Léonard Gérard 13 years ago
parent 7b281317f4
commit 442f38b196

@ -1,2 +1,4 @@
#!/bin/sh #!/bin/sh
SCRIPT_DIR=`dirname $(readlink -f $0)`
cd $SCRIPT_DIR
rm -rf compiler/heptc.byte compiler/heptc.d.byte compiler/_build rm -rf compiler/heptc.byte compiler/heptc.d.byte compiler/_build

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<section name="OcamlProjectSettings">
<section name="OcamlbuildSettings">
<item value="" key="ocamlbuildProjectLinkerFlags"/>
<item value="" key="ocamlbuildProjectLibs"/>
<item value="" key="ocamlbuildProjectCompilerFlags"/>
<item value="-j 0" key="ocamlbuildProjectOtherFlags"/>
<item value="true" key="ocamlbuildGenerateTypeInfo"/>
<item value="heptc.d.byte" key="ocamlbuildProjectTargets"/>
</section>
</section>

63
heptc

@ -1,15 +1,20 @@
#!/bin/bash #!/bin/bash
#Small wrapper to deal with compilation of the compiler and the stdlib. #Small wrapper to deal with compilation of the compiler and the stdlib.
STATUS=0
RUN_DIR="`pwd`" RUN_DIR="`pwd`"
SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" SCRIPT_DIR=`dirname $(readlink -f $0)`
COMPILER_DIR="$SCRIPT_DIR/compiler" COMPILER_DIR="$SCRIPT_DIR/compiler"
COMPILER=heptc.byte COMPILER=heptc.byte
COMPILER_DEBUG=heptc.d.byte COMPILER_DEBUG=heptc.d.byte
LIB_DIR="$SCRIPT_DIR/lib" LIB_DIR="$SCRIPT_DIR/lib"
JAVA_LIB_DIR="$LIB_DIR/java"
JAVAC="javac -cp $JAVA_LIB_DIR"
#the symlink #the symlink
HEPTC="$COMPILER_DIR/$COMPILER" HEPTC="$COMPILER_DIR/$COMPILER"
HEPTC_DEBUG="$COMPILER_DIR/$COMPILER_DEBUG" HEPTC_DEBUG="$COMPILER_DIR/$COMPILER_DEBUG"
@ -17,26 +22,50 @@ HEPTC_DEBUG="$COMPILER_DIR/$COMPILER_DEBUG"
#compile the compiler #compile the compiler
if [ ! -x "$HEPTC" ] if [ ! -x "$HEPTC" ]
then then
if [ -x "$HEPTC_DEBUG" ] if [ -x "$HEPTC_DEBUG" ]
then then
#use the debug #use the debug
HEPTC=$HEPTC_DEBUG HEPTC=$HEPTC_DEBUG
else else
cd "$COMPILER_DIR" pushd "$COMPILER_DIR" > /dev/null
ocamlbuild -j 0 "$COMPILER" ocamlbuild -j 0 "$COMPILER"
cd - popd > /dev/null
fi fi
fi fi
#compile the stdlib #compile the stdlib
if [ ! -e "$LIB_DIR/pervasives.epci" ] || [ "$HEPTC" -nt "$LIB_DIR/pervasives.epci" ] if [ ! -e "$LIB_DIR/pervasives.epci" ] || [ "$HEPTC" -nt "$LIB_DIR/pervasives.epci" ]
then then
cd "$LIB_DIR" pushd "$LIB_DIR" > /dev/null
echo "Recompile pervasives.epci" echo "Recompile pervasives.epci"
"$HEPTC" -nopervasives pervasives.epi "$HEPTC" -nopervasives pervasives.epi
cd - popd > /dev/null
fi fi
#call the compiler with the passed arguments. function compile
cd "$RUN_DIR" {
"$HEPTC" -stdlib "$LIB_DIR" "$@" #call the compiler with the passed arguments.
pushd "$RUN_DIR" > /dev/null
"$HEPTC" -stdlib "$LIB_DIR" "$@"
STATUS=$?
popd > /dev/null
}
case $1 in
java )
shift
compile -target java "$@"
if [[ $STATUS = 0 ]]
#call javac to compile the file given as last argument
last_arg=$#
base_f=`basename ${!last_arg} .ept`
pushd "java/$(echo ${base_f} | sed 's/^./\u&/')" > /dev/null
$JAVAC *.java
popd > /dev/null
fi
;;
-- | * )
compile "$@"
esac
exit $STATUS

Loading…
Cancel
Save