2022-03-21 17:18:49 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-03-25 19:19:57 +01:00
|
|
|
FLAGS="-std=c99 -lm"
|
|
|
|
|
2022-03-21 17:18:49 +01:00
|
|
|
if [[ $1 == "preview" ]]; then
|
|
|
|
[[ $2 ]] || set -- "$1" "build"
|
|
|
|
if [[ $2 == "build" ]]; then
|
|
|
|
mkdir -p out
|
2022-03-27 15:03:13 +02:00
|
|
|
echo "Compilation de src/mnist/preview.c"
|
2022-03-25 19:19:57 +01:00
|
|
|
gcc src/mnist/preview.c -o out/preview_mnist $FLAGS
|
2022-03-27 15:03:13 +02:00
|
|
|
echo "Fait."
|
2022-03-21 17:18:49 +01:00
|
|
|
exit
|
|
|
|
elif [[ $2 == "train" ]]; then
|
|
|
|
[[ -f out/preview_mnist ]] || $0 preview build
|
2022-04-03 21:44:15 +02:00
|
|
|
out/preview_mnist data/mnist/train-images-idx3-ubyte data/mnist/train-labels-idx1-ubyte
|
2022-03-21 17:18:49 +01:00
|
|
|
exit
|
|
|
|
elif [[ $2 == "t10k" ]]; then
|
|
|
|
[[ -f out/preview_mnist ]] || $0 preview build
|
2022-04-03 21:44:15 +02:00
|
|
|
out/preview_mnist data/mnist/t10k-images-idx3-ubyte data/mnist/t10k-labels-idx1-ubyte
|
2022-03-21 17:18:49 +01:00
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
2022-03-27 14:42:00 +02:00
|
|
|
|
|
|
|
if [[ $1 == "test" ]]; then
|
|
|
|
[[ $2 ]] || set -- "$1" "build"
|
|
|
|
if [[ $2 == "build" ]]; then
|
|
|
|
mkdir -p out
|
|
|
|
for i in $(ls test); do
|
2022-03-27 15:03:13 +02:00
|
|
|
echo "Compilation de test/$i"
|
2022-03-27 14:42:00 +02:00
|
|
|
gcc "test/$i" -o "out/test_$(echo $i | awk -F. '{print $1}')" $FLAGS
|
2022-03-27 15:03:13 +02:00
|
|
|
echo "Fait."
|
2022-03-27 14:42:00 +02:00
|
|
|
done
|
|
|
|
exit
|
|
|
|
elif [[ $2 == "run" ]]; then
|
|
|
|
$0 test build
|
2022-03-27 14:54:20 +02:00
|
|
|
mkdir -p .test-cache
|
2022-03-27 14:42:00 +02:00
|
|
|
for i in $(ls out/test_*); do
|
|
|
|
echo "--- $i ---"
|
|
|
|
$i
|
|
|
|
done
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
fi
|
2022-03-27 15:03:13 +02:00
|
|
|
|
|
|
|
echo "Usage:"
|
|
|
|
echo -e "\t$0 preview ( build | train | t10k )"
|
|
|
|
echo -e "\t$0 test ( build | run )\n"
|
|
|
|
echo -e "Les fichiers de test sont recompilés à chaque exécution,\nles autres programmes sont compilés automatiquement si manquants"
|