From 442f38b1969c8aa2100865eab9017fc937fee987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9onard=20G=C3=A9rard?= Date: Sun, 20 Nov 2011 20:03:57 +0100 Subject: [PATCH] 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 --- clean_heptc | 2 ++ compiler/.projectSettings | 11 +++++++ heptc | 63 ++++++++++++++++++++++++++++----------- 3 files changed, 59 insertions(+), 17 deletions(-) create mode 100644 compiler/.projectSettings diff --git a/clean_heptc b/clean_heptc index 3f3227b..0a235e6 100755 --- a/clean_heptc +++ b/clean_heptc @@ -1,2 +1,4 @@ #!/bin/sh +SCRIPT_DIR=`dirname $(readlink -f $0)` +cd $SCRIPT_DIR rm -rf compiler/heptc.byte compiler/heptc.d.byte compiler/_build diff --git a/compiler/.projectSettings b/compiler/.projectSettings new file mode 100644 index 0000000..317ff48 --- /dev/null +++ b/compiler/.projectSettings @@ -0,0 +1,11 @@ + +
+
+ + + + + + +
+
diff --git a/heptc b/heptc index 13fca73..a741623 100755 --- a/heptc +++ b/heptc @@ -1,15 +1,20 @@ #!/bin/bash #Small wrapper to deal with compilation of the compiler and the stdlib. +STATUS=0 + RUN_DIR="`pwd`" -SCRIPT_DIR="$( cd "$( dirname "$0" )" && pwd )" +SCRIPT_DIR=`dirname $(readlink -f $0)` COMPILER_DIR="$SCRIPT_DIR/compiler" COMPILER=heptc.byte COMPILER_DEBUG=heptc.d.byte LIB_DIR="$SCRIPT_DIR/lib" +JAVA_LIB_DIR="$LIB_DIR/java" +JAVAC="javac -cp $JAVA_LIB_DIR" + #the symlink HEPTC="$COMPILER_DIR/$COMPILER" HEPTC_DEBUG="$COMPILER_DIR/$COMPILER_DEBUG" @@ -17,26 +22,50 @@ HEPTC_DEBUG="$COMPILER_DIR/$COMPILER_DEBUG" #compile the compiler if [ ! -x "$HEPTC" ] then - if [ -x "$HEPTC_DEBUG" ] - then - #use the debug - HEPTC=$HEPTC_DEBUG - else - cd "$COMPILER_DIR" - ocamlbuild -j 0 "$COMPILER" - cd - - fi + if [ -x "$HEPTC_DEBUG" ] + then + #use the debug + HEPTC=$HEPTC_DEBUG + else + pushd "$COMPILER_DIR" > /dev/null + ocamlbuild -j 0 "$COMPILER" + popd > /dev/null + fi fi #compile the stdlib if [ ! -e "$LIB_DIR/pervasives.epci" ] || [ "$HEPTC" -nt "$LIB_DIR/pervasives.epci" ] then - cd "$LIB_DIR" - echo "Recompile pervasives.epci" - "$HEPTC" -nopervasives pervasives.epi - cd - + pushd "$LIB_DIR" > /dev/null + echo "Recompile pervasives.epci" + "$HEPTC" -nopervasives pervasives.epi + popd > /dev/null fi -#call the compiler with the passed arguments. -cd "$RUN_DIR" -"$HEPTC" -stdlib "$LIB_DIR" "$@" +function compile +{ + #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