Merge pull request #81 from oberstet/policy-refactor2

Various build things
This commit is contained in:
Peter Thorson
2012-03-08 10:45:37 -08:00
17 changed files with 129 additions and 81 deletions

2
.gitignore vendored
View File

@@ -47,4 +47,4 @@ examples/wsperf/wsperf
.sconsign.dblite
release/
build/

View File

@@ -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)
echo_server = SConscript('#/examples/echo_server/SConscript',
variant_dir = builddir + 'echo_server',
duplicate = 0)

View File

@@ -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')

View File

@@ -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')

View File

@@ -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.
*
*/
*/

View File

@@ -316,4 +316,4 @@ typedef boost::shared_ptr<case_handler> case_handler_ptr;
} // namespace wsperf
#endif // WSPERF_CASE_HPP
#endif // WSPERF_CASE_HPP

View File

@@ -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.
*
*/
*/

View File

@@ -158,4 +158,4 @@ private:
} // namespace wsperf
#endif // WSPERF_CASE_GENERIC_HPP
#endif // WSPERF_CASE_GENERIC_HPP

View File

@@ -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.
*
*/
*/

View File

@@ -188,11 +188,4 @@ void process_requests(request_coordinator* coordinator) {
} // namespace wsperf
#endif // WSPERF_REQUEST_HPP
#endif // WSPERF_REQUEST_HPP

19
src/SConscript Normal file
View File

@@ -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')

View File

@@ -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<size_t>(m_processor->get_bytes_needed())),
boost::bind(
&type::handle_read_frame,
type::shared_from_this(),

View File

@@ -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<size_t>(
new_size, static_cast<size_t>(2*m_payload.capacity())
static_cast<size_t>(new_size), static_cast<size_t>(2*m_payload.capacity())
));
}

View File

@@ -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 <stdint.h>
#include <limits>
#include <iostream>
#include <boost/cstdint.hpp>
#include <boost/asio.hpp>
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/random.hpp>
#include <boost/random/random_device.hpp>
#include <iostream>
#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<int32_t>::min(),
std::numeric_limits<int32_t>::max())) {}
connection_ptr connect(const std::string& u);
@@ -537,4 +534,8 @@ void client<endpoint>::connection<connection_type>::log_open_result() {
} // namespace role
} // namespace websocketpp
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#endif // WEBSOCKETPP_ROLE_CLIENT_HPP

View File

@@ -650,4 +650,8 @@ void server<endpoint>::connection<connection_type>::log_open_result() {
} // namespace role
} // namespace websocketpp
#ifdef _MSC_VER
# pragma warning(pop)
#endif
#endif // WEBSOCKETPP_ROLE_SERVER_HPP

View File

@@ -317,4 +317,4 @@ uint16_t uri::get_port_from_string(const std::string& port) const {
}
return t_port;
}
}

View File

@@ -65,7 +65,7 @@
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>_WEBSOCKETPP_CPP11_FRIEND_;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(BOOSTROOT);..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<BufferSecurityCheck>false</BufferSecurityCheck>