]> mj.ucw.cz Git - eval.git/commitdiff
Introduced extension aliases.
authorMartin Mares <mj@ucw.cz>
Wed, 19 Mar 2008 12:52:27 +0000 (13:52 +0100)
committerMartin Mares <mj@ucw.cz>
Wed, 19 Mar 2008 12:52:27 +0000 (13:52 +0100)
When several filename extensions corresponded to the same programming language,
the compiler and runtime settings had to be duplicated.

It is now possible to define one extension as an alias for another, so that
it is used only for locating the source. The copy of the program in $TDIR
already has the new extension and it is processed according to it.

bin/lib
config

diff --git a/bin/lib b/bin/lib
index 16afaebe428b02feec61afb9f0c831d989e57bdb..8d9441327d8d8b1e2c7fb63d8fd0406b70cd4209 100644 (file)
--- a/bin/lib
+++ b/bin/lib
@@ -173,7 +173,14 @@ function locate-source
 function compile
 {
        pstart "Compiling... "
+
+       a="ALIAS_EXT_$SRCEXT"
+       if [ -n "${!a}" ] ; then
+               SRCEXT="${!a}"
+               echo "Normalized file extension: $SRCEXT"
+       fi
        override-vars "EXT_$SRCEXT"
+
        # Beware, the original SRCN can be a strange user-supplied name
        SRC=$PROBLEM.$SRCEXT
        cp "$SDIR/$SRCN" $TDIR/$SRC
@@ -181,6 +188,7 @@ function compile
                echo "Extras: $COMP_EXTRAS"
                for a in $COMP_EXTRAS ; do cp $PDIR/$a $TDIR/ ; done
        fi
+
        box-clean
        for a in $SRC $COMP_EXTRAS ; do cp $TDIR/$a $BOXDIR/ ; done
        EXE=$PROBLEM
diff --git a/config b/config
index 052e9991b16c46cb1cd78c1409e6a9a34d06e28c..8e8861243cbaaf8aa3264fe7941d5249ffd3c91a 100644 (file)
--- a/config
+++ b/config
@@ -38,6 +38,11 @@ REMOTE_SUBMIT_GROUP=mo-submit
 # Known source file extensions
 EXTENSIONS="c cc C cpp p pas"
 
+# Some of the extensions can be aliases for other extensions
+ALIAS_EXT_cc=cpp
+ALIAS_EXT_C=cpp
+ALIAS_EXT_p=pas
+
 ## Variables which control compilation and execution
 ## (see below for values for individual languages)
 
@@ -61,16 +66,12 @@ EXT_c_COMP='/usr/bin/gcc -std=gnu99 -O2 -g -o $EXE $EXTRA_CFLAGS $SRC -lm'
 EXTRA_CFLAGS=
 
 # C++
-EXT_C_COMP='/usr/bin/g++ -O2 -g -o $EXE $EXTRA_CXXFLAGS $SRC -lm'
-EXT_cpp_COMP="$EXT_C_COMP"
-EXT_cc_COMP="$EXT_C_COMP"
+EXT_cpp_COMP='/usr/bin/g++ -O2 -g -o $EXE $EXTRA_CXXFLAGS $SRC -lm'
 EXTRA_CXXFLAGS=
 
 # Pascal
-EXT_p_COMP='/usr/bin/fpc -Ci -Cr -Ct -g -O2 -Sg -o$EXE $EXTRA_PFLAGS $SRC'
-EXT_pas_COMP="$EXT_p_COMP"
+EXT_pas_COMP='/usr/bin/fpc -Ci -Cr -Ct -g -O2 -Sg -o$EXE $EXTRA_PFLAGS $SRC'
 EXTRA_PFLAGS=
-EXT_p_EXIT_CODE_HOOK=fpc-exit-code
 EXT_pas_EXIT_CODE_HOOK=fpc-exit-code
 
 ### Per-task configuration variables (default values, override in per-task config)