From b57118d0aeadb764751add3e9107e767c879f60e Mon Sep 17 00:00:00 2001 From: gazhonsepaskwa Date: Thu, 13 Feb 2025 08:54:24 +0100 Subject: [PATCH] folders and makefile --- Makefile | 19 ++++++++++++------- run_vg.sh | 2 +- srcs/parsing/ast/{ => nodes}/and_or.c | 2 +- srcs/parsing/ast/{ => nodes}/commands.c | 2 +- srcs/parsing/ast/{ => nodes}/pipeline.c | 2 +- srcs/parsing/ast/{ => nodes}/subsh.c | 2 +- srcs/parsing/ast/{ => utils}/cutll.c | 2 +- srcs/parsing/ast/{ => utils}/free_ast.c | 2 +- srcs/parsing/ast/{ => utils}/redirections.c | 2 +- srcs/parsing/ast/{ => utils}/top_token.c | 2 +- srcs/parsing/{ => heredoc}/heredoc.c | 2 +- srcs/parsing/{ => heredoc}/heredoc_utils.c | 2 +- srcs/parsing/{ => syntax}/syntax.c | 2 +- srcs/parsing/{ => syntax}/syntax_utils.c | 2 +- 14 files changed, 25 insertions(+), 20 deletions(-) rename srcs/parsing/ast/{ => nodes}/and_or.c (96%) rename srcs/parsing/ast/{ => nodes}/commands.c (98%) rename srcs/parsing/ast/{ => nodes}/pipeline.c (96%) rename srcs/parsing/ast/{ => nodes}/subsh.c (97%) rename srcs/parsing/ast/{ => utils}/cutll.c (98%) rename srcs/parsing/ast/{ => utils}/free_ast.c (97%) rename srcs/parsing/ast/{ => utils}/redirections.c (98%) rename srcs/parsing/ast/{ => utils}/top_token.c (98%) rename srcs/parsing/{ => heredoc}/heredoc.c (98%) rename srcs/parsing/{ => heredoc}/heredoc_utils.c (96%) rename srcs/parsing/{ => syntax}/syntax.c (98%) rename srcs/parsing/{ => syntax}/syntax_utils.c (97%) diff --git a/Makefile b/Makefile index e128da0..e564b7f 100644 --- a/Makefile +++ b/Makefile @@ -9,20 +9,23 @@ LIBFT_DIR = lib/libft NAME = minishell LIBFT = $(LIBFT_DIR)/libft.a +LIBFT_SRCS := $(shell find $(LIBFT_DIR) -name "*.c") SRCS = $(shell find $(SRCDIR) -name "*.c") OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRCS)) DEPS = $(OBJS:.o=.d) CYAN = \033[36m +YELLOW = \033[33m RESET = \033[0m -.PHONY: all clean fclean re +.PHONY: all clean fclean re libft all: $(NAME) -$(LIBFT): - @make -C $(LIBFT_DIR) all +$(LIBFT): $(LIBFT_SRCS) + @make -C $(LIBFT_DIR) all > /dev/null + @echo "$(YELLOW)[LIBFT] Created$(RESET)" $(OBJDIR)/%.o: $(SRCDIR)/%.c @mkdir -p $(dir $@) @@ -33,13 +36,15 @@ $(NAME): $(LIBFT) $(OBJS) @echo "$(CYAN)Build completed: $(NAME)$(RESET)" clean: - @rm -rf $(OBJDIR) $(TEST_OBJDIR) - @make -C $(LIBFT_DIR) clean + @make -C $(LIBFT_DIR) clean > /dev/null + @echo "$(YELLOW)[LIBFT] Object files removed$(RESET)" + @rm -rf $(OBJDIR) @echo "$(CYAN)Project cleaned$(RESET)" fclean: clean - @make -C $(LIBFT_DIR) fclean - @rm $(NAME) + @make -C $(LIBFT_DIR) fclean > /dev/null + @echo "$(YELLOW)[LIBFT] Removed$(RESET)" + @rm -rf $(NAME) @echo "$(CYAN)Executable removed$(RESET)" re: fclean all diff --git a/run_vg.sh b/run_vg.sh index d683474..f5450c0 100755 --- a/run_vg.sh +++ b/run_vg.sh @@ -1 +1 @@ -make && valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all --trace-children=yes --track-fds=all --suppressions=valgrind.supp -s ./minishell +make && valgrind --leak-check=full --track-origins=yes --show-leak-kinds=all --trace-children=yes --suppressions=valgrind.supp -s ./minishell diff --git a/srcs/parsing/ast/and_or.c b/srcs/parsing/ast/nodes/and_or.c similarity index 96% rename from srcs/parsing/ast/and_or.c rename to srcs/parsing/ast/nodes/and_or.c index 3bfbf4d..16acfda 100644 --- a/srcs/parsing/ast/and_or.c +++ b/srcs/parsing/ast/nodes/and_or.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" void create_and_or(t_ast_n *self, t_node *lst, t_node *token, t_msh *msh) { diff --git a/srcs/parsing/ast/commands.c b/srcs/parsing/ast/nodes/commands.c similarity index 98% rename from srcs/parsing/ast/commands.c rename to srcs/parsing/ast/nodes/commands.c index 90f7fde..f5a895b 100644 --- a/srcs/parsing/ast/commands.c +++ b/srcs/parsing/ast/nodes/commands.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" char **lltotab(t_node *lst, t_node *limiter) { diff --git a/srcs/parsing/ast/pipeline.c b/srcs/parsing/ast/nodes/pipeline.c similarity index 96% rename from srcs/parsing/ast/pipeline.c rename to srcs/parsing/ast/nodes/pipeline.c index 45a9e20..e3bf908 100644 --- a/srcs/parsing/ast/pipeline.c +++ b/srcs/parsing/ast/nodes/pipeline.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" void create_pline(t_ast_n *self, t_node *lst, t_node *token, t_msh *msh) { diff --git a/srcs/parsing/ast/subsh.c b/srcs/parsing/ast/nodes/subsh.c similarity index 97% rename from srcs/parsing/ast/subsh.c rename to srcs/parsing/ast/nodes/subsh.c index 77568d9..e9d7b85 100644 --- a/srcs/parsing/ast/subsh.c +++ b/srcs/parsing/ast/nodes/subsh.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" t_node *remove_parentheses(t_node *lst) { diff --git a/srcs/parsing/ast/cutll.c b/srcs/parsing/ast/utils/cutll.c similarity index 98% rename from srcs/parsing/ast/cutll.c rename to srcs/parsing/ast/utils/cutll.c index 6a42f11..02c85c6 100644 --- a/srcs/parsing/ast/cutll.c +++ b/srcs/parsing/ast/utils/cutll.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" static void add_nodell(t_nodell **nodell, t_node *node) { diff --git a/srcs/parsing/ast/free_ast.c b/srcs/parsing/ast/utils/free_ast.c similarity index 97% rename from srcs/parsing/ast/free_ast.c rename to srcs/parsing/ast/utils/free_ast.c index 88db1b2..be3dab9 100644 --- a/srcs/parsing/ast/free_ast.c +++ b/srcs/parsing/ast/utils/free_ast.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" static void free_redirs(t_ast_n *node) { diff --git a/srcs/parsing/ast/redirections.c b/srcs/parsing/ast/utils/redirections.c similarity index 98% rename from srcs/parsing/ast/redirections.c rename to srcs/parsing/ast/utils/redirections.c index 845b5f2..edc3353 100644 --- a/srcs/parsing/ast/redirections.c +++ b/srcs/parsing/ast/utils/redirections.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" t_redir get_redir(t_node *node) { diff --git a/srcs/parsing/ast/top_token.c b/srcs/parsing/ast/utils/top_token.c similarity index 98% rename from srcs/parsing/ast/top_token.c rename to srcs/parsing/ast/utils/top_token.c index 58f5256..9577e58 100644 --- a/srcs/parsing/ast/top_token.c +++ b/srcs/parsing/ast/utils/top_token.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../../includes/minishell.h" +#include "../../../../includes/minishell.h" #include static int last_tok_subsh(t_node *lst) diff --git a/srcs/parsing/heredoc.c b/srcs/parsing/heredoc/heredoc.c similarity index 98% rename from srcs/parsing/heredoc.c rename to srcs/parsing/heredoc/heredoc.c index e47d723..8bbd423 100644 --- a/srcs/parsing/heredoc.c +++ b/srcs/parsing/heredoc/heredoc.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../includes/minishell.h" +#include "../../../includes/minishell.h" static void remove_quote(char **str, char c) { diff --git a/srcs/parsing/heredoc_utils.c b/srcs/parsing/heredoc/heredoc_utils.c similarity index 96% rename from srcs/parsing/heredoc_utils.c rename to srcs/parsing/heredoc/heredoc_utils.c index 17644e7..749ecbe 100644 --- a/srcs/parsing/heredoc_utils.c +++ b/srcs/parsing/heredoc/heredoc_utils.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../includes/minishell.h" +#include "../../../includes/minishell.h" void exit_heredoc(char *limiter, t_msh *msh, t_node *lst) { diff --git a/srcs/parsing/syntax.c b/srcs/parsing/syntax/syntax.c similarity index 98% rename from srcs/parsing/syntax.c rename to srcs/parsing/syntax/syntax.c index ba80fee..192320e 100644 --- a/srcs/parsing/syntax.c +++ b/srcs/parsing/syntax/syntax.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../includes/minishell.h" +#include "../../../includes/minishell.h" #include int syntax_err_mess(char *token_base, int selected) diff --git a/srcs/parsing/syntax_utils.c b/srcs/parsing/syntax/syntax_utils.c similarity index 97% rename from srcs/parsing/syntax_utils.c rename to srcs/parsing/syntax/syntax_utils.c index 68c407f..4db7ce2 100644 --- a/srcs/parsing/syntax_utils.c +++ b/srcs/parsing/syntax/syntax_utils.c @@ -10,7 +10,7 @@ /* */ /* ************************************************************************** */ -#include "../../includes/minishell.h" +#include "../../../includes/minishell.h" int is_aop_operator(t_node *node) {