From aef1200e97d2871c4796166895f62e1683c0c3d2 Mon Sep 17 00:00:00 2001 From: rask24 Date: Wed, 10 Jan 2024 15:03:02 +0900 Subject: [PATCH] init --- .github/workflows/ci.yml | 16 +++++++++ .gitignore | 69 +++++++++++++++++++++++++++++++++++++ .gitmodules | 3 ++ Makefile | 73 ++++++++++++++++++++++++++++++++++++++++ include/push_swap.h | 24 +++++++++++++ libft | 1 + src/main.c | 19 +++++++++++ test/test.cpp | 7 ++++ 8 files changed, 212 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 .gitmodules create mode 100644 Makefile create mode 100644 include/push_swap.h create mode 160000 libft create mode 100644 src/main.c create mode 100644 test/test.cpp diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..2dcb567 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,16 @@ +name: Continuous Integration +on: + push: +jobs: + norm: + name: norminette + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - name: Install dependencies + run: | + python3 -m pip install --upgrade pip setuptools + python3 -m pip install norminette + - name: Run Norminette + run: make norm diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..45feb8f --- /dev/null +++ b/.gitignore @@ -0,0 +1,69 @@ +# Prerequisites +*.d + +# Object files +*.o +*.ko +*.obj +*.elf + +# Linker output +*.ilk +*.map +*.exp + +# Precompiled Headers +*.gch +*.pch + +# Libraries +*.lib +*.a +*.la +*.lo + +# Shared objects (inc. Windows DLLs) +*.dll +*.so +*.so.* +*.dylib + +# Executables +*.exe +*.out +*.app +*.i*86 +*.x86_64 +*.hex + +# Debug files +*.dSYM/ +*.su +*.idb +*.pdb + +# Kernel Module Compile Results +*.mod* +*.cmd +.tmp_versions/ +modules.order +Module.symvers +Mkfile.old +dkms.conf + +# Vscode +.vscode/ + +# Build Directory +build/ + +# Executable File +push_swap +checker_Mac +tester + +# Subject File +en.subject.pdf + +# Google Test Source +gtest/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..14ebffc --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "libft"] + path = libft + url = git@github.com:rask24/libft diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..448ceac --- /dev/null +++ b/Makefile @@ -0,0 +1,73 @@ +NAME = push_swap +CFLAGS = -Werror -Wextra -Wall -O3 +NORM = norminette + +SRC_DIR = ./src +BUILD_DIR = ./build +INC_DIR = ./include +LIBFT_DIR = ./libft +SRC = $(SRC_DIR)/main.c +OBJ = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.o, $(SRC)) +DEP = $(patsubst $(SRC_DIR)/%.c, $(BUILD_DIR)/%.d, $(SRC)) +DEPFLAGS = -MMD -MP +INCLUDE = -I $(INC_DIR) + +GTEST_VERSION = 1.8.0 +GTEST_DIR = ./gtest +GTEST = $(GTEST_DIR)/gtest $(GTEST_DIR)/googletest-release-$(GTEST_VERSION) +TEST_DIR = ./test +TEST_SRC = $(TEST_DIR)/test.cpp +TEST_COMPILE = clang++ -std=c++11 \ + $(TEST_SRC) \ + $(GTEST_DIR)/googletest-release-$(GTEST_VERSION)/googletest/src/gtest_main.cc \ + $(GTEST_DIR)/gtest/gtest-all.cc \ + -I $(GTEST_DIR) $(INCLUDE) -L $(LIBFT_DIR) -l ft -lpthread -o tester + +GREEN = \033[0;32m +BLUE = \033[0;34m +RED = \033[0;31m +RESET = \033[0m + +all: title $(NAME) + +$(NAME): $(OBJ) + @printf "\n" + @make -C $(LIBFT_DIR) + @$(CC) $^ -o $@ + +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.c + @mkdir -p $(@D) + @$(CC) $(CFLAGS) $(INCLUDE) $(DEPFLAGS) -c $< -o $@ + @printf "$(GREEN).$(RESET)" + +clean: + @make clean -C $(LIBFT_DIR) + @$(RM) $(OBJ) + +fclean: clean + @make fclean -C $(LIBFT_DIR) + @$(RM) $(NAME) + +re: fclean all + +test: $(GTEST) + @echo "$(BLUE)test$(RESET)" + @$(TEST_COMPILE) + @./tester # --gtest_filter=Vector.other + +$(GTEST): + @curl -OL https://github.com/google/googletest/archive/refs/tags/release-$(GTEST_VERSION).tar.gz + @tar -xvzf release-$(GTEST_VERSION).tar.gz googletest-release-$(GTEST_VERSION) + @$(RM) release-$(GTEST_VERSION).tar.gz + @python3 googletest-release-$(GTEST_VERSION)/googletest/scripts/fuse_gtest_files.py $(GTEST_DIR) + @mv googletest-release-$(GTEST_VERSION) $(GTEST_DIR) + +norm: + $(NORM) $(INC_DIR) $(SRC_DIR) $(LIBFT_DIR) + +title: + @echo "$(BLUE)push_swap$(RESET)" + +.PHONY: all clean fclean re + +-include $(DEP) diff --git a/include/push_swap.h b/include/push_swap.h new file mode 100644 index 0000000..fdfacbe --- /dev/null +++ b/include/push_swap.h @@ -0,0 +1,24 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* push_swap.h :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: reasuke +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/10 12:37:54 by reasuke #+# #+# */ +/* Updated: 2024/01/10 14:55:50 by reasuke ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#ifndef PUSH_SWAP_H +# define PUSH_SWAP_H + +# include +# include + +// TODO: delete +# include + +# include "../libft/libft.h" + +#endif diff --git a/libft b/libft new file mode 160000 index 0000000..ccce01e --- /dev/null +++ b/libft @@ -0,0 +1 @@ +Subproject commit ccce01ebf197d100a9f1ffeef6afb7816db5cc21 diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..c76828c --- /dev/null +++ b/src/main.c @@ -0,0 +1,19 @@ +/* ************************************************************************** */ +/* */ +/* ::: :::::::: */ +/* main.c :+: :+: :+: */ +/* +:+ +:+ +:+ */ +/* By: reasuke +#+ +:+ +#+ */ +/* +#+#+#+#+#+ +#+ */ +/* Created: 2024/01/10 12:37:36 by reasuke #+# #+# */ +/* Updated: 2024/01/10 14:59:00 by reasuke ### ########.fr */ +/* */ +/* ************************************************************************** */ + +#include "push_swap.h" + +int main(void) +{ + printf("This is push_swap main file.\n"); + return (0); +} diff --git a/test/test.cpp b/test/test.cpp new file mode 100644 index 0000000..70587e6 --- /dev/null +++ b/test/test.cpp @@ -0,0 +1,7 @@ +#include "gtest/gtest.h" + +extern "C" { + #include "push_swap.h" +} + +TEST(FunctionTest, Case) {}