Skip to content

Commit

Permalink
build: Implemented CGI handling in common Makefile
Browse files Browse the repository at this point in the history
- implemented module.mk for CGI
- fixed compile issue caused by CGI.cpp:214
  • Loading branch information
Taanviir committed Apr 15, 2024
1 parent 859c5b7 commit 8d3c265
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 133 deletions.
111 changes: 0 additions & 111 deletions CGI/Makefile

This file was deleted.

20 changes: 0 additions & 20 deletions CGI/test_cgi.dSYM/Contents/Info.plist

This file was deleted.

Binary file removed CGI/test_cgi.dSYM/Contents/Resources/DWARF/test_cgi
Binary file not shown.
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,13 @@ TESTS_DIR:= .tests
PARSER_DIR:= $(SRCS_DIR)/parser
HTTP_DIR:= $(SRCS_DIR)/http
SERVER_DIR:= $(SRCS_DIR)/server
CGI_DIR:= $(SRCS_DIR)/CGI

### EXECUTABLE ###
NAME:= webserv

### MODULES & INCLUDES ###
MODULES:= $(PARSER_DIR) $(HTTP_DIR) $(SERVER_DIR)
MODULES:= $(PARSER_DIR) $(HTTP_DIR) $(SERVER_DIR) $(CGI_DIR)
INCLUDES:= -I./includes/ $(patsubst %,-I./%,$(MODULES))

### SOURCES ###
Expand Down Expand Up @@ -98,6 +99,12 @@ test_http:
# @$(CXX) $(CXXFLAGS) $(INCLUDES) $(DEBUGFLAGS) $(SOCKET_SRCS) $(TEST_SOCKET_SRC) -o $(TEST_SOCKET)
# @echo "$(BLUE)[ TEST ]$(RESET) SOCKET ready for testing."

# test_cgi: fclean debug
# @make -C ../sources/HTTP
# $(CXX) $(CXXFLAGS) $(DEBUGFLAGS) $(SANITIZE) $(INCLUDES) $(libhttp) $(TEST_CGI) $(NAME) -o $@
# @mv *.d $(OBJS_DIR)
# @echo "$(BLUE)[ TEST ]$(RESET) CGI is now ready for testing."

-include $(OBJS:.o=.d)

.PHONY: clean fclean all re debug run test_parser test_http test_socket
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion CGI/CGI_handler/Cgi.cpp → sources/CGI/Cgi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ void Cgi::execute(const std::string& outputFile)
res_body.append(buffer, bytesRead);
}
// Save the response to a file
std::ofstream outFile(outputFile);
std::ofstream outFile(outputFile.c_str());
if (outFile.is_open()) {
outFile << res_body;
outFile.close();
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions sources/CGI/module.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# CGI makefile

CGI_SRCS:= $(CGI_DIR)/Cgi.cpp
CGI_OBJS:= $(CGI_SRCS:$(SRCS_DIR)/%.cpp=$(OBJS_DIR)/%.o)
OBJS += $(CGI_OBJS)

# tester mains
TEST_CGI:= $(CGI_DIR)/test_cgi
TEST_CGI_SRC:= $(CGI_DIR)/$(TESTS_DIR)/test_cgi.cpp
File renamed without changes.

0 comments on commit 8d3c265

Please sign in to comment.