Browse Source

Merge pull request #4 from c6burns/master

build updates
Coburn 6 years ago
parent
commit
823eab64a2

+ 2 - 1
.gitignore

@@ -4,4 +4,5 @@ build*
 *.bak
 *.bak
 **/bin
 **/bin
 **/obj
 **/obj
-.vs
+.vs
+Directory.Build.rsp

+ 1 - 3
CMakeLists.txt

@@ -31,6 +31,7 @@ set(ENET_SRCDIR "Source/Native")
 set(ENET_SRCS
 set(ENET_SRCS
 	${ENET_SRCDIR}/enet.c
 	${ENET_SRCDIR}/enet.c
 	${ENET_SRCDIR}/enet.h
 	${ENET_SRCDIR}/enet.h
+	${ENET_SRCDIR}/enet_log.h
 )
 )
 
 
 if(ENET_DEBUG)
 if(ENET_DEBUG)
@@ -39,9 +40,6 @@ endif()
 
 
 if(MSVC)
 if(MSVC)
 	set(CompilerFlags
 	set(CompilerFlags
-        CMAKE_CXX_FLAGS
-        CMAKE_CXX_FLAGS_DEBUG
-        CMAKE_CXX_FLAGS_RELEASE
         CMAKE_C_FLAGS
         CMAKE_C_FLAGS
         CMAKE_C_FLAGS_DEBUG
         CMAKE_C_FLAGS_DEBUG
         CMAKE_C_FLAGS_RELEASE
         CMAKE_C_FLAGS_RELEASE

+ 0 - 0
Directory.Build.rsp


+ 1 - 3
MSBuild/CMake/CMake.Build.targets

@@ -34,9 +34,7 @@ SOFTWARE.
 
 
     <PropertyGroup Condition="'$(OSPlatformWindows)' == 'true'">
     <PropertyGroup Condition="'$(OSPlatformWindows)' == 'true'">
         <CMakeVSArch></CMakeVSArch>
         <CMakeVSArch></CMakeVSArch>
-        <CMakeVSArch Condition="'$(Platform)' == 'x86'">-A Win32</CMakeVSArch>
-        <CMakeVSToolset></CMakeVSToolset>
-        <CMakeVSToolset Condition="'$(BuildingInsideVisualStudio)' != 'true'">-T v141</CMakeVSToolset>
+        <CMakeVSArch Condition="'$(Platform)' == 'x86'">-AWin32</CMakeVSArch>
         <CMakeGenerator>-G"Visual Studio 16 2019" $(CMakeVSArch) $(CMakeVSToolset)</CMakeGenerator>
         <CMakeGenerator>-G"Visual Studio 16 2019" $(CMakeVSArch) $(CMakeVSToolset)</CMakeGenerator>
     </PropertyGroup>
     </PropertyGroup>
     <PropertyGroup Condition="'$(OSPlatformWindows)' != 'true'">
     <PropertyGroup Condition="'$(OSPlatformWindows)' != 'true'">

+ 1 - 1
MSBuild/CMake/CMake.csproj

@@ -31,7 +31,7 @@ SOFTWARE.
     <Import Project="$(CsDir)Common\BannerTask.targets" Condition="'$(BuildingInsideVisualStudio)' != 'true'" />
     <Import Project="$(CsDir)Common\BannerTask.targets" Condition="'$(BuildingInsideVisualStudio)' != 'true'" />
 
 
     <Target Name="ConsoleBanner" BeforeTargets="Build" Condition="'$(BuildingInsideVisualStudio)' != 'true'">
     <Target Name="ConsoleBanner" BeforeTargets="Build" Condition="'$(BuildingInsideVisualStudio)' != 'true'">
-        <BannerTask TextFile="$(CsDir)Common\Banner.txt" />
+        <BannerTask TextFile="$(CsDir)Common\Banner.txt" Condition="'$(BannerSkip)' != 'true'"/>
     </Target>
     </Target>
 
 
     <Import Project="CMake.Build.targets" />
     <Import Project="CMake.Build.targets" />

+ 2 - 36
Source/Native/enet.h

@@ -25,13 +25,13 @@
 #ifndef ENET_H
 #ifndef ENET_H
 #define ENET_H
 #define ENET_H
 
 
-#include <stdarg.h>
 #include <stdbool.h>
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdint.h>
-#include <stdio.h>
 #include <stdlib.h>
 #include <stdlib.h>
 #include <time.h>
 #include <time.h>
 
 
+#include "enet_log.h"
+
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MAJOR 2
 #define ENET_VERSION_MINOR 3
 #define ENET_VERSION_MINOR 3
 #define ENET_VERSION_PATCH 0
 #define ENET_VERSION_PATCH 0
@@ -54,40 +54,6 @@
 #define ENET_SRTT_INITIAL 1.0
 #define ENET_SRTT_INITIAL 1.0
 #define ENET_SRTT_PARA_G 0.125
 #define ENET_SRTT_PARA_G 0.125
 
 
-static FILE *enet_log_fp = NULL;
-enum enet_log_type
-{
-	ENET_LOG_TYPE_TRACE,
-	ENET_LOG_TYPE_ERROR,
-};
-static const char *const enet_log_type_names[] = {
-	[ENET_LOG_TYPE_TRACE] = "TRACE",
-	[ENET_LOG_TYPE_ERROR] = "ERROR",
-};
-#if ENET_DEBUG
-	#define ENET_LOG_TRACE(...) enet_log(ENET_LOG_TYPE_TRACE, __FUNCTION__, __LINE__, __VA_ARGS__)
-	#define ENET_LOG_ERROR(...) enet_log(ENET_LOG_TYPE_ERROR, __FUNCTION__, __LINE__, __VA_ARGS__)
-#else
-	#define ENET_LOG_TRACE(...) ((void)0)
-	#define ENET_LOG_ERROR(...) ((void)0)
-#endif
-#define ENET_LOG_FILE "enet_log.txt"
-static inline void enet_log(enum enet_log_type type, const char *func, int line, const char *fmt, ...)
-{
-	if (!enet_log_fp) enet_log_fp = fopen(ENET_LOG_FILE, "a");
-	if (!enet_log_fp) return;
-	va_list args;
-	time_t tstamp = time(NULL);
-	struct tm *local_time = localtime(&tstamp);
-	char time_buf[64];
-	time_buf[strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", local_time)] = '\0';
-	fprintf(enet_log_fp, "%s [%s] [%s:%d] ", time_buf, enet_log_type_names[type], func, line);
-	va_start(args, fmt);
-	vfprintf(enet_log_fp, fmt, args);
-	va_end(args);
-	fflush(enet_log_fp);
-}
-
 /*
 /*
 =======================================================================
 =======================================================================
 
 

+ 51 - 0
Source/Native/enet_log.h

@@ -0,0 +1,51 @@
+#ifndef ENET_LOG_H
+#define ENET_LOG_H
+
+#include <stdarg.h>
+#include <stdio.h>
+
+#define ENET_LOG_FILE "enet_log.txt"
+
+static FILE *enet_log_fp = NULL;
+
+enum enet_log_type
+{
+	ENET_LOG_TYPE_TRACE,
+	ENET_LOG_TYPE_ERROR,
+};
+
+static const char *const enet_log_type_names[] = {
+	[ENET_LOG_TYPE_TRACE] = "TRACE",
+	[ENET_LOG_TYPE_ERROR] = "ERROR",
+};
+
+#if ENET_DEBUG
+#	define ENET_LOG_TRACE(...) enet_log(ENET_LOG_TYPE_TRACE, __FUNCTION__, __LINE__, __VA_ARGS__)
+#	define ENET_LOG_ERROR(...) enet_log(ENET_LOG_TYPE_ERROR, __FUNCTION__, __LINE__, __VA_ARGS__)
+#else
+#	define ENET_LOG_TRACE(...) ((void)0)
+#	define ENET_LOG_ERROR(...) ((void)0)
+#endif
+
+static inline void enet_log(enum enet_log_type type, const char *func, int line, const char *fmt, ...)
+{
+	if (!enet_log_fp) enet_log_fp = fopen(ENET_LOG_FILE, "a");
+	if (!enet_log_fp) return;
+
+	va_list args;
+	time_t tstamp = time(NULL);
+	struct tm *local_time = localtime(&tstamp);
+	char time_buf[64];
+
+	time_buf[strftime(time_buf, sizeof(time_buf), "%Y-%m-%d %H:%M:%S", local_time)] = '\0';
+	fprintf(enet_log_fp, "%s [%s] [%s:%d] ", time_buf, enet_log_type_names[type], func, line);
+
+	va_start(args, fmt);
+	vfprintf(enet_log_fp, fmt, args);
+	va_end(args);
+
+	fflush(enet_log_fp);
+}
+
+
+#endif