Skip to content

Commit

Permalink
refactor build for tree of scons makefiles, fix out of source build, …
Browse files Browse the repository at this point in the history
…correct target handling
  • Loading branch information
Tobias Oberstein committed Mar 8, 2012
1 parent ae2dac3 commit 16a4ba9
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 52 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ examples/wsperf/wsperf

.sconsign.dblite

release/
build/
78 changes: 27 additions & 51 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,12 @@ elif env['PLATFORM'] == 'posix':
#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':
Expand All @@ -80,51 +77,30 @@ 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"]

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)
releasedir = 'build/release/'
debugdir = 'build/debug/'
builddir = releasedir

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

echo_server = SConscript('#/examples/echo_server/SConscript',
variant_dir = builddir + 'echo_server',
duplicate = 0)
20 changes: 20 additions & 0 deletions examples/echo_server/SConscript
Original file line number Diff line number Diff line change
@@ -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')
26 changes: 26 additions & 0 deletions examples/wsperf/SConscript
Original file line number Diff line number Diff line change
@@ -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')
19 changes: 19 additions & 0 deletions src/SConscript
Original file line number Diff line number Diff line change
@@ -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')

0 comments on commit 16a4ba9

Please sign in to comment.