Updated makefiles and better error reporting

This commit is contained in:
Maieul BOYER 2024-07-26 13:54:49 +02:00
parent 5ed7952cc7
commit 58fc4ecc78
No known key found for this signature in database
10 changed files with 94 additions and 74 deletions

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ # # By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ # # +#+#+#+#+#+ +#+ #
# Created: 2024/04/28 17:28:30 by maiboyer #+# #+# # # Created: 2024/04/28 17:28:30 by maiboyer #+# #+# #
# Updated: 2024/07/24 21:25:38 by maiboyer ### ########.fr # # Updated: 2024/07/26 13:52:19 by maiboyer ### ########.fr #
# # # #
# **************************************************************************** # # **************************************************************************** #
@ -24,6 +24,8 @@ BUILD_DIR ?= $(shell realpath ./build/)
# TODO: REMOVE THIS WHEN FINISHING THIS: # TODO: REMOVE THIS WHEN FINISHING THIS:
CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE CFLAGS_ADDITIONAL += -DPRINT_BACKTRACE
CFLAGS_ADDITIONAL += -gcolumn-info CFLAGS_ADDITIONAL += -gcolumn-info
CFLAGS_ADDITIONAL += '-DERROR=((void)printf("ERROR HERE: " __FILE__ ":%d in %s\n", __LINE__, __func__), 1)'
# Flags # Flags
CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -I./includes -I./output/include -I./stdme/output/include -rdynamic -Wl,-E CFLAGS = -Werror -Wextra -Wall -Wno-unused-command-line-argument -g3 -MMD -I./includes -I./output/include -I./stdme/output/include -rdynamic -Wl,-E
@ -59,13 +61,13 @@ LIBS_FILES = $(addprefix $(BUILD_DIR)/, $(addsuffix .a, $(addprefix lib, $(LIBS_
LIBS_FLAGS = $(addprefix -l, $(LIBS_NAMES)) LIBS_FLAGS = $(addprefix -l, $(LIBS_NAMES))
all: all:
@$(MAKE) -C ./stdme/ "LIB_NAME=$(shell realpath ./stdme)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libme.a @$(MAKE) -C ./stdme/ "LIB_NAME=$(shell realpath ./stdme)/" libme.a
@$(MAKE) -C ./allocator/ "LIB_NAME=$(shell realpath ./allocator)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libaq.a @$(MAKE) -C ./allocator/ "LIB_NAME=$(shell realpath ./allocator)/" libaq.a
@$(MAKE) -C ./ast/ "LIB_NAME=$(shell realpath ./ast)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libast.a @$(MAKE) -C ./ast/ "LIB_NAME=$(shell realpath ./ast)/" libast.a
@$(MAKE) -C ./exec/ "LIB_NAME=$(shell realpath ./exec)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libexec.a @$(MAKE) -C ./exec/ "LIB_NAME=$(shell realpath ./exec)/" libexec.a
@$(MAKE) -C ./line/ "LIB_NAME=$(shell realpath ./line)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libline.a @$(MAKE) -C ./line/ "LIB_NAME=$(shell realpath ./line)/" libline.a
@$(MAKE) -C ./parser/ -f ./Grammar.mk "LIB_NAME=$(shell realpath ./parser)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libgmr.a @$(MAKE) -C ./parser/ -f ./Grammar.mk "LIB_NAME=$(shell realpath ./parser)/" libgmr.a
@$(MAKE) -C ./parser/ -f ./Parser.mk "LIB_NAME=$(shell realpath ./parser)/" "BUILD_DIR=$(BUILD_DIR)" "CFLAGS_ADDITIONAL=$(CFLAGS_ADDITIONAL)" libparser.a @$(MAKE) -C ./parser/ -f ./Parser.mk "LIB_NAME=$(shell realpath ./parser)/" libparser.a
@$(MAKE) -f./Minishell.mk $(NAME) @$(MAKE) -f./Minishell.mk $(NAME)

View file

@ -9,11 +9,11 @@ me_alloc/merge_blocks \
me_alloc/pages \ me_alloc/pages \
me_alloc/realloc \ me_alloc/realloc \
vg/dummy_block \ vg/dummy_block \
vg/dummy_mem_status \
vg/dummy_mempool \ vg/dummy_mempool \
vg/dummy_mempool_bis \ vg/dummy_mempool_bis \
vg/dummy_mem_status \
vg/valgrind_block \ vg/valgrind_block \
vg/valgrind_mem_status \
vg/valgrind_mempool \ vg/valgrind_mempool \
vg/valgrind_mempool_bis \ vg/valgrind_mempool_bis \
vg/valgrind_mem_status \

View file

@ -3,4 +3,12 @@ from_node \
not_done_function \ not_done_function \
not_done_print \ not_done_print \
print_ast \ print_ast \
print_ast/ast_print_command \
print_ast/ast_print_global \
print_ast/ast_print_node \
print_ast/ast_print_redirection \
print_ast/ast_print_subshell \
print_ast/helper_function_print \
print_ast/print_arithmetic \
print_ast/print_ast \

View file

@ -12,7 +12,10 @@
#include "../../include/function_declaration.h" #include "../../include/function_declaration.h"
void ast_print_node_file_redirection_heredoc(t_ast_node self); void ast_print_node_file_redirection_heredoc(t_ast_node self)
{
(void)(self);
}
//{ //{
// if (self->data.file_redirection.op == AST_REDIR_HEREDOC) // if (self->data.file_redirection.op == AST_REDIR_HEREDOC)
// printf("<<"); // printf("<<");

View file

@ -56,34 +56,34 @@ void ast_print_node_program(t_ast_node self)
} }
} }
void ast_print_node_compound_statement(t_ast_node self) // void ast_print_node_compound_statement(t_ast_node self)
{ // {
t_usize i; // t_usize i;
if (self == NULL) // if (self == NULL)
return ; // return ;
if (self->kind != AST_COMPOUND_STATEMENT) // if (self->kind != AST_COMPOUND_STATEMENT)
return ; // return ;
i = 0; // i = 0;
if (self->data.compound_statement.bang) // if (self->data.compound_statement.bang)
printf("! "); // printf("! ");
printf("{ "); // printf("{ ");
while (i < self->data.compound_statement.body.len) // while (i < self->data.compound_statement.body.len)
{ // {
ast_print_node(self->data.compound_statement.body.buffer[i++]); // ast_print_node(self->data.compound_statement.body.buffer[i++]);
printf(" "); // printf(" ");
} // }
printf("}"); // printf("}");
i = 0; // i = 0;
while (i < self->data.compound_statement.suffixes_redirections.len) // while (i < self->data.compound_statement.suffixes_redirections.len)
{ // {
printf(" "); // printf(" ");
ast_print_node \ // ast_print_node \
(self->data.compound_statement.suffixes_redirections.buffer[i++]); // (self->data.compound_statement.suffixes_redirections.buffer[i++]);
} // }
printf(" "); // printf(" ");
_print_term(self->data.compound_statement.term); // _print_term(self->data.compound_statement.term);
} // }
void ast_print_node_compound_statement(t_ast_node self) void ast_print_node_compound_statement(t_ast_node self)
{ {

View file

@ -62,7 +62,7 @@ void ast_print_node(t_ast_node self)
if (self->kind == AST_ELSE) if (self->kind == AST_ELSE)
return (ast_print_node_else(self)); return (ast_print_node_else(self));
if (self->kind == AST_EMPTY) if (self->kind == AST_EMPTY)
return (ast_print_node_empty(self)); return ;
if (self->kind == AST_EXPANSION) if (self->kind == AST_EXPANSION)
return (ast_print_node_expansion(self)); return (ast_print_node_expansion(self));
if (self->kind == AST_EXTGLOB) if (self->kind == AST_EXTGLOB)

View file

@ -2,9 +2,9 @@ SRC_FILES = \
line \ line \
line_edit_actions \ line_edit_actions \
line_edit_actions2 \ line_edit_actions2 \
line_edit_mode \
line_editing \ line_editing \
line_editing2 \ line_editing2 \
line_edit_mode \
line_globals \ line_globals \
line_history \ line_history \
line_internals \ line_internals \

View file

@ -114,28 +114,6 @@ primary_state_ids/primary_state_ids_18 \
primary_state_ids/primary_state_ids_19 \ primary_state_ids/primary_state_ids_19 \
primary_state_ids/primary_state_ids_20 \ primary_state_ids/primary_state_ids_20 \
primary_state_ids/primary_state_ids_21 \ primary_state_ids/primary_state_ids_21 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
small_parse_table/small_parse_table_0 \ small_parse_table/small_parse_table_0 \
small_parse_table/small_parse_table_1 \ small_parse_table/small_parse_table_1 \
small_parse_table/small_parse_table_2 \ small_parse_table/small_parse_table_2 \
@ -968,6 +946,28 @@ small_parse_table/small_parse_table_828 \
small_parse_table/small_parse_table_829 \ small_parse_table/small_parse_table_829 \
small_parse_table/small_parse_table_830 \ small_parse_table/small_parse_table_830 \
small_parse_table/small_parse_table_831 \ small_parse_table/small_parse_table_831 \
small_parse_table_map/small_parse_table_map_0 \
small_parse_table_map/small_parse_table_map_1 \
small_parse_table_map/small_parse_table_map_2 \
small_parse_table_map/small_parse_table_map_3 \
small_parse_table_map/small_parse_table_map_4 \
small_parse_table_map/small_parse_table_map_5 \
small_parse_table_map/small_parse_table_map_6 \
small_parse_table_map/small_parse_table_map_7 \
small_parse_table_map/small_parse_table_map_8 \
small_parse_table_map/small_parse_table_map_9 \
small_parse_table_map/small_parse_table_map_10 \
small_parse_table_map/small_parse_table_map_11 \
small_parse_table_map/small_parse_table_map_12 \
small_parse_table_map/small_parse_table_map_13 \
small_parse_table_map/small_parse_table_map_14 \
small_parse_table_map/small_parse_table_map_15 \
small_parse_table_map/small_parse_table_map_16 \
small_parse_table_map/small_parse_table_map_17 \
small_parse_table_map/small_parse_table_map_18 \
small_parse_table_map/small_parse_table_map_19 \
small_parse_table_map/small_parse_table_map_20 \
small_parse_table_map/small_parse_table_map_21 \
symbols_metadata/symbols_metadata_0 \ symbols_metadata/symbols_metadata_0 \
symbols_metadata/symbols_metadata_1 \ symbols_metadata/symbols_metadata_1 \
symbols_names/symbols_names_0 \ symbols_names/symbols_names_0 \

View file

@ -38,10 +38,10 @@ fs/read \
fs/read_to_vec \ fs/read_to_vec \
fs/write \ fs/write \
gnl/get_next_line \ gnl/get_next_line \
hash/hasher \
hash/hash_signed \ hash/hash_signed \
hash/hash_str \ hash/hash_str \
hash/hash_unsigned \ hash/hash_unsigned \
hash/hasher \
hash/sip/sip13 \ hash/sip/sip13 \
hash/sip/sip_utils \ hash/sip/sip_utils \
hash/sip/sip_utils2 \ hash/sip/sip_utils2 \
@ -89,10 +89,6 @@ printf/printf \
printf/printf_fd \ printf/printf_fd \
printf/printf_str \ printf/printf_str \
printf/vprintf \ printf/vprintf \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
str/str_clone \ str/str_clone \
str/str_compare \ str/str_compare \
str/str_find_chr \ str/str_find_chr \
@ -109,6 +105,10 @@ str/str_n_find_str \
str/str_split \ str/str_split \
str/str_substring \ str/str_substring \
str/str_trim \ str/str_trim \
string/mod \
string/string_insert \
string/string_remove \
string/string_reserve \
GEN_FILES = \ GEN_FILES = \
convert/i16_to_str \ convert/i16_to_str \

View file

@ -6,7 +6,7 @@
/* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */ /* By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */ /* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/03 14:31:12 by maiboyer #+# #+# */ /* Created: 2023/11/03 14:31:12 by maiboyer #+# #+# */
/* Updated: 2024/07/11 18:54:29 by maiboyer ### ########.fr */ /* Updated: 2024/07/26 13:55:48 by maiboyer ### ########.fr */
/* */ /* */
/* ************************************************************************** */ /* ************************************************************************** */
@ -64,9 +64,16 @@ void me_exit(t_i32 code);
/// @brief a function that prints the current stack trace /// @brief a function that prints the current stack trace
void print_trace(void); void print_trace(void);
# ifndef ERROR
/// @def signal that an error occured /// @def signal that an error occured
# define ERROR 1 # define ERROR 1
# else
# include <stdio.h>
# endif
# ifndef NO_ERROR
/// @def signal that no error occured /// @def signal that no error occured
# define NO_ERROR 0 # define NO_ERROR 0
# endif
#endif #endif