Skip to content

Commit

Permalink
Merge pull request #11 from samih713/clean-up
Browse files Browse the repository at this point in the history
merge: Clean-up into server
  • Loading branch information
samih713 authored Jan 22, 2024
2 parents e545889 + d07fb53 commit e075939
Show file tree
Hide file tree
Showing 37 changed files with 326 additions and 16,514 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/compile-check.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
name: Compilation Check
name: Clean-Up Compilation Check

on:
push:
branches:
- server/ver-01.1
- clean-up

jobs:
build:
runs-on: ubuntu-latest
build-linux:
runs-on:
- ubuntu-latest

steps:
- name: Checkout repository
Expand All @@ -19,6 +20,20 @@ jobs:
compiler: gcc

- name: Build project
run: |
cd ver-01.1
make
run: make

build-Mac:
runs-on:
- macos-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up C++ environment
uses: aminya/setup-cpp@v1
with:
compiler: gcc

- name: Build project
run: make
11 changes: 9 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
.vscode/
*/objs/
*/objects/
*/.cache/

*.o
libserver.a
libparser.a
webserver
test_parser
test_server
test_socket
client
77 changes: 77 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
### COLORS ####
BLUE:= \033[1;34m
GREEN:= \033[1;32m
MAGENTA:= \033[1;35m
RED:= \033[1;31m
YELLOW:= \033[1;33m
RESET:= \033[0m

CXX:= c++
CXXFLAGS:= -Wall -Werror -Wextra
DEBUGFLAGS:= -ggdb3 -fsanitize=address -D__DEBUG__

ifeq ($(shell uname), Linux)
CXXFLAGS += -D__LINUX__
else ifeq ($(shell uname), Darwin)
CXXFLAGS += -D__MAC__
endif

RM:= rm -rf

INCLUDES:= -I./includes

SRCS:= main.cpp
OBJS_DIR:= objects
OBJS:= $(SRCS:%.cpp=$(OBJS_DIR)/%.o)

LIBRARY_FLAGS:= -Lserver/ -lserver -Lparser/ -lparser

NAME:= webserv

all: $(NAME)

run: re
./$(NAME)

$(NAME): parser server $(OBJS)
@$(CXX) $(CXXFLAGS) $(INCLUDES) $(OBJS) -o $@ $(LIBRARY_FLAGS)
@echo "$(GREEN)[ COMPILE ]$(RESET) $(NAME) is ready.\n"

$(OBJS_DIR)/%.o: %.cpp | $(OBJS_DIR)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
@echo "$(GREEN)[ COMPILE ]$(RESET) $<."

$(OBJS_DIR):
@mkdir -p objects

debug: CXXFLAGS += $(DEBUGFLAGS)
debug: all
@echo "$(MAGENTA)[ DEBUG ]$(RESET) $(NAME) is ready for debugging."

# @make -sC tester/ # need to add tests for parser and server
tests:
@make tests -sC parser/
@make tests -sC server/
@echo "$(BLUE)[ TEST ]$(RESET) Ready for testing."

parser:
@make -sC parser/

server:
@make -sC server/

clean:
@$(RM) $(OBJS_DIR) *.o
@make clean -sC parser/ > /dev/null 2>&1
@make clean -sC server/ > /dev/null 2>&1
@echo "$(RED)[ DELETE ]$(RESET) Removed object files."

fclean: clean
@$(RM) $(NAME)
@make fclean -sC parser/ > /dev/null 2>&1
@make fclean -sC server/ > /dev/null 2>&1
@echo "$(RED)[ DELETE ]$(RESET) Removed $(NAME) and libraries."

re: fclean all

.PHONY: clean fclean all re tests server parser debug run
File renamed without changes.
3 changes: 3 additions & 0 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main(void) {
return 0;
}
5 changes: 5 additions & 0 deletions parser/ConfigParser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "ConfigParser.hpp"

ConfigParser::ConfigParser(std::string file) {
(void) file;
}
16 changes: 16 additions & 0 deletions parser/ConfigParser.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef CONFIG_PARSER_HPP
#define CONFIG_PARSER_HPP

#include <string>

class ConfigParser {
public:
ConfigParser(std::string file);
~ConfigParser();

private:
ConfigParser();

};

#endif
72 changes: 72 additions & 0 deletions parser/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
### COLORS ####
BLUE:= \033[1;34m
GREEN:= \033[1;32m
MAGENTA:= \033[1;35m
RED:= \033[1;31m
YELLOW:= \033[1;33m
RESET:= \033[0m

CXX:= c++
CXXFLAGS:= -Wall -Werror -Wextra -std=c++98
DEBUGFLAGS:= -ggdb3 -fsanitize=address -D__DEBUG__

ifeq ($(shell uname), Linux)
CXXFLAGS += -D__LINUX__
else ifeq ($(shell uname), Darwin)
CXXFLAGS += -D__MAC__
endif

RM:= rm -rf

INCLUDES:= -I./

SRCS:= ConfigParser.cpp

# tester mains
TEST_DIR:= tester
TEST_PARSER:= $(TEST_DIR)/test_parser.cpp

OBJS_DIR:= objects
OBJS:= $(addprefix $(OBJS_DIR)/, $(SRCS:%.cpp=%.o))
OBJS_BASENAMES:= $(addprefix $(OBJS_DIR)/,$(notdir $(OBJS)))

CONFIG_FILES:= config_sample.conf

NAME:= libparser.a

all: $(NAME)

$(NAME): $(OBJS)
@ar rcs $(NAME) $(OBJS)
@echo "$(YELLOW)[ LIBRARY ]$(RESET) $(NAME) is ready.\n"

$(OBJS_DIR)/%.o: %.cpp | $(OBJS_DIR)
@$(CXX) $(CXXFLAGS) $(INCLUDES) -c $^ -o $(OBJS_DIR)/$(notdir $@)
@echo "$(GREEN)[ COMPILE ]$(RESET) $<."

$(OBJS_DIR):
@mkdir -p objects

debug: CXXFLAGS += $(DEBUGFLAGS)
debug: all
@echo "$(MAGENTA)[ DEBUG ]$(RESET) $(NAME) is ready for debugging."

test_parser: $(TEST_PARSER) debug
@$(CXX) $(CXXFLAGS) $(INCLUDES) -fsanitize=address $(TEST_PARSER) $(NAME) -o $@
@echo "$(BLUE)[ TEST ]$(RESET) Parser is now ready for testing."

tests: test_parser
@echo ""

clean:
@$(RM) $(OBJS_DIR)
@echo "$(RED)[ DELETE ]$(RESET) Removed object files."

fclean: clean
@$(RM) $(NAME)
@$(RM) test_parser
@echo "$(RED)[ DELETE ]$(RESET) Removed $(NAME) and other executables."

re: fclean all

.PHONY: clean fclean all re test_parser tests
27 changes: 27 additions & 0 deletions parser/config_sample.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
server { # php/fastcgi
listen 80;
server_name dq
access_log logs/domain1.access.log main;
root html;

location ~ \.php$ {
fastcgi_pass 127.0.0.1:1025;
}
}

server { # simple reverse-proxy
listen 80;
server_name domain2.com www.domain2.com;
access_log logs/domain2.access.log main;

# serve static files
location ~ ^/(images|javascript|js|css|flash|media|static)/ {
root /var/www/virtual/big.server.com/htdocs;
expires 30d;
}

# pass requests for dynamic content to rails/turbogears/zope, et al
location / {
proxy_pass http://127.0.0.1:8080;
}
}
3 changes: 3 additions & 0 deletions parser/tester/test_parser.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
int main(void) {
return 0;
}
Binary file removed resources/C++ Network Programming Volume 1.pdf
Binary file not shown.
Binary file removed resources/C++Networkprogramming_ppt.pdf
Binary file not shown.
Loading

0 comments on commit e075939

Please sign in to comment.