diff --git a/compile.sh b/compile.sh index 692994e..8b32399 100755 --- a/compile.sh +++ b/compile.sh @@ -7,15 +7,23 @@ if [ "$1" = "--debug" ]; then shift fi +OPTIMIZE_FLAG="" +if [ "$1" = "--optimize" ]; then + OPTIMIZE_FLAG="-O3" + shift +fi + if [ $# -eq 0 ]; then - echo "Usage: ./compile.sh [--debug] [output_name]" + echo "Usage: ./compile.sh [--debug] [--optimize] [output_name]" echo "" echo "Options:" - echo " --debug Generate debug printf statements in the C output" + 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 @@ -59,7 +67,7 @@ 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 libsuicmez/suicmez_gc.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" || exit 1 +gcc $OPTIMIZE_FLAG "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" || exit 1 echo "✓ Successfully created: $OUTPUT_BINARY" echo " Run with: ./$OUTPUT_BINARY" diff --git a/compile_and_run.sh b/compile_and_run.sh index 478cdc0..11786f3 100755 --- a/compile_and_run.sh +++ b/compile_and_run.sh @@ -7,15 +7,23 @@ if [ "$1" = "--debug" ]; then shift fi +OPTIMIZE_FLAG="" +if [ "$1" = "--optimize" ]; then + OPTIMIZE_FLAG="-O3" + shift +fi + if [ $# -eq 0 ]; then - echo "Usage: ./compile_and_run.sh [--debug] [program_args...]" + echo "Usage: ./compile_and_run.sh [--debug] [--optimize] [program_args...]" echo "" echo "Options:" - echo " --debug Generate debug printf statements in the C output" + echo " --debug Generate debug printf statements in the C output" + echo " --optimize Compile with -O3 optimization" echo "" echo "Examples:" echo " ./compile_and_run.sh tests/structs.sui" echo " ./compile_and_run.sh --debug tests/structs.sui" + echo " ./compile_and_run.sh --optimize tests/structs.sui" echo " ./compile_and_run.sh tests/myprogram.sui arg1 arg2" exit 1 fi @@ -70,7 +78,7 @@ RAYLIB_LIBS=$(pkg-config --libs raylib 2>/dev/null || echo "-lraylib -lm") 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") -if ! gcc "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" 2>&1; then +if ! gcc $OPTIMIZE_FLAG "$C_FILE" libsuicmez/libsuicmez.c libsuicmez/suicmez_gc.c $RAYLIB_CFLAGS $RAYLIB_LIBS $ODE_CFLAGS $ODE_LIBS -lm -o "$OUTPUT_BINARY" 2>&1; then echo "" echo "✗ C compilation failed" exit 1 diff --git a/tests/fps_game.o b/tests/fps_game.o index 3b3e29a..2cb269e 100755 Binary files a/tests/fps_game.o and b/tests/fps_game.o differ