Switched to Filelist.<name>.mk files

This commit is contained in:
Maieul BOYER 2024-07-23 22:04:11 +00:00
parent fd646bda95
commit c3626fc59e
42 changed files with 456 additions and 399 deletions

View file

@ -114,6 +114,28 @@ primary_state_ids/primary_state_ids_18 \
primary_state_ids/primary_state_ids_19 \
primary_state_ids/primary_state_ids_20 \
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_1 \
small_parse_table/small_parse_table_2 \
@ -946,28 +968,6 @@ small_parse_table/small_parse_table_828 \
small_parse_table/small_parse_table_829 \
small_parse_table/small_parse_table_830 \
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_1 \
symbols_names/symbols_names_0 \

20
parser/Filelist.parser.mk Normal file
View file

@ -0,0 +1,20 @@
SRC_FILES = \
create_language \
input \
language \
length \
lex \
lexer \
lib \
node \
parser \
point \
reduce_action \
scanner \
stack \
subtree \
tree \
GEN_FILES = \
\

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
# Updated: 2024/06/30 18:45:33 by maiboyer ### ########.fr #
# Updated: 2024/07/23 21:53:40 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
@ -23,13 +23,10 @@ LIB_NAME ?=
TARGET = $(BUILD_DIR)/$(NAME)
CC ?= cc
CFLAGS = -Wall -Wextra -Werror -MMD -I./includes -I../includes -I../output/include -I../tree-sitter-sh/src
CFLAGS += $(CFLAGS_ADDITIONAL)
#CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=runtime -fno-common -fsanitize-address-use-after-scope
include ./Filelist.mk
#SRC_FILES = parser
#scanner
#parser
-include Filelist.$(ANAME).mk
SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES)))
OBJ = $(addsuffix .o,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(SRC_FILES)))
@ -76,4 +73,11 @@ re:
@$(MAKE) --no-print-directory fclean
@$(MAKE) --no-print-directory all
build_filelist:
@rm -f Filelist.$(ANAME).mk
@printf '%-78s\\\n' "SRC_FILES =" > Filelist.$(ANAME).mk
@tree static -ifF | rg 'static/(.*)\.c$$' --replace '$$1' | sed -re 's/^(.*)_([0-9]+)$$/\1|\2/g' | sort -t'|' --key=1,1 --key=2,2n | sed -e's/|/_/' | xargs printf '%-78s\\\n' >> Filelist.$(ANAME).mk
@echo "" >> Filelist.$(ANAME).mk
@echo -e "$(GREY) Populating $(GREEN) Filelist.$(ANAME).mk$(END)"
-include $(DEPS)

View file

@ -6,7 +6,7 @@
# By: rparodi <rparodi@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/12 11:05:05 by rparodi #+# #+# #
# Updated: 2024/06/09 19:14:28 by maiboyer ### ########.fr #
# Updated: 2024/07/23 20:58:57 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
@ -23,9 +23,8 @@ libgmr.a:
@$(MAKE) --no-print-directory -f Grammar.mk "LIB_NAME=$(shell realpath .)/" "BUILD_DIR=$(shell realpath $(BUILD_DIR))" libgmr.a
build_filelist:
@rm Filelist.mk
@printf '%-78s\\\n' "SRC_FILES =" > Filelist.mk
@tree static -ifF | rg 'static/(.*)\.c$$' --replace '$$1' | sed -re 's/^(.*)_([0-9]+)$$/\1|\2/g' | sort -t'|' --key=1,1 --key=2,2n | sed -e's/|/_/' | xargs printf '%-78s\\\n' >> Filelist.mk
@echo "" >> Filelist.mk
@$(MAKE) --no-print-directory -f Parser.mk build_filelist
@$(MAKE) --no-print-directory -f Grammar.mk build_filelist
.PHONY: all bonus clean fclean re libparser.a libgmr.a build_filelist

View file

@ -6,7 +6,7 @@
# By: maiboyer <maiboyer@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/03 13:20:01 by maiboyer #+# #+# #
# Updated: 2024/06/30 16:23:47 by maiboyer ### ########.fr #
# Updated: 2024/07/23 21:53:53 by maiboyer ### ########.fr #
# #
# **************************************************************************** #
@ -22,12 +22,16 @@ LIB_NAME ?=
TARGET = $(BUILD_DIR)/$(NAME)
CC ?= cc
CFLAGS = -Wall -Wextra -Werror -MMD -I./includes -I../includes -I../output/include -g3 -I$(SRC_DIR)
CFLAGS += $(CFLAGS_ADDITIONAL)
#CFLAGS += -fsanitize=address -fno-omit-frame-pointer -fsanitize-address-use-after-return=runtime -fno-common -fsanitize-address-use-after-scope
SRC_FILES = lib
GEN_FILES =
SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES))) $(addsuffix .c,$(addprefix $(GEN_DIR)/,$(GEN_FILES)))
# TODO: change from only lib.c to filelist
#-include Filelist.$(ANAME).mk
SRC = $(addsuffix .c,$(addprefix $(SRC_DIR)/,$(SRC_FILES)) $(addprefix $(GEN_DIR)/,$(GEN_FILES)))
OBJ = $(addsuffix .o,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(SRC_FILES))) $(addsuffix .o,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(GEN_FILES)))
DEPS = $(addsuffix .d,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(SRC_FILES))) $(addsuffix .d,$(addprefix $(BUILD_DIR)/$(ANAME)/,$(GEN_FILES)))
@ -54,6 +58,11 @@ $(BUILD_DIR)/$(ANAME)/%.o: $(SRC_DIR)/%.c
@echo -e '$(GREY) Building\t$(END)$(GREEN)$<$(END)'
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/$(ANAME)/%.o: $(GEN_DIR)/%.c
@mkdir -p $(dir $@)
@echo -e '$(GREY) Building\t$(END)$(GREEN)$<$(END)'
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@- $(foreach LIB,$(LIBS), \
make clean LIB_NAME=$(LIB)/ BUILD_DIR=$(realpath $(BUILD_DIR)) -C $(LIB) --no-print-directory || true;\
@ -72,4 +81,14 @@ re:
@$(MAKE) --no-print-directory fclean
@$(MAKE) --no-print-directory all
build_filelist:
@rm -f Filelist.$(ANAME).mk
@printf '%-78s\\\n' "SRC_FILES =" > Filelist.$(ANAME).mk
@tree $(SRC_DIR) -ifF | rg '$(SRC_DIR)/(.*)\.c$$' --replace '$$1' | sed -re 's/^(.*)_([0-9]+)$$/\1|\2/g' | sort -t'|' --key=1,1 --key=2,2n | sed -e's/|/_/' | xargs printf '%-78s\\\n' >> Filelist.$(ANAME).mk
@echo "" >> Filelist.$(ANAME).mk
@printf '%-78s\\\n' "GEN_FILES =" >> Filelist.$(ANAME).mk
@tree $(GEN_DIR) -ifF | rg '$(GEN_DIR)/(.*)\.c$$' --replace '$$1' | sed -re 's/^(.*)_([0-9]+)$$/\1|\2/g' | sort -t'|' --key=1,1 --key=2,2n | sed -e's/|/_/' | xargs printf '%-78s\\\n' >> Filelist.$(ANAME).mk
@echo "" >> Filelist.$(ANAME).mk
@echo -e "$(GREY) Populating $(GREEN) Filelist.$(ANAME).mk$(END)"
-include $(DEPS)