-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
122 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
database | ||
build | ||
out | ||
out.exe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,56 @@ | ||
OBJS = $(wildcard *.cpp) | ||
SRC_FILES = $(wildcard src/*.cpp) | ||
OBJ_FILES = $(SRC_FILES:src/%.cpp=build/%.o) | ||
DEP_FILES = $(OBJ_FILES:.o=.d) | ||
|
||
ALLOBJS = $(OBJS) | ||
TARGET = out | ||
|
||
COMPILER_FLAGS = -Wall -std=c++17 -O2 | ||
OPT_REL = -O2 | ||
LD_REL = -s | ||
OPT_DBG = -Og -g | ||
|
||
LIBS = -I ./ -I ./lib/json/include/ -I ./lib/uWebSockets/src/ -L ./lib/uWebSockets/ -s -static -luWS -lssl -lz -lcrypto | ||
CPPFLAGS += -std=c++11 -Wall -Wextra -Wno-unknown-pragmas -Wno-unused-parameter | ||
CPPFLAGS += -MMD -MP | ||
|
||
UWS = ./lib/uWebSockets | ||
JSON = ./lib/json | ||
LIB_FILES = $(UWS)/libuWS.a | ||
|
||
CPPFLAGS += -I ./src/ | ||
CPPFLAGS += -I $(UWS)/src/ | ||
CPPFLAGS += -I $(JSON)/include/ | ||
LDFLAGS += -L $(UWS)/ | ||
|
||
LDLIBS += -lssl -lz -lcrypto | ||
|
||
ifeq ($(OS),Windows_NT) | ||
LIBS += -luv -lstdc++ -Wl,--whole-archive -lpthread -Wl,-Bdynamic,--no-whole-archive -lWs2_32 -lwsock32 -lGdi32 -lpsapi -liphlpapi -luserenv | ||
LDLIBS += -luv -lWs2_32 -lpsapi -liphlpapi -luserenv | ||
endif | ||
|
||
TARGET = out | ||
.PHONY: all g clean clean-all | ||
|
||
all: CPPFLAGS += $(OPT_REL) | ||
all: LDFLAGS += $(LD_REL) | ||
all: $(TARGET) | ||
|
||
g: CPPFLAGS += $(OPT_DBG) | ||
g: LDFLAGS += $(LD_DBG) | ||
g: $(TARGET) | ||
|
||
$(TARGET): $(OBJ_FILES) $(LIB_FILES) | ||
$(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) | ||
|
||
build/%.o: src/%.cpp | ||
$(CXX) $(CPPFLAGS) -c -o $@ $< | ||
|
||
|
||
$(UWS)/libuWS.a: | ||
$(MAKE) -C $(UWS) -f ../uWebSockets.mk | ||
|
||
all: uWS $(ALLOBJS) | ||
$(CXX) $(ALLOBJS) $(COMPILER_FLAGS) $(LIBS) -o $(TARGET) | ||
|
||
vanilla: uWS $(ALLOBJS) | ||
$(CXX) $(ALLOBJS) $(COMPILER_FLAGS) -DVANILLA_SERVER $(LIBS) -o $(TARGET) | ||
clean: | ||
- $(RM) $(TARGET) $(OBJ_FILES) $(DEP_FILES) | ||
|
||
g: uWS $(ALLOBJS) | ||
$(CXX) $(ALLOBJS) -Wall -std=gnu++0x -Og -g $(LIBS) -o $(TARGET) | ||
clean-all: clean | ||
$(MAKE) -C $(UWS) -f ../uWebSockets.mk clean | ||
|
||
uWS: | ||
$(MAKE) -C lib/uWebSockets -f ../uWebSockets.mk | ||
-include $(DEP_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
diff --git a/src/Networking.h b/src/Networking.h | ||
index e26888c..7f55618 100644 | ||
--- a/src/Networking.h | ||
+++ b/src/Networking.h | ||
@@ -23,7 +23,9 @@ | ||
#endif | ||
|
||
#ifdef _WIN32 | ||
-#define NOMINMAX | ||
+#ifndef NOMINMAX | ||
+ #define NOMINMAX | ||
+#endif | ||
#include <WinSock2.h> | ||
#include <Ws2tcpip.h> | ||
#pragma comment(lib, "ws2_32.lib") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,24 @@ | ||
CPPFILES = $(wildcard src/*.cpp) | ||
OBJFILES = $(CPPFILES:src/%.cpp=%.o) | ||
INCLUDES = -I src -lssl -lz -lcrypto | ||
|
||
ifeq ($(OS),Windows_NT) | ||
INCLUDES += -luv -lWs2_32 -lwsock32 -lGdi32 -lpsapi -liphlpapi -luserenv | ||
endif | ||
|
||
LIB = libuWS.a | ||
|
||
CPP_STATIC := -std=c++11 -O3 $(INCLUDES) -c $(CPPFILES) | ||
|
||
$(LIB): | ||
$(CXX) $(CPPFLAGS) $(CFLAGS) $(CPP_STATIC) -s | ||
ar rcs $(LIB) $(OBJFILES) | ||
rm -f $(OBJFILES) | ||
|
||
clean: | ||
rm -f $(LIB) | ||
rm -f $(OBJFILES) | ||
SRC_FILES = $(wildcard src/*.cpp) | ||
OBJ_FILES = $(SRC_FILES:.cpp=.o) | ||
DEP_FILES = $(OBJ_FILES:.o=.d) | ||
|
||
CPPFLAGS += -std=c++11 -O3 | ||
CPPFLAGS += -I ./src/ | ||
CPPFLAGS += -MMD -MP | ||
|
||
TARGET = libuWS.a | ||
|
||
.PHONY: all clean | ||
|
||
all: $(TARGET) | ||
|
||
$(TARGET): $(OBJ_FILES) | ||
$(AR) rcs $@ $^ | ||
|
||
src/%.o: src/%.cpp | ||
$(CXX) $(CPPFLAGS) -c -o $@ $< | ||
|
||
clean: | ||
- $(RM) $(TARGET) $(OBJ_FILES) $(DEP_FILES) | ||
|
||
-include $(DEP_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include "crossfuncs.hpp" | ||
|
||
#ifndef __WIN32 | ||
#include <sys/types.h> | ||
#include <sys/stat.h> | ||
#else | ||
#include <windows.h> | ||
#endif | ||
|
||
bool makedir(const std::string & dir) { | ||
#ifndef __WIN32 | ||
return mkdir(dir.c_str(), 0755) == 0; | ||
#else | ||
/* conversion from windows bool to c++ bool necessary? */ | ||
return CreateDirectory(dir.c_str(), nullptr) == TRUE; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#pragma once | ||
#include <string> | ||
|
||
bool makedir(const std::string &); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters