73 lines
2.2 KiB
Bash
Executable file
73 lines
2.2 KiB
Bash
Executable file
#!/bin/bash
|
|
# Simple helper script to compile Sui code and link with libsuicmez
|
|
|
|
DEBUG_FLAG=""
|
|
if [ "$1" = "--debug" ]; then
|
|
DEBUG_FLAG="--debug"
|
|
shift
|
|
fi
|
|
|
|
OPTIMIZE_FLAG=""
|
|
if [ "$1" = "--optimize" ]; then
|
|
OPTIMIZE_FLAG="-O3"
|
|
shift
|
|
fi
|
|
|
|
if [ $# -eq 0 ]; then
|
|
echo "Usage: ./compile.sh [--debug] [--optimize] <sui_source.sui> [output_name]"
|
|
echo ""
|
|
echo "Options:"
|
|
echo " --debug Generate debug printf statements in the C output"
|
|
echo " --optimize Compile with -O3 optimization"
|
|
echo ""
|
|
echo "Examples:"
|
|
echo " ./compile.sh tests/structs.sui"
|
|
echo " ./compile.sh --debug tests/structs.sui"
|
|
echo " ./compile.sh --optimize tests/structs.sui"
|
|
echo " ./compile.sh tests/structs.sui my_program"
|
|
exit 1
|
|
fi
|
|
|
|
INPUT_SUI="$1"
|
|
OUTPUT_NAME="${2:-${INPUT_SUI%.sui}}"
|
|
|
|
if [ ! -f "$INPUT_SUI" ]; then
|
|
echo "Error: File not found: $INPUT_SUI"
|
|
exit 1
|
|
fi
|
|
|
|
# Compile Sui to C
|
|
echo "Compiling $INPUT_SUI to C..."
|
|
if [ -n "$DEBUG_FLAG" ]; then
|
|
cargo run -- "$DEBUG_FLAG" "$INPUT_SUI" || exit 1
|
|
else
|
|
cargo run -- "$INPUT_SUI" || exit 1
|
|
fi
|
|
|
|
# Get the C file name (should be next to the .sui file)
|
|
C_FILE="${INPUT_SUI%.sui}.c"
|
|
OUTPUT_BINARY="${INPUT_SUI%.sui}"
|
|
|
|
if [ -n "$2" ]; then
|
|
OUTPUT_BINARY="$2"
|
|
fi
|
|
|
|
if [ ! -f "$C_FILE" ]; then
|
|
echo "Error: Generated C file not found: $C_FILE"
|
|
exit 1
|
|
fi
|
|
|
|
# Get raylib compile and link flags
|
|
RAYLIB_CFLAGS=$(pkg-config --cflags raylib 2>/dev/null || echo "-I/usr/include")
|
|
RAYLIB_LIBS=$(pkg-config --libs raylib 2>/dev/null || echo "-lraylib -lm")
|
|
|
|
# Get ODE compile and link flags
|
|
ODE_CFLAGS=$(pkg-config --cflags ode 2>/dev/null || echo "-I/usr/include")
|
|
ODE_LIBS=$(pkg-config --libs ode 2>/dev/null || echo "-lode -lm")
|
|
|
|
# Compile C to executable with libsuicmez, raylib, and ODE support
|
|
echo "Compiling C code and linking with libsuicmez, raylib, and ODE..."
|
|
gcc $OPTIMIZE_FLAG -I. -Ilibfishsoup/include "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c libfishsoup/src/*.c game/inc/suic_math.c game/inc/suic_terrain.c game/inc/suic_net.c game/inc/suic_ui.c game/inc/suic_lighting.c $RAYLIB_CFLAGS $ODE_CFLAGS -o "$OUTPUT_BINARY" $RAYLIB_LIBS $ODE_LIBS -lz -lm || exit 1
|
|
|
|
echo "✓ Successfully created: $OUTPUT_BINARY"
|
|
echo " Run with: ./$OUTPUT_BINARY"
|