diff --git a/Minishell.mk b/Minishell.mk index 950d2fc8..84d85851 100644 --- a/Minishell.mk +++ b/Minishell.mk @@ -6,7 +6,7 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2024/04/28 17:28:30 by maiboyer #+# #+# # -# Updated: 2024/07/10 21:02:49 by maiboyer ### ########.fr # +# Updated: 2024/07/11 17:14:34 by maiboyer ### ########.fr # # # # **************************************************************************** # @@ -54,7 +54,7 @@ END = \033[0m .PHONY: all Bonus -LIBS_NAMES = me gmr aq ast parser line +LIBS_NAMES = me gmr aq ast parser line exec LIBS_FILES = $(addprefix $(BUILD_DIR)/, $(addsuffix .a, $(addprefix lib, $(LIBS_NAMES)))) LIBS_FLAGS = $(addprefix -l, $(LIBS_NAMES)) @@ -62,6 +62,7 @@ all: @$(MAKE) -C ./stdme/ "LIB_NAME=$(shell realpath ./stdme)/" "BUILD_DIR=$(BUILD_DIR)" libme.a @$(MAKE) -C ./allocator/ "LIB_NAME=$(shell realpath ./allocator)/" "BUILD_DIR=$(BUILD_DIR)" libaq.a @$(MAKE) -C ./ast/ "LIB_NAME=$(shell realpath ./ast)/" "BUILD_DIR=$(BUILD_DIR)" libast.a + @$(MAKE) -C ./exec/ "LIB_NAME=$(shell realpath ./exec)/" "BUILD_DIR=$(BUILD_DIR)" libexec.a @$(MAKE) -C ./line/ "LIB_NAME=$(shell realpath ./line)/" "BUILD_DIR=$(BUILD_DIR)" libline.a @$(MAKE) -C ./parser/ -f./Grammar.mk "LIB_NAME=$(shell realpath ./parser)/" "BUILD_DIR=$(BUILD_DIR)" libgmr.a @$(MAKE) -C ./parser/ -f./Parser.mk "LIB_NAME=$(shell realpath ./parser)/" "BUILD_DIR=$(BUILD_DIR)" libparser.a diff --git a/allocator/Makefile b/allocator/Makefile index b1cb3d6c..aa63640d 100644 --- a/allocator/Makefile +++ b/allocator/Makefile @@ -6,11 +6,11 @@ # By: maiboyer +#+ +:+ +#+ # # +#+#+#+#+#+ +#+ # # Created: 2023/11/03 13:20:01 by maiboyer #+# #+# # -# Updated: 2024/07/03 22:39:16 by maiboyer ### ########.fr # +# Updated: 2024/07/11 17:11:52 by maiboyer ### ########.fr # # # # **************************************************************************** # -BUILD_DIR ?= build +BUILD_DIR ?= ../build SRC_DIR = src INCLUDE_DIR = include output/include ../stdme/include LIBS_DIR = . diff --git a/ast/src.list b/ast/src.list index 91bcc0a2..096cf66f 100644 --- a/ast/src.list +++ b/ast/src.list @@ -1,4 +1,3 @@ -empty from_node not_done_function print_ast diff --git a/exec/Makefile b/exec/Makefile new file mode 100644 index 00000000..0bced878 --- /dev/null +++ b/exec/Makefile @@ -0,0 +1,96 @@ +# **************************************************************************** # +# # +# ::: :::::::: # +# Makefile :+: :+: :+: # +# +:+ +:+ +:+ # +# By: maiboyer +#+ +:+ +#+ # +# +#+#+#+#+#+ +#+ # +# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# # +# Updated: 2024/07/11 17:13:13 by maiboyer ### ########.fr # +# # +# **************************************************************************** # + +BUILD_DIR ?= ../build +SRC_DIR = src +INCLUDE_DIR = include/ output/include/ ../includes/ ../output/include/ +LIBS_DIR = . +GENERIC_DIR = output/src +GENERIC_INCLUDE = output/include + + +BASE_PATH ?= $(shell pwd) +NAME = libexec.a +LIB_NAME ?= +TARGET = $(BUILD_DIR)/$(NAME) +CC ?= clang +CFLAGS = -Wno-unused-command-line-argument -Wall -Werror -Wextra -g3 -L$(BUILD_DIR) -MMD -rdynamic -DBASE_PATH='"$(BASE_PATH)/"' +# CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=runtime -fno-common -fsanitize-address-use-after-scope +BONUS_FILES = +LIBS_NAME = +SUBJECT_URL = + +SRC_FILES = $(shell cat src.list) + +SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES))) +OBJ = $(addsuffix .o,$(addprefix $(BUILD_DIR)/exec/,$(SRC_FILES))) +DEPS = $(addsuffix .d,$(addprefix $(BUILD_DIR)/exec/,$(SRC_FILES))) + +LIBS = $(addprefix $(LIBS_DIR)/,$(LIBS_NAME)) +INCLUDES = $(addprefix -I,$(foreach P,$(INCLUDE_DIR) $(LIBS) $(addsuffix /include,$(LIBS)) vendor $(addsuffix /vendor,$(LIBS)),$(realpath $(P)))) +COL_BOLD = \033[1m +COL_GOLD = \033[93m +COL_GRAY = \033[90m +COL_GREEN = \033[32m +COL_RESET = \033[0m +COL_WHITE = \033[37m + +# TODO: REMOVE FOR RENDU !!!!! +CFLAGS += -DPRINT_BACKTRACE + + +.PHONY = all bonus clean re subject + +all: $(NAME) + +$(NAME): $(TARGET) + +$(TARGET): $(OBJ) + @echo -e '$(COL_GRAY) Linking \t$(COL_GOLD)$(TARGET)$(COL_RESET)' + @ar rcs $(BUILD_DIR)/$(NAME) $(OBJ) + +$(BUILD_DIR)/exec/%.o: $(SRC_DIR)/%.c + @mkdir -p $(dir $@) + @echo -e '$(COL_GRAY) Building\t$(COL_GREEN)$<$(COL_RESET)' + @$(CC) $(CFLAGS) $(WERROR) $(INCLUDES) -c $< -o $@ + +$(BUILD_DIR)/exec/%.o: $(GENERIC_DIR)/%.c + @mkdir -p $(dir $@) + @echo -e '$(COL_GRAY) Building\t$(COL_GREEN)$<$(COL_RESET)' + @$(CC) $(CFLAGS) $(WERROR) $(INCLUDES) -c $< -o $@ + +clean: + @- $(foreach LIB,$(LIBS), \ + make clean LIB_NAME=$(LIB)/ BUILD_DIR=$(realpath $(BUILD_DIR)) -C $(LIB) --no-print-directory || true;\ + ) + @- $(if $(LIB_NAME),,echo -e '$(COL_WHITE)Clearing Artefacts';rm -rf $(BUILD_DIR)) + +fclean: clean + @- $(foreach LIB,$(LIBS), \ + make fclean LIB_NAME=$(LIB)/ BUILD_DIR=$(shell realpath $(BUILD_DIR)) -C $(LIB) --no-print-directory || true;\ + ) + @echo -e '$(COL_WHITE)Clearing Output $(COL_GRAY)$(LIB_NAME)$(NAME)' + @rm -f $(BUILD_DIR)$(NAME) + +re: fclean all + +subject: subject.txt + bat --plain ./subject.txt + +subject.txt: + @curl $(SUBJECT_URL) | pdftotext -layout -nopgbrk -q - subject.txt + +generate_filelist:: + @/usr/bin/env zsh -c "tree -iFf --noreport output | rg '^output/src/(.*)\.c\$$' --replace '\$$1' | sort -u" > ./gen.list + @/usr/bin/env zsh -c "tree -iFf --noreport src | rg '^src/(.*)\.c\$$' --replace '\$$1' | sort -u" > ./src.list + +-include $(DEPS) diff --git a/exec/gen.list b/exec/gen.list new file mode 100644 index 00000000..e69de29b diff --git a/exec/include/exec/run.h b/exec/include/exec/run.h new file mode 100644 index 00000000..d610d911 --- /dev/null +++ b/exec/include/exec/run.h @@ -0,0 +1,20 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* run.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/11 17:23:24 by maiboyer #+# #+# */ +/* Updated: 2024/07/11 17:38:05 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef RUN_H +#define RUN_H + +#include "me/types.h" + + + +#endif /* RUN_H */ diff --git a/exec/src.list b/exec/src.list new file mode 100644 index 00000000..10cfe6fb --- /dev/null +++ b/exec/src.list @@ -0,0 +1 @@ +run_ast diff --git a/exec/src/run_ast.c b/exec/src/run_ast.c new file mode 100644 index 00000000..4a638be8 --- /dev/null +++ b/exec/src/run_ast.c @@ -0,0 +1,15 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* run_ast.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: maiboyer +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/07/11 17:22:29 by maiboyer #+# #+# */ +/* Updated: 2024/07/11 17:22:57 by maiboyer ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "me/types.h" +#include "ast/ast.h" +#include "exec/run.h" diff --git a/includes/exec b/includes/exec new file mode 120000 index 00000000..374f36bb --- /dev/null +++ b/includes/exec @@ -0,0 +1 @@ +../exec/include/exec \ No newline at end of file