Skip to content

Commit

Permalink
[~] Update the project file by the last version of the project
Browse files Browse the repository at this point in the history
  • Loading branch information
toro-nicolas committed Jun 3, 2024
1 parent 385c789 commit aeb8f64
Show file tree
Hide file tree
Showing 1,398 changed files with 227,710 additions and 2,381 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
docs/html/* linguist-detectable=false
docs/html/search/* linguist-detectable=false
docs/tests/* linguist-detectable=false
bonus/docs/html/* linguist-detectable=false
bonus/docs/html/search/* linguist-detectable=false
bonus/docs/tests/* linguist-detectable=false

110 changes: 110 additions & 0 deletions .github/push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
#!/bin/bash

# Executables
executables="corewar"

# Couleur pour les messages
RED='\033[0;31m'
GREEN='\033[0;32m'
RESET='\033[0m'
BOLD='\033[1m'

# Fonction pour compter les occurrences d'un mot dans un fichier
count_occurrences() {
local word=$1
local file=$2
grep -o -i -w "$word" "$file" | wc -l
}

# Nom du fichier de résultat
file="plum_result.txt"

# Exécution du coding style checker
plum > $file

# Compter les occurrences de MAJOR, MINOR et INFO
major_count=$(count_occurrences "MAJOR" "$file")
minor_count=$(count_occurrences "MINOR" "$file")
info_count=$(count_occurrences "INFO" "$file")

# Vérifier si le fichier contient plus de 2 occurrences de MAJOR, MINOR ou INFO
if [ $major_count -gt 2 ] || [ $minor_count -gt 2 ] || [ $info_count -gt 2 ]; then
cat $file
echo -e "${RED}${BOLD}${BOLD}INTERDICTION DE PUSH:${RED}${RED} Le fichier contient des erreurs de Coding-Style !$RESET"
rm -rf $file
exit 1
else
echo -e "${GREEN}Aucune erreur de Coding-Style détecter.${RESET}"
fi

# Supprimer le fichier de résultat
rm -rf $file

# Tester la compilation
make >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} La compilation a échouée.${RESET}"
exit 1
else
echo -e "${GREEN}La compilation s'est déroulée correctement.${RESET}"
fi

# Tester
make clean >/dev/null 2>&1 &
pid=$!
wait $pid

# Check la création de l'exécutable
.github/workflows/check_program_compilation $executables >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Les executables n'ont pas été trouvé.${RESET}"
exit 1
else
echo -e "${GREEN}Les executables ont bien été trouvé.${RESET}"
fi

# Check les fonctions autorisées
.github/workflows/check_banned_functions $executables .github/workflows/authorized_functions.txt > result.txt
pid=$!
wait $pid
if [ $? -ne 0 ]; then
cat result.txt
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Des fonctions bannies ont été trouvé.${RESET}"
rm -rf result.txt
exit 1
else
echo -e "${GREEN}Aucune fonction bannie n'a été trouvé.${RESET}"
fi
rm -rf result.txt

# Tester les unit tests
make tests_run >/dev/null 2>&1 &
pid=$!
wait $pid
if [ $? -ne 0 ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} Les tests unitaires ont échoués.${RESET}"
exit 1
else
echo -e "${GREEN}Les tests unitaires se sont déroulés correctement.${RESET}"
fi

# Vérifier la taille du repository
make fclean >/dev/null 2>&1 &
pid=$!
wait $pid
size=$(du -sm --exclude='.git' | cut -f1)
limit=50
if [ "$size" -gt "$limit" ]; then
echo -e "${RED}${BOLD}INTERDICTION DE PUSH:${RED} La taille du repository dépasse la limite autorisée ($size MB > $limit MB)${RESET}"
exit 1
else
echo -e "${GREEN}La taille du repository est inférieure à la limite autorisée ($size MB < $limit MB)${RESET}"
fi

# Push
echo -e "${GREEN}${BOLD}PUSH AUTORISÉ !${RESET}"
git push
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ a.out
asm
vm
corewar
libcsfml-graphics.so*
libcsfml-graphics.so.2.6

# Unit_tests files
*.gcda
Expand Down
35 changes: 32 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,48 @@ BUILDDIR = ./build
SRCDIR = ./src

SRCS += main.c
SRCS += instructions/add.c
SRCS += instructions/aff.c
SRCS += instructions/and.c
SRCS += instructions/fork.c
SRCS += instructions/ld.c
SRCS += instructions/ldi.c
SRCS += instructions/lfork.c
SRCS += instructions/live.c
SRCS += instructions/lld.c
SRCS += instructions/lldi.c
SRCS += instructions/or.c
SRCS += instructions/st.c
SRCS += instructions/sti.c
SRCS += instructions/sub.c
SRCS += instructions/xor.c
SRCS += instructions/zjmp.c
SRCS += arena.c
SRCS += champion.c
SRCS += coding_byte.c
SRCS += corewar.c
SRCS += header.c
SRCS += instructions.c
SRCS += op.c
SRCS += parsing.c
SRCS += read_file.c
SRCS += state.c
SRCS += update.c

OBJS = $(addprefix $(BUILDDIR)/, $(notdir $(SRCS:.c=.o)))

CFLAGS = -Werror -Wextra -I./include/
DEBUGFLAGS = -g3
OPTIMIZEFLAGS = -O3
VALGRINDFLAGS = --leak-check=full --show-leak-kinds=all --track-origins=yes
OUTPUT = valgrind.log

LDFLAGS = -L./lib/ -lmymemory -lmylist -lmy

.PHONY: all libs create-build debug clean fclean re unit_tests tests_run
TEST_ARGS = -d 10 -n 1 champions/42.cor -n 10 champions/42.cor

.PHONY: all libs create-build debug valgrind clean fclean re \
unit_tests tests_run doc

all: create-build libs $(BUILDDIR) $(NAME)
@echo -e "\033[1;33m$(NAME) compiled.\033[0m"
Expand All @@ -46,6 +72,9 @@ create-build:
$(BUILDDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@

$(BUILDDIR)/%.o: $(SRCDIR)/instructions/%.c
$(CC) $(CFLAGS) $(OPTIMIZEFLAGS) $(LDFLAGS) -c $< -o $@

debug: CFLAGS += $(DEBUGFLAGS)
debug: OPTIMIZEFLAGS =
debug: DEBUG_MODE = debug
Expand All @@ -72,8 +101,8 @@ re: fclean all
re_debug: fclean debug

valgrind: fclean debug
@echo -e "\033[0;36mExecuting valgrind...\033[0m"
@valgrind $(VALGRINDFLAGS) ./$(NAME) 2> $(OUTPUT)
@echo -e "\033[0;32mExecuting valgrind...\033[0m"
@valgrind $(VALGRINDFLAGS) ./$(NAME) $(TEST_ARGS) 2> $(OUTPUT)

# Unit tests Makefile
unit_tests:
Expand Down
Loading

0 comments on commit aeb8f64

Please sign in to comment.