Browse Source

figuring out appropriate underlying library for networking

tristangurtler 1 year ago
parent
commit
d31afa1ca1
3 changed files with 37 additions and 6 deletions
  1. 3 0
      .gitmodules
  2. 1 0
      civetweb
  3. 33 6
      prsona/Makefile

+ 3 - 0
.gitmodules

@@ -2,3 +2,6 @@
 	path = BGN2
 	url = git@git-crysp.uwaterloo.ca:BGN2
 	branch = prsona
+[submodule "civetweb"]
+	path = civetweb
+	url = https://github.com/civetweb/civetweb.git

+ 1 - 0
civetweb

@@ -0,0 +1 @@
+Subproject commit 58070cd614f70d43accc172d924260fbc70eadf2

+ 33 - 6
prsona/Makefile

@@ -21,19 +21,26 @@ BGN_BIN_PATH = $(BGN_PATH)/$(BIN_PATH)
 666_OBJ_PATH = $(666_PATH)/$(OBJ_PATH)
 666_BIN_PATH = $(666_PATH)/$(BIN_PATH)
 
+MG_PATH = ../civetweb
+MG_INC_PATH = $(MG_PATH)/include
+MG_OBJ_PATH = $(MG_PATH)/out/src
+
 CPP = g++
-CPPFLAGS = -std=c++14 -Wall -I$(PRSONA_INC_PATH) -I$(BGN_INC_PATH) -I$(666_INC_PATH) -O2
-CPPTESTFLAGS = -std=c++14 -Wall -I$(PRSONA_INC_PATH) -I$(BGN_INC_PATH) -I$(666_INC_PATH) -g
+CPPFLAGS = -std=c++14 -Wall -I$(PRSONA_INC_PATH) -I$(BGN_INC_PATH) -I$(666_INC_PATH) -I$(MG_INC_PATH) -O2
+CPPTESTFLAGS = -std=c++14 -Wall -I$(PRSONA_INC_PATH) -I$(BGN_INC_PATH) -I$(666_INC_PATH) -I$(MG_INC_PATH) -g
 LDFLAGS = -lgmp -lgmpxx -lssl -lcrypto
 LDTESTFLAGS = -lgmp -lgmpxx -lssl -lcrypto -g
 
 CC = gcc
-CFLAGS = -std=c99 -O3 -fomit-frame-pointer -I$(666_INC_PATH)
+CFLAGS = -std=c99 -O3 -fomit-frame-pointer -I$(666_INC_PATH) -I$(MG_INC_PATH)
 C_LDFLAGS = -lm
 
-all: $(PRSONA_BIN_PATH) $(PRSONA_OBJ_PATH) $(BGN_OBJ_PATH) $(666_OBJ_PATH) $(PRSONA_BIN_PATH)/main
+main: $(PRSONA_BIN_PATH) $(PRSONA_OBJ_PATH) $(BGN_OBJ_PATH) $(666_OBJ_PATH) $(PRSONA_BIN_PATH)/main
 test: $(PRSONA_BIN_PATH) $(PRSONA_OBJ_PATH) $(BGN_OBJ_PATH) $(666_OBJ_PATH) $(PRSONA_BIN_PATH)/test
 
+server: $(PRSONA_BIN_PATH) $(PRSONA_OBJ_PATH) $(BGN_OBJ_PATH) $(666_OBJ_PATH) $(PRSONA_BIN_PATH)/server
+client: $(PRSONA_BIN_PATH) $(PRSONA_OBJ_PATH) $(BGN_OBJ_PATH) $(666_OBJ_PATH) $(PRSONA_BIN_PATH)/client
+
 $(PRSONA_BIN_PATH):
 	mkdir -p $@
 
@@ -46,8 +53,13 @@ $(BGN_OBJ_PATH):
 $(666_OBJ_PATH):
 	mkdir -p $@
 
+$(MG_OBJ_PATH):
+	mkdir -p $@
+
 PRSONA_FULL_SRC = $(wildcard $(PRSONA_SRC_PATH)/*.cpp)
-PRSONA_SRC = $(filter-out $(PRSONA_SRC_PATH)/main.cpp, $(PRSONA_FULL_SRC)) 
+PRSONA_NETWORK_SRC = $(wildcard $(PRSONA_SRC_PATH)/network*.cpp)
+PRSONA_SRC = $(filter-out $(PRSONA_NETWORK_SRC) $(wildcard $(PRSONA_SRC_PATH)/*ain.cpp), $(PRSONA_FULL_SRC)) 
+PRSONA_NETWORK_OBJ = $(patsubst $(PRSONA_SRC_PATH)/%.cpp, $(PRSONA_OBJ_PATH)/%.o, $(PRSONA_NETWORK_SRC))
 PRSONA_OBJ = $(patsubst $(PRSONA_SRC_PATH)/%.cpp, $(PRSONA_OBJ_PATH)/%.o, $(PRSONA_SRC))
 PRSONA_TEST_OBJ = $(patsubst $(PRSONA_SRC_PATH)/%.cpp, $(PRSONA_OBJ_PATH)/%.test.o, $(PRSONA_SRC))
 
@@ -89,15 +101,27 @@ $(BGN_OBJ_PATH)/bgn.test.a: $(666_AS_OBJ) $(666_C_OBJ) $(BGN_TEST_OBJ)
 	rm -f $@
 	ar cr $@ $^
 
+MG_OBJ += $(MG_OBJ_PATH)/civetweb.o
+MG_OBJ += $(MG_OBJ_PATH)/CiverServer.o
+
+$(MG_OBJ_PATH)/%.o: 
+	make -C ../civetweb WITH_WEBSOCKET=1 WITH_CPP=1 lib
+
 $(PRSONA_BIN_PATH)/main: $(PRSONA_OBJ_PATH)/main.o $(PRSONA_OBJ) $(BGN_OBJ_PATH)/bgn.a
 	$(CPP) $(CPPFLAGS) -no-pie -o $@ $^ $(LDFLAGS)
 
+$(PRSONA_BIN_PATH)/server: $(PRSONA_OBJ_PATH)/serverMain.o $(PRSONA_OBJ) $(PRSONA_NETWORK_OBJ) $(MG_OBJ) $(BGN_OBJ_PATH)/bgn.a
+	$(CPP) $(CPPFLAGS) -no-pie -o $@ $^ $(LDFLAGS)
+
+$(PRSONA_BIN_PATH)/client: $(PRSONA_OBJ_PATH)/clientMain.o $(PRSONA_OBJ) $(PRSONA_NETWORK_OBJ) $(MG_OBJ) $(BGN_OBJ_PATH)/bgn.a
+	$(CPP) $(CPPFLAGS) -no-pie -o $@ $^ $(LDFLAGS)
+
 $(PRSONA_BIN_PATH)/test: $(PRSONA_OBJ_PATH)/main.test.o $(PRSONA_TEST_OBJ) $(BGN_OBJ_PATH)/bgn.test.a
 	$(CPP) $(CPPTESTFLAGS) -no-pie -o $@ $^ $(LDTESTFLAGS)
 
 .PHONY: clean
 
-clean: prsona_clean bgn_clean 666_clean 
+clean: prsona_clean bgn_clean 666_clean mg_clean
 
 pclean: prsona_clean
 
@@ -110,3 +134,6 @@ bgn_clean:
 
 666_clean:
 	-rm $(666_OBJ_PATH)/*
+
+mg_clean: 
+	-rm $(MG_OBJ_PATH)/*