mkdir -p ../../artifacts
mkdir -p builds
git clone --depth 1 https://git.tesses.org/tesses50/zig-cross builds/zig-cross



for tripple in x86_64-linux-musl x86-linux-musl aarch64-linux-musl arm-linux-musleabi riscv64-linux-musl powerpc-linux-musleabihf; do
    export BUILDDIR=builds/$tripple
    mkdir -p $BUILDDIR
    cmake -S ../.. -B $BUILDDIR --toolchain $PWD/builds/zig-cross/$tripple\.cmake -DCMAKE_BUILD_TYPE=Release -DTESSESFRAMEWORK_INSTALL_DEVELOPMENT=OFF -DTESSESFRAMEWORK_ENABLE_EXAMPLES=OFF -DTESSESFRAMEWORK_STATIC=ON -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++ -static -Wl,--strip-all" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -GNinja
    cmake --build $BUILDDIR || exit 1
    cmake --install $BUILDDIR --prefix $BUILDDIR/out
    tar cvzf ../../artifacts/tessesframework-tools-$tripple\.tar.gz -C $BUILDDIR/out/ bin
    
done
#x86_64-windows-gnu x86-windows-gnu
    export BUILDDIR=builds/aarch64-windows-gnu
    mkdir -p $BUILDDIR
    cmake -S ../.. -B $BUILDDIR --toolchain $PWD/builds/zig-cross/aarch64-windows-gnu.cmake -DCMAKE_BUILD_TYPE=Release -DTESSESFRAMEWORK_INSTALL_DEVELOPMENT=OFF -DTESSESFRAMEWORK_ENABLE_EXAMPLES=OFF -DTESSESFRAMEWORK_STATIC=ON -DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++ -static -Wl,--strip-all" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -GNinja
    cmake --build $BUILDDIR || exit 1
    cmake --install $BUILDDIR --prefix $BUILDDIR/out
    
    env -C $BUILDDIR/out zip -r ../../../../../artifacts/tessesframework-tools-aarch64-windows-gnu.zip bin


for tripple in x86_64-macos-none aarch64-macos-none; do
    export BUILDDIR=builds/$tripple
    mkdir -p $BUILDDIR
    cmake -S ../.. -B $BUILDDIR --toolchain $PWD/builds/zig-cross/$tripple\.cmake -DCMAKE_BUILD_TYPE=Release -DTESSESFRAMEWORK_INSTALL_DEVELOPMENT=OFF -DTESSESFRAMEWORK_ENABLE_EXAMPLES=OFF -DTESSESFRAMEWORK_STATIC=ON -DCMAKE_POSITION_INDEPENDENT_CODE=ON -GNinja -DCMAKE_EXE_LINKER_FLAGS="-Wl,--strip-all"
    cmake --build $BUILDDIR || exit 1
    cmake --install $BUILDDIR --prefix $BUILDDIR/out
    tar cvzf ../../artifacts/tessesframework-tools-$tripple\.tar.gz -C $BUILDDIR/out/ bin
    
done