#!/bin/bash

set -e

########
## Clean 
#
rm -fr ./dsa
gprclean -r -P ../gel_demo.gpr -Xrestrictions=xgc -Xopengl_platform=egl -Xopengl_profile=lean


#########
## Build
#
mkdir --parents  dsa/x86_64-unknown-linux-gnu/obj
cp /usr/lib/gcc/x86_64-pc-linux-gnu/15.1.1/adalib/a-sttebu.ali \
   dsa/x86_64-unknown-linux-gnu/obj

set +e
po_gnatdist -Xrestrictions=xgc                                    \
            -Xopengl_platform=egl                                 \
            -Xopengl_profile=lean                                 \
            -P demo_dsa.gpr                                       \
            simple_dsa.cfg                                        \
            -cargs                                                \
            -I$LACE/3-mid/physics/implement/box2d/contrib/include \
            -g                                                    \
            -largs                                                \
            -g
set -e


echo __________________________________________________ PHASE 2 _____________________________________________

cp dsa/x86_64-unknown-linux-gnu/obj/*.o   dsa/x86_64-unknown-linux-gnu/partitions/simple_dsa/server_partition
cp dsa/x86_64-unknown-linux-gnu/obj/*.o   dsa/x86_64-unknown-linux-gnu/partitions/simple_dsa/client_partition

po_gnatdist  -Xrestrictions=xgc -Xopengl_platform=egl -Xopengl_profile=lean -P demo_dsa.gpr  simple_dsa.cfg 


cp bin/server_partition test/test_server
cp bin/client_partition test/test_client_1
cp bin/client_partition test/test_client_2
