#!/bin/bash # Builds jetc itself (if needed), compiles a .jet file to C++, and links the # result into a standalone executable against CoreUtils + the JetCore # runtime (everything jet-2.0 itself links against, minus jet-2.0.cpp's own # main() - the compiled program brings its own). # # Usage: ./build-compiled.sh set -e JC="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" CU="$JC/../CoreUtils" HERE="$JC/jetc" if [ $# -ne 2 ]; then echo "usage: $0 " exit 1 fi INPUT="$1" OUTNAME="$2" if [ ! -x "$HERE/jetc" ]; then echo "Building jetc..." g++ -g -std=c++23 -o "$HERE/jetc" "$HERE/jetc.cpp" "$HERE/JetParser.cpp" "$HERE/JetCodegen.cpp" fi echo "Compiling $INPUT -> $OUTNAME.compiled.cpp" "$HERE/jetc" "$INPUT" "$HERE/$OUTNAME.compiled.cpp" echo "Building JetCore runtime objects (everything Tag::interpretSpan's fallback path may need)..." list="" for f in "$JC"/*.cpp; do base=$(basename "$f") if [ "$base" = "jet-2.0.cpp" ]; then continue; fi obj="$HERE/${base%.cpp}.o" if [ ! -f "$obj" ]; then g++ -g -c -std=c++23 -I"$CU" -I"$JC" "$f" -o "$obj" & fi list="$list $obj" done wait g++ -g -c -std=c++23 -I"$CU" -I"$JC" "$HERE/$OUTNAME.compiled.cpp" -o "$HERE/$OUTNAME.compiled.o" g++ -g -o "$HERE/$OUTNAME" "$HERE/$OUTNAME.compiled.o" $list -std=c++23 -L"$CU" -lCoreUtils -lmysqlclient -lcrypto echo "Built $HERE/$OUTNAME"