From c4bc783ef4e7b0f9c5de57a51cacda7f9f1a4f0e Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Tue, 26 Feb 2019 19:23:04 +0100 Subject: [PATCH] test(tests/playground/run.sh): split out compile.sh --- tests/playground/compile.sh | 40 +++++++++++++++++++++++++++++++++++++ tests/playground/run.sh | 37 +--------------------------------- 2 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 tests/playground/compile.sh diff --git a/tests/playground/compile.sh b/tests/playground/compile.sh new file mode 100644 index 0000000000..65abf8b9d5 --- /dev/null +++ b/tests/playground/compile.sh @@ -0,0 +1,40 @@ +#!/usr/bin/env bash +if [ $# -eq 0 ]; then + echo "Usage: compile.sh [file]" + exit 1 +fi +ulimit -s 8192 +source ../compiler/test_flags.sh +BIN_DIR=../../bin +LEAN=$BIN_DIR/lean +INCLUDE_DIR=../../src +export LEAN_PATH=../../library:. +ff=$1 + +# Hack for converting a list of libraries such as `/usr/lib/gmp.so;dl` into valid liker parameters. +LINKER_LIBS="" +for lib in ${LIBS//;/ }; do + if [[ $lib == *".so" || $lib == *".dll" || $lib == *".dylib" ]]; then + LINKER_LIBS="$LINKER_LIBS $lib" + else + LINKER_LIBS="$LINKER_LIBS -l$lib" + fi +done + +if [[ "$OSTYPE" == "msys" ]]; then + # Windows running MSYS2 + # Replace /c/ with c:, and / with \\ + ff=$(echo $ff | sed 's|^/\([a-z]\)/|\1:/|' | sed 's|/|\\\\|g') +fi + +$LEAN --cpp="$ff".cpp "$ff" +if [ $? -ne 0 ]; then + echo "Failed to compile $ff into C++ file" + exit 1 +fi + +$CXX -o "$ff.out" -I $INCLUDE_DIR $CXX_FLAGS $ff.cpp $BIN_DIR/libleanstatic.a $LINKER_FLAGS $LINKER_LIBS +if [ $? -ne 0 ]; then + echo "Failed to compile C++ file $ff.cpp" + exit 1 +fi diff --git a/tests/playground/run.sh b/tests/playground/run.sh index f9f5ce9af8..58973f580a 100755 --- a/tests/playground/run.sh +++ b/tests/playground/run.sh @@ -3,41 +3,6 @@ if [ $# -eq 0 ]; then echo "Usage: run.sh [file] [args]*" exit 1 fi -ulimit -s 8192 -source ../compiler/test_flags.sh -BIN_DIR=../../bin -LEAN=$BIN_DIR/lean -INCLUDE_DIR=../../src -export LEAN_PATH=../../library:. -ff=$1 - -# Hack for converting a list of libraries such as `/usr/lib/gmp.so;dl` into valid liker parameters. -LINKER_LIBS="" -for lib in ${LIBS//;/ }; do - if [[ $lib == *".so" || $lib == *".dll" || $lib == *".dylib" ]]; then - LINKER_LIBS="$LINKER_LIBS $lib" - else - LINKER_LIBS="$LINKER_LIBS -l$lib" - fi -done - -if [[ "$OSTYPE" == "msys" ]]; then - # Windows running MSYS2 - # Replace /c/ with c:, and / with \\ - ff=$(echo $ff | sed 's|^/\([a-z]\)/|\1:/|' | sed 's|/|\\\\|g') -fi - -$LEAN --cpp="$ff".cpp "$ff" -if [ $? -ne 0 ]; then - echo "Failed to compile $ff into C++ file" - exit 1 -fi - -$CXX -o "$ff.out" -I $INCLUDE_DIR $CXX_FLAGS $ff.cpp $BIN_DIR/libleanstatic.a $LINKER_FLAGS $LINKER_LIBS -if [ $? -ne 0 ]; then - echo "Failed to compile C++ file $ff.cpp" - exit 1 -fi - +./compile.sh $1 shift 1 "./$ff.out" $*