From db164b98e56b61dc210c7ba3c5a140a7c92c370e Mon Sep 17 00:00:00 2001 From: Raphael Date: Thu, 1 May 2025 14:46:01 +0200 Subject: [PATCH] init(09): starting to work on the pmergeme --- cpp09/ex02/Makefile | 165 ++++++++++++++++++++++++++++++++++++++++ cpp09/ex02/PmergeMe.cpp | 13 ++++ cpp09/ex02/PmergeMe.hpp | 13 ++++ cpp09/ex02/main.cpp | 13 ++++ 4 files changed, 204 insertions(+) create mode 100644 cpp09/ex02/Makefile create mode 100644 cpp09/ex02/PmergeMe.cpp create mode 100644 cpp09/ex02/PmergeMe.hpp create mode 100644 cpp09/ex02/main.cpp diff --git a/cpp09/ex02/Makefile b/cpp09/ex02/Makefile new file mode 100644 index 0000000..78834b3 --- /dev/null +++ b/cpp09/ex02/Makefile @@ -0,0 +1,165 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: rparodi +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/11/12 11:05:05 by rparodi #+# #+# # +# Updated: 2025/05/01 14:45:09 by rparodi ### ########.fr # +# # +# **************************************************************************** # + +# Variables + +# Name +NAME = PmergeMe + +# Commands +CXX = c++ +RM = rm -rf + +# Flags +# Mandatory flags for 42 +CXXFLAGS = -Werror -Wextra -Wall -std=c++98 +# Flags to have the dependences (can be removed for correction) +# Flags to have the debug (can be removed for correction) +DEBUG = -g3 +# DEBUG += -fsanitize=address +CXXFLAGS += $(DEBUG) + +# Sources +SRC = PmergeMe.cpp \ + main.cpp + +INC_DIR = + +CPPFLAGS = $(addprefix -I, $(INC_DIR)) -MMD -MP + +# Flags to have the dependences (can be removed for correction) +# DEBUG = -g3 +# CPPFLAGS += $(DEBUG) + +# Objects +OBJDIRNAME = ./build +OBJ = $(addprefix $(OBJDIRNAME)/,$(SRC:.cpp=.o)) + +# Colors +GREEN = \033[32m +GREY = \033[0;90m +RED = \033[0;31m +GOLD = \033[38;5;220m +END = \033[0m + +# Rules + +# All (make all) +all: header $(NAME) footer + +# Clean (make clean) +clean: + @printf '$(GREY) Removing $(END)$(RED)Objects$(END)\n' + @printf '$(GREY) Removing $(END)$(RED)Objects Folder$(END)\n' + @$(RM) $(OBJDIRNAME) + +# Clean (make fclean) +fclean: clean + @printf '$(GREY) Removing $(END)$(RED)Program$(END)\n' + @$(RM) $(NAME) + @echo "" + +# Restart (make re) +re: header fclean all + +# Dependences for all +$(NAME): $(OBJ) + @mkdir -p $(OBJDIRNAME) + @printf '$(GREY) Creating $(END)$(GREEN)$(OBJDIRNAME)$(END)\n' + @$(CXX) $(CXXFLAGS) -o $(NAME) $(OBJ) + +# Creating the objects +$(OBJDIRNAME)/%.o: %.cpp + @mkdir -p $(dir $@) + @printf '$(GREY) Compiling $(END)$(GREEN)$<$(END)\n' + @$(CXX) $(CXXFLAGS) -o $@ -c $< + +test: + @printf '$(GREY) Testing with $(END)$(GOLD)./RPN ""$(END)\n' + @./$(NAME) "" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN ""$(END)\n' + @valgrind ./$(NAME) "" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 + @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "8 9 * 9 - 9 - 9 - 4 - 1 +"$(END)\n' + @./$(NAME) "8 9 * 9 - 9 - 9 - 4 - 1 +" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "8 9 * 9 - 9 - 9 - 4 - 1 +"$(END)\n' + @valgrind ./$(NAME) "8 9 * 9 - 9 - 9 - 4 - 1 +" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 + @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "7 7 * 7 -"$(END)\n' + @./$(NAME) "7 7 * 7 -" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "7 7 * 7 -"$(END)\n' + @valgrind ./$(NAME) "7 7 * 7 -" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 + @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "1 2 * 2 / 2 * 2 4 - +"$(END)\n' + @./$(NAME) "1 2 * 2 / 2 * 2 4 - +" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "1 2 * 2 / 2 * 2 4 - +"$(END)\n' + @valgrind ./$(NAME) "1 2 * 2 / 2 * 2 4 - +" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 + @printf '$(GREY) Testing with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' + @./$(NAME) "(1 + 1)" + @printf '\n' + @printf '$(GREY) MemCheck with $(END)$(GOLD)./RPN "(1 + 1)"$(END)\n' + @valgrind ./$(NAME) "(1 + 1)" 2> /tmp/RPN_test + @cat /tmp/RPN_test | rg --color=always "ERROR SUMMARY" -A 10 + +# Header +header: + @clear + @printf '\n\n' + @printf '$(GOLD) ******* ****** ******* $(END)\n' + @printf '$(GOLD) ****** *** ******* $(END)\n' + @printf '$(GOLD) ******* * ******* $(END)\n' + @printf '$(GOLD) ****** ******* $(END)\n' + @printf '$(GOLD) ******* ******* $(END)\n' + @printf '$(GOLD) ******************* ******* * $(END)\n' + @printf '$(GOLD) ******************* ******* *** $(END)\n' + @printf '$(GOLD) ****** ******* ****** $(END)\n' + @printf '$(GOLD) ****** $(END)\n' + @printf '$(GOLD) ****** $(END)\n' + @printf '$(GREY) Made by rparodi$(END)\n\n' + +# Footer +footer: + @printf "\n" + @printf "$(GOLD) ,_ _,$(END)\n" + @printf "$(GOLD) | \\___//|$(END)\n" + @printf "$(GOLD) |=6 6=|$(END)\n" + @printf "$(GOLD) \\=._Y_.=/$(END)\n" + @printf "$(GOLD) ) \` ( ,$(END)\n" + @printf "$(GOLD) / \\ (('$(END)\n" + @printf "$(GOLD) | | ))$(END)\n" + @printf "$(GOLD) /| | | |\\_//$(END)\n" + @printf "$(GOLD) \\| |._.| |/-\`$(END)\n" + @printf "$(GOLD) '\"' '\"'$(END)\n" + @printf ' $(GREY)The compilation is$(END) $(GOLD)finish$(END)\n $(GREY)Have a good $(END)$(GOLD)correction !$(END)\n' + +clangd: + @printf "CompileFlags:\n" > ./.clangd + @printf " Add:\n" >> ./.clangd + @printf " - \"-xc++\"\n" >> ./.clangd + @for FLAG in $(CXXFLAGS); do \ + printf " - \"$$FLAG\"\n" >> ./.clangd; \ + done + @printf " - \"-I"$(shell pwd)"/\"\n" >> .clangd; + @for file in $(INC_DIR); do \ + printf " - \"-I"$(shell pwd)"/"$$file"\"" >> .clangd; \ + done + @printf "\n" >> ./.clangd + @printf '$(GREY) Now parsing settings is set in $(END)$(GREEN)./.clangd$(END)\n' + +# Phony +.PHONY: all clean fclean re get_db clangd +-include ${OBJ:.o=.d} diff --git a/cpp09/ex02/PmergeMe.cpp b/cpp09/ex02/PmergeMe.cpp new file mode 100644 index 0000000..e3aa479 --- /dev/null +++ b/cpp09/ex02/PmergeMe.cpp @@ -0,0 +1,13 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* PmergeMe.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/01 14:45:19 by rparodi #+# #+# */ +/* Updated: 2025/05/01 14:45:32 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + + diff --git a/cpp09/ex02/PmergeMe.hpp b/cpp09/ex02/PmergeMe.hpp new file mode 100644 index 0000000..979f17d --- /dev/null +++ b/cpp09/ex02/PmergeMe.hpp @@ -0,0 +1,13 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* PmergeMe.hpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/01 14:45:25 by rparodi #+# #+# */ +/* Updated: 2025/05/01 14:45:29 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#pragma once diff --git a/cpp09/ex02/main.cpp b/cpp09/ex02/main.cpp new file mode 100644 index 0000000..9eb63eb --- /dev/null +++ b/cpp09/ex02/main.cpp @@ -0,0 +1,13 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.cpp :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: rparodi +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2025/05/01 14:45:40 by rparodi #+# #+# */ +/* Updated: 2025/05/01 14:45:41 by rparodi ### ########.fr */ +/* */ +/* ************************************************************************** */ + +