pocketpy/build.sh
Kanika Kapoor c7572c76ba Fix amalgamation script to work with python3-only environments (#444)
- Use sys.executable in Python scripts (amalgamate.py, cmake_build.py) instead of hardcoded 'python'
- Update shell scripts to prefer python3 over python with fallback
- Fix scripts/run_tests.py to detect python3 for CPython benchmarking

This fixes the issue where the amalgamation script fails on Linux systems
that only have python3 available and no 'python' symlink.
2025-12-27 00:42:53 +05:30

31 lines
710 B
Bash

#!/bin/bash
# Check if clang is installed
if ! type -P clang >/dev/null 2>&1; then
echo "clang is required and not installed. Kindly install it."
echo "Run: sudo apt-get install clang"
exit 1
fi
echo "> Running prebuild.py... "
command -v python3 >/dev/null 2>&1 && python3 prebuild.py || python prebuild.py
if [ $? -ne 0 ]; then
echo "prebuild.py failed."
exit 1
fi
SRC=$(find src/ -name "*.c")
SRC2=${1:-src2/main.c}
echo "> Compiling and linking source files... "
clang -std=c11 -O2 -Wfatal-errors -Iinclude -DNDEBUG -o main $SRC $SRC2 -lm -ldl -lpthread
if [ $? -eq 0 ]; then
echo "Build completed. Type \"./main\" to enter REPL."
else
echo "Build failed."
exit 1
fi