Browse Source

supoort win32 console application

pull/412/head
orignal 9 years ago
parent
commit
355c7437ed
  1. 15
      DaemonWin32.cpp
  2. 8
      Makefile.mingw

15
DaemonWin32.cpp

@ -1,3 +1,4 @@
#include <thread>
#include "Config.h" #include "Config.h"
#include "Daemon.h" #include "Daemon.h"
#include "util.h" #include "util.h"
@ -6,7 +7,9 @@
#ifdef _WIN32 #ifdef _WIN32
#include "Win32/Win32Service.h" #include "Win32/Win32Service.h"
#ifdef WIN32_APP
#include "Win32/Win32App.h" #include "Win32/Win32App.h"
#endif
namespace i2p namespace i2p
{ {
@ -65,10 +68,12 @@ namespace i2p
SetConsoleCP(1251); SetConsoleCP(1251);
SetConsoleOutputCP(1251); SetConsoleOutputCP(1251);
setlocale(LC_ALL, "Russian"); setlocale(LC_ALL, "Russian");
#ifdef WIN32_APP
if (!i2p::win32::StartWin32App ()) return false; if (!i2p::win32::StartWin32App ()) return false;
// override log // override log
i2p::config::SetOption("log", std::string ("file")); i2p::config::SetOption("log", std::string ("file"));
#endif
bool ret = Daemon_Singleton::start(); bool ret = Daemon_Singleton::start();
if (ret && IsLogToFile ()) if (ret && IsLogToFile ())
{ {
@ -84,13 +89,23 @@ namespace i2p
bool DaemonWin32::stop() bool DaemonWin32::stop()
{ {
#ifdef WIN32_APP
i2p::win32::StopWin32App (); i2p::win32::StopWin32App ();
#endif
return Daemon_Singleton::stop(); return Daemon_Singleton::stop();
} }
void DaemonWin32::run () void DaemonWin32::run ()
{ {
#ifdef WIN32_APP
i2p::win32::RunWin32App (); i2p::win32::RunWin32App ();
#else
while (running)
{
std::this_thread::sleep_for (std::chrono::seconds(1));
}
#endif
} }
} }
} }

8
Makefile.mingw

@ -1,10 +1,11 @@
USE_WIN32_APP=yes
CXX = g++ CXX = g++
WINDRES = windres WINDRES = windres
CXXFLAGS = -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN CXXFLAGS = -Os -D_MT -DWIN32 -D_WINDOWS -DWIN32_LEAN_AND_MEAN
NEEDED_CXXFLAGS = -std=c++11 NEEDED_CXXFLAGS = -std=c++11
BOOST_SUFFIX = -mt BOOST_SUFFIX = -mt
INCFLAGS = -I/usr/include/ -I/usr/local/include/ INCFLAGS = -I/usr/include/ -I/usr/local/include/
LDFLAGS = -mwindows -s -Wl,-rpath,/usr/local/lib \ LDFLAGS = -Wl,-rpath,/usr/local/lib \
-L/usr/local/lib \ -L/usr/local/lib \
-L/c/dev/openssl \ -L/c/dev/openssl \
-L/c/dev/boost/lib -L/c/dev/boost/lib
@ -24,8 +25,13 @@ LDLIBS = \
-static-libgcc -static-libstdc++ \ -static-libgcc -static-libstdc++ \
-Wl,-Bstatic -lstdc++ \ -Wl,-Bstatic -lstdc++ \
-Wl,-Bstatic -lpthread -Wl,-Bstatic -lpthread
ifeq ($(USE_WIN32_APP), yes)
CXXFLAGS += -DWIN32_APP
LDFLAGS += -mwindows -s
DAEMON_RC += Win32/Resource.rc DAEMON_RC += Win32/Resource.rc
DAEMON_OBJS += $(patsubst %.rc,obj/%.o,$(DAEMON_RC)) DAEMON_OBJS += $(patsubst %.rc,obj/%.o,$(DAEMON_RC))
endif
ifeq ($(USE_AESNI),1) ifeq ($(USE_AESNI),1)
CPU_FLAGS = -maes -DAESNI CPU_FLAGS = -maes -DAESNI

Loading…
Cancel
Save