#!/bin/sh -e

#TODO use variables for the pkg-config

echo "testing C++ library"

# generate the config.h file
meson setup build

# build Cpp tests
for f in cplusplus/tests/*.cpp; do
    echo g++ -o "${f%.cpp}" "$(pkg-config --cflags libxrl)" -Isrc -Ibuild "$f" "$(pkg-config --libs libxrl)" -lm
    g++ -o "${f%.cpp}" $(pkg-config --cflags libxrl) -Isrc -Ibuild $f $(pkg-config --libs libxrl) -lm
    echo "run ${f%.cpp}"
    ./"${f%.cpp}"
done;


# build Cpp examples
for f in example/*.cpp; do
   echo g++ -o "${f%.cpp}" "$(pkg-config --cflags libxrl)" "$f" "$(pkg-config --libs libxrl)" -lm
   g++ -o "${f%.cpp}" $(pkg-config --cflags libxrl) $f $(pkg-config --libs libxrl) -lm
   echo "run ${f%.cpp}"
   ./"${f%.cpp}"
done;

