#!/bin/bash # Simple helper script to compile Sui code and link with libsuicmez if [ $# -eq 0 ]; then echo "Usage: ./compile.sh [output_name]" echo "" echo "Example:" echo " ./compile.sh tests/structs.sui" echo " ./compile.sh tests/structs.sui my_program" exit 1 fi INPUT_SUI="$1" OUTPUT_NAME="${2:-${INPUT_NAME%.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..." cargo run "$INPUT_SUI" || exit 1 # Get the C file name (should be next to the .sui file) C_FILE="${INPUT_SUI%.sui}.c" OUTPUT_BINARY="${INPUT_SUI%.sui}.o" 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 raylib and ODE support echo "Compiling C code and linking with libsuicmez, raylib, and ODE..." gcc "$C_FILE" libsuicmez/libsuicmez.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -o "$OUTPUT_BINARY" || exit 1 echo "✓ Successfully created: $OUTPUT_BINARY" echo " Run with: ./$OUTPUT_BINARY"