scons updates

This commit is contained in:
Peter Thorson
2012-03-08 07:56:58 -06:00
parent f506c185a8
commit a11e66d3f5
2 changed files with 108 additions and 15 deletions

View File

@@ -7,24 +7,115 @@
#env = Environment(PREFIX = GetOption('prefix'))
env = Environment() # Initialize the environment
import os, sys
env = Environment(ENV = os.environ)
## Boost
##
## Note: You need to either set BOOSTROOT to the root of a stock Boost distribution
## or set BOOST_INCLUDES and BOOST_LIBS if Boost comes with your OS distro e.g. and
## needs BOOST_INCLUDES=/usr/include/boost and BOOST_LIBS=/usr/lib like Ubuntu.
##
if os.environ.has_key('BOOSTROOT'):
env['BOOST_INCLUDES'] = os.environ['BOOSTROOT']
env['BOOST_LIBS'] = os.path.join(os.environ['BOOSTROOT'], 'stage', 'lib')
elif os.environ.has_key('BOOST_INCLUDES') and os.environ.has_key('BOOST_LIBS'):
env['BOOST_INCLUDES'] = os.environ['BOOST_INCLUDES']
env['BOOST_LIBS'] = os.environ['BOOST_LIBS']
else:
raise SCons.Errors.UserError, "Neither BOOSTROOT, nor BOOST_INCLUDES + BOOST_LIBS was set!"
env.Append(CPPPATH = [env['BOOST_INCLUDES']])
env.Append(LIBPATH = [env['BOOST_LIBS']])
boost_linkshared = False
def boostlibs(libnames):
if env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
# http://www.boost.org/doc/libs/1_49_0/more/getting_started/windows.html#auto-linking
return []
else:
libs = []
prefix = env['SHLIBPREFIX'] if boost_linkshared else env['LIBPREFIX']
suffix = env['SHLIBSUFFIX'] if boost_linkshared else env['LIBSUFFIX']
for name in libnames:
lib = File(os.path.join(env['BOOST_LIBS'], '%sboost_%s%s' % (prefix, name, suffix)))
libs.append(lib)
return libs
if env['PLATFORM'].startswith('win'):
env.Append(CPPDEFINES = ['WIN32', 'NDEBUG', '_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'
env.VariantDir("release/", "src/");
lib_sources = ["base64/base64.cpp","md5/md5.c","messages/data.cpp","network_utilities.cpp","processors/hybi_header.cpp","sha1/sha1.cpp","uri.cpp"]
lib_path = ['/usr/lib','/usr/local/lib','#/release']
if env['PLATFORM'].startswith('win'):
lib_path = env['BOOST_LIBS']
else:
lib_path = ['/usr/lib',
'/usr/local/lib',
env['BOOST_LIBS'],
'#/release']
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)
# 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=[shared_lib,'boost_system','boost_date_time','boost_regex','boost_thread','pthread'],LIBPATH=lib_path)
lib_rt = ''
platform_libs = []
if env['PLATFORM'] == 'posix':
lib_rt = 'rt'
platform_libs = ['pthread', 'rt']
elif env['PLATFORM'].startswith('win'):
# Win/VC++ supports autolinking. nothing to do.
pass
# Echo Server
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=[shared_lib,'boost_system','boost_date_time','boost_regex','boost_thread','pthread',lib_rt,'boost_random','boost_chrono','boost_program_options'],LIBPATH=lib_path)
#### 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"]
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)
wslib = static_lib
## 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
##
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)

View File

@@ -372,6 +372,7 @@
B6E56D6F150457B8007E1707 /* wscmd.hpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.h; name = wscmd.hpp; path = examples/wsperf/wscmd.hpp; sourceTree = "<group>"; };
B6E56D7E150644A3007E1707 /* request.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = request.cpp; path = examples/wsperf/request.cpp; sourceTree = "<group>"; };
B6E56D7F150644A3007E1707 /* request.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = request.hpp; path = examples/wsperf/request.hpp; sourceTree = "<group>"; };
B6E56D821508EACA007E1707 /* SConstruct */ = {isa = PBXFileReference; lastKnownFileType = text; path = SConstruct; sourceTree = "<group>"; };
B6E7E7731505532E00394909 /* wsperf */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = wsperf; sourceTree = BUILT_PRODUCTS_DIR; };
B6E7E78A150553D000394909 /* libboost_chrono.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libboost_chrono.dylib; path = usr/local/lib/libboost_chrono.dylib; sourceTree = SDKROOT; };
B6FE8CE2144DE17F00B32547 /* readme.txt */ = {isa = PBXFileReference; lastKnownFileType = text; path = readme.txt; sourceTree = "<group>"; };
@@ -749,6 +750,7 @@
B6DF1CC51435ECE40029A1B1 /* libraries */,
B6138791145CA6F700ED9B19 /* Makefile */,
B6DE901314C4D875009A1591 /* readme.txt */,
B6E56D821508EACA007E1707 /* SConstruct */,
B64E12D014BDE132006F20F0 /* test */,
B6DF1C7F1434ABB70029A1B1 /* src */,
B6DF1C6A1434A7A30029A1B1 /* Products */,