Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f626a8b
Fixed split_in_two
oddtiming Apr 21, 2022
d9f6230
Fixed deques
oddtiming Apr 21, 2022
7708f98
Fixed undo_moves
oddtiming Apr 21, 2022
ea7050b
fixed parse.c
oddtiming Apr 21, 2022
0ca41cc
Created block_utils
oddtiming Apr 21, 2022
8fa41a8
split_in_blocks.c, deque_operators.c
oddtiming Apr 21, 2022
3f6f8bd
Normed insert_utils.c
oddtiming Apr 21, 2022
c0cb894
sort_utils.c: OK!
oddtiming Apr 21, 2022
c1f8259
cleanup.c: OK!
oddtiming Apr 21, 2022
1e3c95d
utils.c: OK!
oddtiming Apr 21, 2022
4dd0d43
rrx.c: OK!
oddtiming Apr 21, 2022
8ed81f3
Normed insert_blocks.c, insert_blocks_utils.c
oddtiming Apr 21, 2022
cad7b2e
Normed deque_utils.c
oddtiming Apr 21, 2022
ece12c7
Added new files
oddtiming Apr 21, 2022
07ebaff
Normed
oddtiming Apr 21, 2022
ef2974a
Started working on bonus
oddtiming Apr 21, 2022
7309710
Updated push
oddtiming Apr 21, 2022
b5a6a1f
Added checker_bonus
oddtiming Apr 21, 2022
066fbdf
Updated submodule
Apr 25, 2022
b9d46ca
Updated submodule
oddtiming Apr 25, 2022
7cd1402
Started modifications
Apr 27, 2022
859a3ff
Merge branch 'backup_rework' of github.com:oddtiming/push_swap into b…
Apr 27, 2022
5ced6db
ft_safealloc() --> libft/ft_xalloc()
oddtiming Apr 28, 2022
97903c3
Fixed delta_insert
oddtiming Apr 28, 2022
ceb30de
Unfucked the bonus, but found worse
oddtiming Apr 28, 2022
49b557b
Fixed bonus
oddtiming Apr 30, 2022
9d833ed
Fixed i/o redir
oddtiming Apr 30, 2022
e168164
Norminetted all but deques.h
oddtiming Apr 30, 2022
0505b58
Still can't fix norminette
oddtiming May 1, 2022
4e7e6c5
It is fixed !
May 1, 2022
0868789
Finally finished cleaning up
oddtiming May 2, 2022
e40089e
Ready to remove libft
oddtiming May 2, 2022
728e0bb
Fixed libft include in Makefile's `bonus` rule
May 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ dkms.conf
*.swp
.vscode
*.txt
checker*
checker_Mac
push_swap
push_swap_debug
*.o
Expand Down
120 changes: 0 additions & 120 deletions 5_permutations.txt

This file was deleted.

51 changes: 0 additions & 51 deletions 5_permutations_post_pb.txt

This file was deleted.

116 changes: 57 additions & 59 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
NAME = push_swap

NAME_BONUS = checker_bonus

# FOR TESTING PURPOSES
RUN_ARGS = 37 15 27 4 6 33 12 19 31 3 2 13 49 42 22 16 39 10 24 8 41 5 1 28 7 40 29 47 21 35 50 48 38 45 34 36 44 20 32 17 9 23 25 11 26 14 46 43 30 18

