Skip to content

Commit

Permalink
improve compilation scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
blackav committed May 1, 2024
1 parent 8af6333 commit 57f3be9
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 16 deletions.
26 changes: 23 additions & 3 deletions scripts/dotnet-cs.in
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#! /bin/bash
# Copyright (c) 2019-2023 Alexander Chernov <[email protected]>
# Copyright (c) 2019-2024 Alexander Chernov <[email protected]>

# A script for compilation of C# programs using the dotnet compiler.
# Usage: dotnet-cs in-file out-file

# using EJUDGE_FLAGS we may pass additional flags

prefix="@prefix@"

LANG_CONFIG_DIR="@lang_config_dir@"
Expand Down Expand Up @@ -41,6 +39,28 @@ unset LANGUAGE
export DOTNET_NOLOGO=true
export DOTNET_CLI_TELEMETRY_OPTOUT=true

if [ "$EJUDGE_HAS_PROJECT" = 1 ]
then
if [ x"${EJUDGE_SOLUTION_FILE}" = x ]
then
echo "EJUDGE_SOLUTION_FILE must be specified" >&2
exit 1
fi
mv "$1" "${EJUDGE_SOLUTION_FILE}.cs"

if ! "${DOTNETRUN}" build -c Release
then
echo "Compilation failed." >&2
exit 1
fi
if ! mv bin/Release/${DOTNETTARGET}/solution.dll "$2"
then
echo "Compilation output is missing" >&2
exit 1
fi
exit 0
fi

TEMPLATE_DIR="${prefix}/share/ejudge/template"
TEMPLATE_FILE="${TEMPLATE_DIR}/dotnet-cs.tbz"

Expand Down
17 changes: 15 additions & 2 deletions scripts/g++.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/bin/sh
# Copyright (c) 2001-2023 Alexander Chernov <[email protected]>
#! /bin/bash
# Copyright (c) 2001-2024 Alexander Chernov <[email protected]>

# using EJUDGE_FLAGS we may pass additional flags

Expand Down Expand Up @@ -34,4 +34,17 @@ unset LC_ALL
unset LC_MESSAGES
unset LANGUAGE

if [ "${EJUDGE_COMPILE_MASK}" != "" ]
then
if [ "${EJUDGE_SOLUTION_FILE}" != "" ]
then
if ! mv "$1" "${EJUDGE_SOLUTION_FILE}.cpp"
then
echo "failed to rename $1 to $EJUDGE_SOLUTION_FILE" >&2
exit 1
fi
exec "${GPPRUN}" ${EJUDGE_FLAGS} ${EJUDGE_COMPILE_MASK} -o "$2" -lm ${EJUDGE_LIBS}
fi
fi

exec "${GPPRUN}" ${EJUDGE_FLAGS} "$1" -o "$2" -lm ${EJUDGE_LIBS}
52 changes: 42 additions & 10 deletions scripts/node.in
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#!/bin/sh
# Copyright (c) 2017 Alexander Chernov <[email protected]>
#! /bin/bash
# Copyright (c) 2017-2024 Alexander Chernov <[email protected]>

# This is a `compilation' script for the JavaScript (NodeJS) language.
# The idea is to append "#!${NODEPATH}" string
# to the beginning of the file.
# Usage: node <input> <output>
# Usage: node <input> <output> [<property-file>]

# using EJUDGE_FLAGS we may pass additional flags

LANG_CONFIG_DIR="@lang_config_dir@"
LANG_CONFIG_DIR="/home/judges/compile/conf/lang.d"
[ "${EJUDGE_LANG_CONFIG}" = "" ] && EJUDGE_LANG_CONFIG="${LANG_CONFIG_DIR}/node.cfg"

if [ -f "${EJUDGE_LANG_CONFIG}" ]
Expand All @@ -25,7 +20,44 @@ then
exit 1
fi

echo "#! ${NODEPATH} ${EJUDGE_FLAGS}" > $2
if [ x"${EJUDGE_EXE_PROPERTIES}" = x1 ]
then
extra_args=""
if [ "${EJUDGE_RUN_FLAGS}" != "" ]
then
for x in ${EJUDGE_RUN_FLAGS}
do
extra_args="$extra_args",'"'$x'"'
done
fi
if [ x"${EJUDGE_ARCHIVE}" = x1 ]
then
if [ x"${EJUDGE_SOLUTION_FILE}" = x ]
then
echo "EJUDGE_SOLUTION_FILE must be specified" >&2
exit 1
fi
if [ x"${EJUDGE_START_FILE}" = x ]
then
echo "EJUDGE_START_FILE must be specified" >&2
exit 1
fi
mv "$1" "${EJUDGE_SOLUTION_FILE}.js"
tar cfz "$2" .
echo '{ "is_archive": true, "start_cmd": "'${NODEPATH}'", "start_args": ["'${NODEPATH}'"'${extra_args}',"'${EJUDGE_START_FILE}'.js"] }' > "$3"
ls -l .
cat $3
exit 0
fi

prop_file="$3"
echo '{ "start_cmd": "'${NODEPATH}'", "start_args": ["'${NODEPATH}'"'${extra_args}']}' > "$prop_file"
cp -p "$1" "$2"
chmod +x "$2"
exit 0
fi

echo "#! ${NODEPATH}" > $2
echo >> $2
cat $1 >> $2
chmod +x $2
Expand Down
13 changes: 12 additions & 1 deletion scripts/rust.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#! /bin/bash
# Copyright (c) 2017-2023 Alexander Chernov <[email protected]>
# Copyright (c) 2017-2024 Alexander Chernov <[email protected]>

# using EJUDGE_FLAGS we may pass additional flags

Expand Down Expand Up @@ -66,4 +66,15 @@ unset LC_ALL
unset LC_MESSAGES
unset LANGUAGE

if [ "${EJUDGE_START_FILE}" != "" ]
then
if [ x"${EJUDGE_SOLUTION_FILE}" = x ]
then
echo "EJUDGE_SOLUTION_FILE must be specified" >&2
exit 1
fi
mv "$1" "${EJUDGE_SOLUTION_FILE}.rs"
exec "${RUSTRUN}" ${EJUDGE_FLAGS} "${EJUDGE_START_FILE}.rs" ${EJUDGE_LIBS} -o "$2"
fi

exec "${RUSTRUN}" ${EJUDGE_FLAGS} "$1" ${EJUDGE_LIBS} -o "$2"

0 comments on commit 57f3be9

Please sign in to comment.