From 1f29dc180b5a86ddf2115f97ad410e0e9b1beb4b Mon Sep 17 00:00:00 2001 From: David Date: Thu, 4 Feb 2010 21:37:00 +0000 Subject: david - Made a build-M3 file for building to windows (mingw). This one actually builds *.cpp, yay!... Although i took out Process, Plugger, and Regex... to be re-added later... also had to stubify a few more functions when compiling on WIN32. --- mingw.bld | 80 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/fastcgi.cpp | 10 ++++++- src/fifo.cpp | 14 +++++++++ src/ito.cpp | 4 +++ src/itoserver.cpp | 2 ++ src/itoserver.h | 5 +++- src/logger.cpp | 4 +++ src/multiserver.cpp | 2 ++ src/plugger.cpp | 5 ++++ src/plugger.h | 3 ++ src/protocolhttp.cpp | 6 +++- src/server.h | 6 +++- 12 files changed, 137 insertions(+), 4 deletions(-) create mode 100644 mingw.bld diff --git a/mingw.bld b/mingw.bld new file mode 100644 index 0000000..61dbeaf --- /dev/null +++ b/mingw.bld @@ -0,0 +1,80 @@ +/** + * This is the default.bld file for libbu++, it pretty much handles everything + * libbu++ related, kinda' cool, eh? It can completely replace the old build + * and actually does a better job with a number of things. + */ + +CXXFLAGS += "-ggdb -W -Wall"; + + +action "default" +{ + build: [targets("header-links"), "libbu++win.a"]; +} + + +target files("src/*.h").replace("src/", "bu/") +{ + tag "header-links"; + display "symlink"; + input OUTPUT.replace("bu/","src/"); + profile "build" + { + execute("ln -s ../${INPUT} ${OUTPUT}"); + } +} + +target "libbu++win.a" +{ + input files("src/*.cpp"); + rule "lib"; + CXXFLAGS += "-I. -Isupport/windows"; +} + +target "src/process.win_o" +{ + profile "build" + { + execute("rm -f src/process.win_o && touch src/process.win_o && echo NOT BUILDING PROCESS RIGHT NOW!!!"); + } +} +target "src/regex.win_o" +{ + profile "build" + { + execute("rm -f src/regex.win_o && touch src/regex.win_o && echo NOT BUILDING REGEX RIGHT NOW!!!"); + } +} + +function cppToWinObj() +{ + if OBJ_DIR == null then + { + return INPUT.regex("\\.cpp$", ".win_o"); + } + else + { + return OBJ_DIR + "/" + INPUT.fileName().regex("\\.cpp$", ".win_o"); + } + +} + +rule "lib" +{ + input "*.win_o"; + profile "build" + { + execute("wine C:/MinGW/bin/ar.exe cr ${OUTPUT} ${INPUT}"); + } +} + +rule "wincpp" +{ + input "*.cpp"; + output INPUT.cppToWinObj(); + //requires getMakeDeps("wine C:/MinGW/bin/g++.exe ${CXXFLAGS} -M ${INPUT}"); + profile "build" + { + execute("wine C:/MinGW/bin/g++.exe ${CXXFLAGS} -c -o ${OUTPUT} ${INPUT}", "g++"); + } +} diff --git a/src/fastcgi.cpp b/src/fastcgi.cpp index 1662fe6..ede5cac 100644 --- a/src/fastcgi.cpp +++ b/src/fastcgi.cpp @@ -7,7 +7,10 @@ #include "bu/fastcgi.h" -#include +#ifndef WIN32 + #include +#endif + #include #include @@ -37,6 +40,7 @@ Bu::FastCgi::~FastCgi() bool Bu::FastCgi::isEmbedded() { +#ifndef WIN32 struct sockaddr name; socklen_t namelen = sizeof(name); if( getpeername( STDIN_FILENO, &name, &namelen ) != 0 && @@ -54,6 +58,10 @@ bool Bu::FastCgi::isEmbedded() sio << "No socket detected, running in standalone mode" << sio.nl; return false; } +#else + #warning Bu::FastCgi::isEmbedded IS A STUB for WIN32!!!! + return false; +#endif } void Bu::FastCgi::read( Bu::Socket &s, Bu::FastCgi::Record &r ) diff --git a/src/fifo.cpp b/src/fifo.cpp index 1bbab37..eaf1705 100644 --- a/src/fifo.cpp +++ b/src/fifo.cpp @@ -12,6 +12,8 @@ #include #include +#include "win32_compatibility.h" + namespace Bu { subExceptionDef( FifoException ) } Bu::Fifo::Fifo( const Bu::FString &sName, int iFlags, mode_t mAcc ) : @@ -19,6 +21,7 @@ Bu::Fifo::Fifo( const Bu::FString &sName, int iFlags, mode_t mAcc ) : iIn( -1 ), iOut( -1 ) { +#ifndef WIN32 if( iFlags&Create ) { if( mkfifo( sName.getStr(), mAcc ) ) @@ -40,6 +43,9 @@ Bu::Fifo::Fifo( const Bu::FString &sName, int iFlags, mode_t mAcc ) : O_WRONLY ); } +#else + #warning Bu::Fifo::Fifo IS A STUB for WIN32!!!! +#endif } Bu::Fifo::~Fifo() @@ -126,15 +132,23 @@ bool Bu::Fifo::isSeekable() bool Bu::Fifo::isBlocking() { +#ifndef WIN32 return ((fcntl( iIn, F_GETFL, 0 )&O_NONBLOCK) == O_NONBLOCK); +#else + #warning Bu::Fifo::isBlocking IS A STUB for WIN32!!!! +#endif } void Bu::Fifo::setBlocking( bool bBlocking ) { +#ifndef WIN32 if( bBlocking ) fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )&(~O_NONBLOCK) ); else fcntl( iIn, F_SETFL, fcntl( iIn, F_GETFL, 0 )|O_NONBLOCK ); +#else + #warning Bu::Fifo::setBlocking IS A STUB for WIN32!!!! +#endif } void Bu::Fifo::flush() diff --git a/src/ito.cpp b/src/ito.cpp index c8b3d68..e9fb033 100644 --- a/src/ito.cpp +++ b/src/ito.cpp @@ -43,6 +43,10 @@ bool Bu::Ito::join() void Bu::Ito::yield() { +#ifndef WIN32 pthread_yield(); +#else + #warning Bu::Ito::yield IS A STUB for WIN32!!!! +#endif } diff --git a/src/itoserver.cpp b/src/itoserver.cpp index 83d2e9f..cfd5c2f 100644 --- a/src/itoserver.cpp +++ b/src/itoserver.cpp @@ -5,6 +5,8 @@ * terms of the license contained in the file LICENSE. */ +#include "win32_compatibility.h" + #include "bu/itoserver.h" #include #include "bu/serversocket.h" diff --git a/src/itoserver.h b/src/itoserver.h index bcdd1d1..4bbd6bf 100644 --- a/src/itoserver.h +++ b/src/itoserver.h @@ -9,7 +9,10 @@ #define BU_ITO_SERVER_H #include -#include + +#ifndef WIN32 + #include +#endif #include "bu/fstring.h" #include "bu/list.h" diff --git a/src/logger.cpp b/src/logger.cpp index e3de2fb..b8f9ca3 100644 --- a/src/logger.cpp +++ b/src/logger.cpp @@ -23,6 +23,7 @@ Bu::Logger::~Logger() void Bu::Logger::log( uint32_t nLevel, const char *sFile, const char *sFunction, int nLine, const char *sFormat, ...) { +#ifndef WIN32 if( (nLevel&nLevelMask) == 0 ) return; @@ -63,6 +64,9 @@ void Bu::Logger::log( uint32_t nLevel, const char *sFile, const char *sFunction, write( fileno(stdout), line, strlen(line) ); free( text ); free( line ); +#else + #warning Bu::Logger::log IS A STUB for WIN32!!!! +#endif } void Bu::Logger::setFormat( const Bu::FString &str ) diff --git a/src/multiserver.cpp b/src/multiserver.cpp index 73c794c..b049b4e 100644 --- a/src/multiserver.cpp +++ b/src/multiserver.cpp @@ -5,6 +5,8 @@ * terms of the license contained in the file LICENSE. */ +#include "win32_compatibility.h" + #include "bu/multiserver.h" #include "bu/protocol.h" #include "bu/client.h" diff --git a/src/plugger.cpp b/src/plugger.cpp index 8a1ed47..ef74da1 100644 --- a/src/plugger.cpp +++ b/src/plugger.cpp @@ -7,4 +7,9 @@ #include "bu/plugger.h" +#ifndef WIN32 + namespace Bu { subExceptionDef( PluginException ) } + +#endif + diff --git a/src/plugger.h b/src/plugger.h index 48d778d..60f1967 100644 --- a/src/plugger.h +++ b/src/plugger.h @@ -8,6 +8,7 @@ #ifndef BU_PLUGGER_H #define BU_PLUGGER_H +#ifndef WIN32 //yeah, this one is going to take some work... #include "bu/hash.h" #include "bu/list.h" @@ -212,4 +213,6 @@ namespace Bu }; } +#endif //#ifndef WIN32 //yeah, this one is going to take some work... + #endif diff --git a/src/protocolhttp.cpp b/src/protocolhttp.cpp index 534cb02..0c45ea7 100644 --- a/src/protocolhttp.cpp +++ b/src/protocolhttp.cpp @@ -6,7 +6,11 @@ */ #include -#include + +#ifndef WIN32 + #include +#endif + #include #include #include "bu/protocolhttp.h" diff --git a/src/server.h b/src/server.h index 1e317a4..a618a8d 100644 --- a/src/server.h +++ b/src/server.h @@ -9,7 +9,10 @@ #define BU_SERVER_H #include -#include + +#ifndef WIN32 + #include +#endif #include "bu/fstring.h" #include "bu/list.h" @@ -17,6 +20,7 @@ #include "bu/clientlink.h" #include "bu/clientlinkfactory.h" #include "bu/hash.h" +#include "bu/win32_compatibility.h" namespace Bu { -- cgit v1.2.3