diff --git a/.gitignore b/.gitignore index a8d338edf7..14928e0e84 100644 --- a/.gitignore +++ b/.gitignore @@ -47,4 +47,4 @@ examples/wsperf/wsperf .sconsign.dblite -release/ \ No newline at end of file +build/ \ No newline at end of file diff --git a/SConstruct b/SConstruct index e07ccbb672..1dbf72d0dc 100644 --- a/SConstruct +++ b/SConstruct @@ -44,78 +44,63 @@ def boostlibs(libnames): libs.append(lib) return libs - if env['PLATFORM'].startswith('win'): - env.Append(CPPDEFINES = ['WIN32', 'NDEBUG', '_CONSOLE', '_WEBSOCKETPP_CPP11_FRIEND_']) + env.Append(CPPDEFINES = ['WIN32', + 'NDEBUG', + 'WIN32_LEAN_AND_MEAN', + '_WIN32_WINNT=0x0600', + '_CONSOLE', + '_WEBSOCKETPP_CPP11_FRIEND_']) arch_flags = '/arch:SSE2' opt_flags = '/Ox /Oi /fp:fast' warn_flags = '/W3 /wd4996 /wd4995 /wd4355' env['CCFLAGS'] = '%s /EHsc /GR /GS- /MD /nologo %s %s' % (warn_flags, arch_flags, opt_flags) env['LINKFLAGS'] = '/INCREMENTAL:NO /MANIFEST /NOLOGO /OPT:REF /OPT:ICF /MACHINE:X86' +elif env['PLATFORM'] == 'posix': + env.Append(CPPDEFINES = ['NDEBUG']) + env.Append(CCFLAGS = ['-Wall', '-fno-strict-aliasing']) + env.Append(CCFLAGS = ['-O3', '-fomit-frame-pointer', '-march=core2']) + #env['LINKFLAGS'] = '' -env.VariantDir("release/", "src/"); - if env['PLATFORM'].startswith('win'): - lib_path = env['BOOST_LIBS'] + env['LIBPATH'] = env['BOOST_LIBS'] else: - lib_path = ['/usr/lib', - '/usr/local/lib', - env['BOOST_LIBS'], - '#/release'] + env['LIBPATH'] = ['/usr/lib', + '/usr/local/lib', + env['BOOST_LIBS']] platform_libs = [] if env['PLATFORM'] == 'posix': - platform_libs = ['pthread', 'rt'] + platform_libs = ['pthread', 'rt'] elif env['PLATFORM'].startswith('win'): # Win/VC++ supports autolinking. nothing to do. pass -#### END OF GLOBAL CONF ######################################################## -## WebSocket++ library -## -lib_sources = ["base64/base64.cpp", - "md5/md5.c", - "messages/data.cpp", - "network_utilities.cpp", - "processors/hybi_header.cpp", - "sha1/sha1.cpp", - "uri.cpp"] +releasedir = 'build/release/' +debugdir = 'build/debug/' +builddir = releasedir -static_lib = env.StaticLibrary(target = 'release/websocketpp', - source = lib_sources, - srcdir = "release") -#shared_lib=env.SharedLibrary(target = 'release/websocketpp', source = lib_sources, srcdir="release",LIBS=['boost_regex'],LIBPATH=lib_path) +Export('env') +Export('platform_libs') +Export('boostlibs') + +## END OF CONFIG !! + +## TARGETS: + +static_lib, shared_lib = SConscript('src/SConscript', + variant_dir = builddir + 'websocketpp', + duplicate = 0) wslib = static_lib +Export('wslib') -## Echo Server -## -env.VariantDir("#/release/echo_server", "examples/echo_server") -env.Program(target = "#/release/echo_server/echo_server", - srcdir = "#/release/echo_server/", - source = ["echo_server.cpp"], - LIBS = [wslib, platform_libs] + boostlibs(['system', - 'date_time', - 'regex', - 'thread']), - LIBPATH = lib_path) +wsperf = SConscript('#/examples/wsperf/SConscript', + variant_dir = builddir + 'wsperf', + duplicate = 0) -## wsperf -## -env.VariantDir("#/release/wsperf", "examples/wsperf") -env.Program(target = "#/release/wsperf/wsperf", - srcdir = "#/release/wsperf/", - source = ["wsperf.cpp", - "request.cpp", - "case.cpp", - "generic.cpp"], - LIBS = [wslib, platform_libs] + boostlibs(['system', - 'date_time', - 'regex', - 'thread', - 'random', - 'chrono', - 'program_options']), - LIBPATH = lib_path) \ No newline at end of file +echo_server = SConscript('#/examples/echo_server/SConscript', + variant_dir = builddir + 'echo_server', + duplicate = 0) diff --git a/examples/echo_server/SConscript b/examples/echo_server/SConscript new file mode 100644 index 0000000000..f65aa91ab2 --- /dev/null +++ b/examples/echo_server/SConscript @@ -0,0 +1,20 @@ +## echo_server +## + +Import('env') +Import('boostlibs') +Import('wslib') +Import('platform_libs') + +localenv = env.Clone () + +sources = ["echo_server.cpp"] + +LIBS = [wslib, platform_libs] + boostlibs(['system', + 'date_time', + 'regex', + 'thread']) + +prg = localenv.Program('echo_server', sources, LIBS = LIBS) + +Return('prg') diff --git a/examples/wsperf/SConscript b/examples/wsperf/SConscript new file mode 100644 index 0000000000..7bc172397c --- /dev/null +++ b/examples/wsperf/SConscript @@ -0,0 +1,26 @@ +## wsperf +## + +Import('env') +Import('boostlibs') +Import('wslib') +Import('platform_libs') + +localenv = env.Clone () + +sources = ["wsperf.cpp", + "request.cpp", + "case.cpp", + "generic.cpp"] + +LIBS = [wslib, platform_libs] + boostlibs(['system', + 'date_time', + 'regex', + 'thread', + 'random', + 'chrono', + 'program_options']) + +prg = localenv.Program('wsperf', sources, LIBS = LIBS) + +Return('prg') diff --git a/examples/wsperf/case.cpp b/examples/wsperf/case.cpp index 1156347606..65d401e974 100644 --- a/examples/wsperf/case.cpp +++ b/examples/wsperf/case.cpp @@ -23,4 +23,4 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - */ \ No newline at end of file + */ diff --git a/examples/wsperf/case.hpp b/examples/wsperf/case.hpp index 7b7d7c7779..4926ff74ae 100644 --- a/examples/wsperf/case.hpp +++ b/examples/wsperf/case.hpp @@ -316,4 +316,4 @@ typedef boost::shared_ptr case_handler_ptr; } // namespace wsperf -#endif // WSPERF_CASE_HPP \ No newline at end of file +#endif // WSPERF_CASE_HPP diff --git a/examples/wsperf/generic.cpp b/examples/wsperf/generic.cpp index 1156347606..65d401e974 100644 --- a/examples/wsperf/generic.cpp +++ b/examples/wsperf/generic.cpp @@ -23,4 +23,4 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - */ \ No newline at end of file + */ diff --git a/examples/wsperf/generic.hpp b/examples/wsperf/generic.hpp index 88ab45d4c1..534f3e9773 100644 --- a/examples/wsperf/generic.hpp +++ b/examples/wsperf/generic.hpp @@ -158,4 +158,4 @@ private: } // namespace wsperf -#endif // WSPERF_CASE_GENERIC_HPP \ No newline at end of file +#endif // WSPERF_CASE_GENERIC_HPP diff --git a/examples/wsperf/request.cpp b/examples/wsperf/request.cpp index 1156347606..65d401e974 100644 --- a/examples/wsperf/request.cpp +++ b/examples/wsperf/request.cpp @@ -23,4 +23,4 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - */ \ No newline at end of file + */ diff --git a/examples/wsperf/request.hpp b/examples/wsperf/request.hpp index c9c5815318..f1484cae54 100644 --- a/examples/wsperf/request.hpp +++ b/examples/wsperf/request.hpp @@ -188,11 +188,4 @@ void process_requests(request_coordinator* coordinator) { } // namespace wsperf - - - - - - - -#endif // WSPERF_REQUEST_HPP \ No newline at end of file +#endif // WSPERF_REQUEST_HPP diff --git a/src/SConscript b/src/SConscript new file mode 100644 index 0000000000..00fcfea756 --- /dev/null +++ b/src/SConscript @@ -0,0 +1,19 @@ +## websocket++ library +## + +Import('env') + +localenv = env.Clone () + +sources = ["base64/base64.cpp", + "md5/md5.c", + "messages/data.cpp", + "network_utilities.cpp", + "processors/hybi_header.cpp", + "sha1/sha1.cpp", + "uri.cpp"] + +static_lib = localenv.StaticLibrary('websocketpp', sources) +shared_lib = None # localenv.SharedLibrary('websocketpp', sources) + +Return('static_lib', 'shared_lib') diff --git a/src/connection.hpp b/src/connection.hpp index 17b3131407..e47b304af4 100644 --- a/src/connection.hpp +++ b/src/connection.hpp @@ -348,7 +348,7 @@ public: boost::asio::async_read( socket_type::get_socket(), m_buf, - boost::asio::transfer_at_least(m_processor->get_bytes_needed()), + boost::asio::transfer_at_least(static_cast(m_processor->get_bytes_needed())), boost::bind( &type::handle_read_frame, type::shared_from_this(), diff --git a/src/messages/data.cpp b/src/messages/data.cpp index 4765edc10b..4e95a2c087 100644 --- a/src/messages/data.cpp +++ b/src/messages/data.cpp @@ -58,7 +58,7 @@ uint64_t data::process_payload(std::istream& input,uint64_t size) { if (new_size > m_payload.capacity()) { m_payload.reserve(std::max( - new_size, static_cast(2*m_payload.capacity()) + static_cast(new_size), static_cast(2*m_payload.capacity()) )); } diff --git a/src/roles/client.hpp b/src/roles/client.hpp index 883a848a9d..3b9fe773a3 100644 --- a/src/roles/client.hpp +++ b/src/roles/client.hpp @@ -28,22 +28,19 @@ #ifndef WEBSOCKETPP_ROLE_CLIENT_HPP #define WEBSOCKETPP_ROLE_CLIENT_HPP -#include "../endpoint.hpp" -#include "../uri.hpp" -#include "../shared_const_buffer.hpp" - -#ifndef __STDC_LIMIT_MACROS - #define __STDC_LIMIT_MACROS -#endif -#include +#include +#include +#include #include #include #include #include #include -#include +#include "../endpoint.hpp" +#include "../uri.hpp" +#include "../shared_const_buffer.hpp" #ifdef _MSC_VER // Disable "warning C4355: 'this' : used in base member initializer list". @@ -209,8 +206,8 @@ public: client (boost::asio::io_service& m) : m_endpoint(static_cast< endpoint_type& >(*this)), m_io_service(m), - m_gen(m_rng,boost::random::uniform_int_distribution<>(INT32_MIN, - INT32_MAX)) {} + m_gen(m_rng,boost::random::uniform_int_distribution<>(std::numeric_limits::min(), + std::numeric_limits::max())) {} connection_ptr connect(const std::string& u); @@ -537,4 +534,8 @@ void client::connection::log_open_result() { } // namespace role } // namespace websocketpp +#ifdef _MSC_VER +# pragma warning(pop) +#endif + #endif // WEBSOCKETPP_ROLE_CLIENT_HPP diff --git a/src/roles/server.hpp b/src/roles/server.hpp index 56ecfc8078..822f37a7cb 100644 --- a/src/roles/server.hpp +++ b/src/roles/server.hpp @@ -650,4 +650,8 @@ void server::connection::log_open_result() { } // namespace role } // namespace websocketpp +#ifdef _MSC_VER +# pragma warning(pop) +#endif + #endif // WEBSOCKETPP_ROLE_SERVER_HPP diff --git a/src/uri.cpp b/src/uri.cpp index c1cb3151ae..b69ab6bb71 100644 --- a/src/uri.cpp +++ b/src/uri.cpp @@ -317,4 +317,4 @@ uint16_t uri::get_port_from_string(const std::string& port) const { } return t_port; -} \ No newline at end of file +} diff --git a/windows/vcpp2010/examples/wsperf/wsperf.vcxproj b/windows/vcpp2010/examples/wsperf/wsperf.vcxproj index 9886234e41..dce6ac4ef4 100644 --- a/windows/vcpp2010/examples/wsperf/wsperf.vcxproj +++ b/windows/vcpp2010/examples/wsperf/wsperf.vcxproj @@ -65,7 +65,7 @@ MaxSpeed true true - WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + _WEBSOCKETPP_CPP11_FRIEND_;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) $(BOOSTROOT);..;%(AdditionalIncludeDirectories) MultiThreaded false