changeset 137:bc291b131f6a

Irccd: make compile on VS2015, #425
author David Demelier <markand@malikania.fr>
date Thu, 19 May 2016 12:52:00 +0200
parents 01df93b56dde
children ff26bd33a45d
files cmake/IrccdSystem.cmake cmake/function/IrccdDefineExecutable.cmake irccd/main.cpp lib/irccd/fs.cpp lib/irccd/js.hpp lib/irccd/mod-irccd.cpp lib/irccd/mod-server.cpp lib/irccd/path.cpp lib/irccd/sockets.hpp
diffstat 9 files changed, 46 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/cmake/IrccdSystem.cmake	Wed May 18 22:31:24 2016 +0200
+++ b/cmake/IrccdSystem.cmake	Thu May 19 12:52:00 2016 +0200
@@ -58,8 +58,10 @@
 	message(WARNING "Unsupported ${CMAKE_CXX_COMPILER_ID}, may not build correctly.")
 endif ()
 
-if (WIN32)
+if (MINGW)
 	set(CMAKE_CXX_FLAGS "-D_WIN32_WINNT=0x0600 ${CMAKE_CXX_FLAGS}")
+elseif (MSVC)
+	set(CMAKE_CXX_FLAGS "/DWIN32_LEAN_AND_MEAN /DNOMINMAX /D_CRT_SECURE_NO_WARNINGS /EHsc")
 endif ()
 
 if (CMAKE_SIZEOF_VOID_P MATCHES "8")
--- a/cmake/function/IrccdDefineExecutable.cmake	Wed May 18 22:31:24 2016 +0200
+++ b/cmake/function/IrccdDefineExecutable.cmake	Thu May 19 12:52:00 2016 +0200
@@ -58,7 +58,16 @@
 
 	# use fakeroot for public executables.
 	if (NOT EXE_PRIVATE)
-		set_target_properties(${EXE_TARGET} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR})
+		set_target_properties(
+			${EXE_TARGET}
+			PROPERTIES
+			RUNTIME_OUTPUT_DIRECTORY ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR}
+			RUNTIME_OUTPUT_DIRECTORY_DEBUG ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR}
+			RUNTIME_OUTPUT_DIRECTORY_RELEASE ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR}
+			RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR}
+			RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${IRCCD_FAKEROOTDIR}/${WITH_BINDIR}
+		)
+
 		install(TARGETS ${EXE_TARGET} RUNTIME DESTINATION ${WITH_BINDIR})
 	endif ()
 endfunction()
--- a/irccd/main.cpp	Wed May 18 22:31:24 2016 +0200
+++ b/irccd/main.cpp	Thu May 19 12:52:00 2016 +0200
@@ -203,9 +203,8 @@
 			daemon(1, 0);
 		}
 #else
-		(void)foreground;
-		(void)options;
-		throw std::runtime_error("foreground option not supported on this platform");
+		if (options.count("-f") > 0 || options.count("--foreground") > 0 || foreground)
+			throw std::runtime_error("foreground option not supported on this platform");
 #endif
 	} catch (const std::exception &ex) {
 		log::warning() << "irccd: " << ex.what() << std::endl;
--- a/lib/irccd/fs.cpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/fs.cpp	Thu May 19 12:52:00 2016 +0200
@@ -20,6 +20,7 @@
 #include <cerrno>
 #include <cstdio>
 #include <cstring>
+#include <sstream>
 #include <stdexcept>
 
 #if defined(_WIN32)
@@ -212,7 +213,7 @@
 {
 	struct stat st;
 
-	if (stat(path.c_str(), &st) < 0)
+	if (::stat(path.c_str(), &st) < 0)
 		throw std::runtime_error(std::strerror(errno));
 
 	return st;
--- a/lib/irccd/js.hpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/js.hpp	Thu May 19 12:52:00 2016 +0200
@@ -196,6 +196,11 @@
 	 * The object.
 	 */
 	T *object{nullptr};
+
+	Pointer(T *o)
+		: object(o)
+	{
+	}
 };
 
 /**
@@ -215,6 +220,12 @@
 	 * Number of args that the function takes
 	 */
 	duk_idx_t nargs{0};
+
+	Function(duk_c_function f, duk_idx_t n)
+		: function(f)
+		, nargs(n)
+	{
+	}
 };
 
 /**
--- a/lib/irccd/mod-irccd.cpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/mod-irccd.cpp	Thu May 19 12:52:00 2016 +0200
@@ -36,7 +36,7 @@
 
 void SystemError::raise(duk::ContextPtr ctx) const
 {
-	duk::StackAssert sa(ctx, 1);
+	duk::StackAssert sa(ctx, 0);
 
 	duk::getGlobal<void>(ctx, "Irccd");
 	duk::getProperty<void>(ctx, -1, "SystemError");
--- a/lib/irccd/mod-server.cpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/mod-server.cpp	Thu May 19 12:52:00 2016 +0200
@@ -83,7 +83,7 @@
 	duk::push(ctx, duk::Object{});
 	duk::putProperty(ctx, -1, "name", server->name());
 	duk::putProperty(ctx, -1, "host", server->info().host);
-	duk::putProperty<int>(ctx, -1, "port", server->info().port);
+	duk::putProperty(ctx, -1, "port", static_cast<int>(server->info().port));
 	duk::putProperty<bool>(ctx, -1, "ssl", server->info().flags & ServerInfo::Ssl);
 	duk::putProperty<bool>(ctx, -1, "sslVerify", server->info().flags & ServerInfo::SslVerify);
 	duk::putProperty(ctx, -1, "commandChar", server->settings().command);
--- a/lib/irccd/path.cpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/path.cpp	Thu May 19 12:52:00 2016 +0200
@@ -83,7 +83,7 @@
 std::string executablePath()
 {
 	std::string result;
-	std::size_t size = PATH_MAX;
+	std::size_t size = MAX_PATH;
 	
 	result.resize(size);
 	
--- a/lib/irccd/sockets.hpp	Wed May 18 22:31:24 2016 +0200
+++ b/lib/irccd/sockets.hpp	Thu May 19 12:52:00 2016 +0200
@@ -1454,6 +1454,11 @@
 	 */
 	bool value{false};
 
+	SockBlockMode(bool v)
+		: value(v)
+	{
+	}
+
 	/**
 	 * Set the option.
 	 *
@@ -1522,6 +1527,11 @@
 	 */
 	bool value{true};
 
+	SockReuseAddress(bool v)
+		: value(v)
+	{
+	}
+
 	/**
 	 * Set the option.
 	 *
@@ -1671,6 +1681,11 @@
 	 */
 	bool value{true};
 
+	Ipv6Only(bool v)
+		: value(v)
+	{
+	}
+
 	/**
 	 * Set the option.
 	 *