Expand All @@ -12,20 +14,25 @@ RED = \033[0;31m
ON_RED = \033[41m
RESET_COL = \033[0m

CFILES = algorithms.c \
CFILES = block_utils.c \
calc_insert_cost.c \
cherrypick.c \
cherrypick_utils.c \
cleanup.c \
delta_insert.c \
deques.c \
deque_modify.c \
deque_operators.c \
deque_utils.c \
errors.c \
ignore_LIS.c \
ignore_lis.c \
ignore_lis_utils.c \
init.c \
insert.c \
insert_blocks.c \
insert_blocks_utils.c \
insert_utils.c \
iterators.c \
longest_increas_subseq.c \
lis_utils.c \
parse.c \
partition_leaving_vals.c \
partition_stack.c \
Expand All @@ -35,48 +42,53 @@ CFILES = algorithms.c \
rrx.c \
rx.c \
sort.c \
sort_big.c \
sort_utils.c \
sort_small.c \
split_in_blocks.c \
split_in_two.c \
split_in_two_utils.c \
sx.c \
try_x.c \
undo_moves.c \
utils.c
undo_moves.c

CFILES_BONUS = checker_bonus.c \
checker_utils_bonus.c \
deques.c \
deque_modify.c \
deque_operators.c \
deque_utils.c \
errors.c \
ft_read_line.c \
px_bonus.c \
parse_bonus.c \
rx_bonus.c \
rrx_bonus.c \
sx_bonus.c \
undo_moves.c

HFILES = push_swap.h \
deques.h

SRC_DIR = src
SRCS = $(addprefix $(SRC_DIR)/, $(CFILES))


OBJ_DIR = obj
OBJS = $(addprefix $(OBJ_DIR)/, $(CFILES:.c=.o))
OBJ_DIR = obj
OBJS = $(addprefix $(OBJ_DIR)/, $(CFILES:.c=.o))
OBJS_BONUS = $(addprefix $(OBJ_DIR)/, $(CFILES_BONUS:.c=.o))

INCL = include
INCLFLAGS = -I$(INCL)
HEADERS = $(addprefix $(INCL)/, $(HFILES))

CC = gcc
CFLAGS = -Wall -Wextra -Werror -g -O3

#
# DEBUG build settings
#
DBG_DIR = debug_objs
DBG_EXE = push_swap_try_pb_debug
DBG_OBJS = $(addprefix $(DBG_DIR)/, $(CFILES:.c=.o))
DBG_CFLAGS = -D DEBUG=1 -g

CFLAGS = -Wall -Wextra -Werror -O3

LIBFT_DIR = ./libft
LIBFT = $(LIBFT_DIR)/libft.a
LIBFT_FLAGS = -lft -Llibft

RM_OBJS = rm -rf $(OBJ_DIR)
RM_OBJS_OUT = $$($(RM_OBJS) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')
RM_EXE = rm -f $(NAME)
RM_EXE = rm -f $(NAME) $(NAME_BONUS)
RM_EXE_OUT = $$($(RM_EXE) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')
RM_LIBFT = make clean -sC ./libft
RM_LIBFT_OUT = $$($(RM_LIBFT) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')
Expand All @@ -87,23 +99,15 @@ COMPILE_EXE_OUT = $$($(COMPILE_EXE) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\0
COMPILE_C = $(CC) $(CFLAGS) $(INCLFLAGS) -o $@ -c $<
COMPILE_C_OUT = $$($(COMPILE_C) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')

COMPILE_EXE_BONUS = $(CC) $(CFLAGS) $(LIBFT_FLAGS) $(INCLFLAGS) $(OBJS_BONUS) -o $(NAME_BONUS)
COMPILE_EXE_BONUS_OUT = $$($(COMPILE_EXE_BONUS) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')

COMPILE_C_BONUS = $(CC) $(CFLAGS) $(INCLFLAGS) -o $@ -c $<
COMPILE_C_BONUS_OUT = $$($(COMPILE_C_BONUS) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')

$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
@printf "$(CYAN)%-30s-->%30s $(RESET_COL)$(COMPILE_C_OUT)\n" $^ $@

#
# DEBUG MACROS
#
COMPILE_DBG_EXE = $(CC) $(DBG_CFLAGS) $(LIBFT_FLAGS) $(INCLFLAGS) $(DBG_OBJS) -o $(DBG_EXE)
COMPILE_DBG_EXE_OUT = $$($(COMPILE_DBG_EXE) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')
COMPILE_DBGC = $(CC) $(DBG_CFLAGS) $(INCLFLAGS) -o $@ -c $<
COMPILE_DBGC_OUT = $$($(COMPILE_DBGC) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')
RM_DBG_EXE = rm $(DBG_EXE)
RM_DBG_EXE_OUT = $$($(RM_DBG_EXE) 2>&1 | sed -e 's/error/\\\033[0;31merror\\\033[0m/g' -e 's/warning/\\\033[0;33mwarning\\\033[0m/g')

$(DBG_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(DBG_DIR)
@echo -e "$(ON_RED)>\t$^\t--> $@ $(RESET_COL)$(COMPILE_DBGC_OUT)"
@printf "$(CYAN)%-32s-->%32s $(RESET_COL)$(COMPILE_C_OUT)\n" $^ $@

all: $(NAME)
@if [ -e $(NAME) ]; \
Expand All @@ -113,12 +117,23 @@ all: $(NAME)
echo -e "$(RED)>>>>>>>> Compilation failed\n>>>>>>>>$(RESET_COL)"; \
fi

bonus: $(NAME_BONUS)
@if [ -e $(NAME_BONUS) ]; \
then \
echo -e "$(GREEN)>>>>>>>> Compilation successful\n>>>>>>>>$(RESET_COL)"; \
else \
echo -e "$(RED)>>>>>>>> Compilation failed\n>>>>>>>>$(RESET_COL)"; \
fi


$(NAME): libft pretty_print $(OBJS)
@echo -e "\n$(CYAN)>>>>>>>> Compiling $(NAME) ...$(RESET_COL)$(COMPILE_EXE_OUT)"

$(NAME_BONUS): libft pretty_print_bonus $(OBJS_BONUS)
@echo -e "\n$(CYAN)>>>>>>>> Compiling $(NAME_BONUS) ...$(RESET_COL)$(COMPILE_EXE_BONUS_OUT)"

silent_libft:
@echo -e "---------------------- libft.a ----------------------\n"
@echo -e "---------------------- libft ----------------------\n"
@echo -e "$(CYAN)>>>>>>>> Archiving libft.a ...$(RESET_COL)"
@make -s bonus -C $(LIBFT_DIR)
@if [ -e $(LIBFT) ]; \
Expand All @@ -133,7 +148,6 @@ libft: silent_libft
pretty_print:
@echo -e "\n--------------------- $(NAME) ---------------------"


clean:
@echo -e "$(RED)>>>>>>>> Deleting obj files$(RESET_COL)$(RM_OBJS_OUT)"
@echo -e "$(GREEN)>>>>>>>> obj files deleted\n>>>>>>>>$(RESET_COL)"
Expand All @@ -142,32 +156,16 @@ clean_libft:
@echo -e "$(RED)>>>>>>>> make fclean -sC libft $(RESET_COL)$(RM_LIBFT_OUT)"
@echo -e "$(GREEN)>>>>>>>> libft cleaned\n>>>>>>>>$(RESET_COL)"

clean_debug: clean
@echo -e "$(RED)>>>>>>>> Deleting debug obj files$(RESET_COL)$(RM_DBG_EXE_OUT)"
@echo -e "$(GREEN)>>>>>>>> obj files deleted\n>>>>>>>>$(RESET_COL)"

fclean: clean clean_libft clean_debug
fclean: clean clean_libft
@echo -e "$(RED)>>>>>>>> Deleting $(NAME)$(RESET_COL)$(RM_EXE_OUT)"
@echo -e "$(GREEN)>>>>>>>> ./$(NAME) deleted\n>>>>>>>>$(RESET_COL)"

re: fclean all

test5: all
gcc -g push_swap_tester.c libft/libft.a && ./a.out 5;

bonus: all
pretty_print_bonus:
@echo -e "$(GREEN)\n------------------- $(NAME_BONUS) -------------------$(RESET_COL)\n"

run: all
./$(NAME) $(RUN_ARGS)

#
# Debug rules
#
pretty_print_debug:
@echo -e "$(RED)\n------------------- $(DBG_EXE) -------------------$(RESET_COL)\n"

debug: all pretty_print_debug $(DBG_OBJS)
@echo -e "\n$(ON_RED)>>>>>>>> Compiling $(DBG_EXE) ...$(RESET_COL)$(COMPILE_DBG_EXE_OUT)"
./$(DBG_EXE) $(RUN_ARGS)

.PHONY: all clean clean_libft fclean re bonus libft silent_libft pretty_print pretty_print_debug run debug test5
.PHONY: all clean clean_libft fclean re bonus libft silent_libft pretty_print pretty_print_bonus run
Loading