From 6c153c0f796cd32128268c82d482cebe2d342115 Mon Sep 17 00:00:00 2001 From: Vinnie Falco Date: Sat, 1 Jun 2013 14:04:36 -0700 Subject: [PATCH] Update SConstruct for beast --- SConstruct | 200 ++++++++++++++++++++++++++--------------------------- 1 file changed, 100 insertions(+), 100 deletions(-) diff --git a/SConstruct b/SConstruct index b5c26e003..61b2ec991 100644 --- a/SConstruct +++ b/SConstruct @@ -5,27 +5,28 @@ import commands import copy import glob +import os import platform import re -LevelDB = bool(1) +LevelDB = bool(1) -OSX = bool(platform.mac_ver()[0]) -FreeBSD = bool('FreeBSD' == platform.system()) -Linux = bool('Linux' == platform.system()) -Ubuntu = bool(Linux and 'Ubuntu' == platform.linux_distribution()[0]) +OSX = bool(platform.mac_ver()[0]) +FreeBSD = bool('FreeBSD' == platform.system()) +Linux = bool('Linux' == platform.system()) +Ubuntu = bool(Linux and 'Ubuntu' == platform.linux_distribution()[0]) if OSX or Ubuntu: - CTAGS = '/usr/bin/ctags' + CTAGS = '/usr/bin/ctags' else: - CTAGS = '/usr/bin/exuberant-ctags' + CTAGS = '/usr/bin/exuberant-ctags' # # scons tools # env = Environment( - tools = ['default', 'protoc'] + tools = ['default', 'protoc'] ) GCC_VERSION = re.split('\.', commands.getoutput(env['CXX'] + ' -dumpversion')) @@ -40,9 +41,9 @@ GCC_VERSION = re.split('\.', commands.getoutput(env['CXX'] + ' -dumpversion')) ctags = Builder(action = '$CTAGS $CTAGSOPTIONS -f $TARGET $SOURCES') env.Append(BUILDERS = { 'CTags' : ctags }) if OSX: - env.Replace(CTAGS = CTAGS) + env.Replace(CTAGS = CTAGS) else: - env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative') + env.Replace(CTAGS = CTAGS, CTAGSOPTIONS = '--tag-relative') # Use openssl env.ParseConfig('pkg-config --cflags --libs openssl') @@ -56,35 +57,88 @@ env.ParseConfig('pkg-config --cflags --libs openssl') # FreeBSD and Ubuntu non-mt libs do link with pthreads. if FreeBSD or Ubuntu: env.Append( - LIBS = [ - 'boost_date_time', - 'boost_filesystem', - 'boost_program_options', - 'boost_regex', - 'boost_system', - 'boost_thread', - 'boost_random', - ] + LIBS = [ + 'boost_date_time', + 'boost_filesystem', + 'boost_program_options', + 'boost_regex', + 'boost_system', + 'boost_thread', + 'boost_random', + ] ) else: env.Append( - LIBS = [ - 'boost_date_time-mt', - 'boost_filesystem-mt', - 'boost_program_options-mt', - 'boost_regex-mt', - 'boost_system-mt', - 'boost_thread-mt', - 'boost_random-mt', - ] + LIBS = [ + 'boost_date_time-mt', + 'boost_filesystem-mt', + 'boost_program_options-mt', + 'boost_regex-mt', + 'boost_system-mt', + 'boost_thread-mt', + 'boost_random-mt', + ] ) +#------------------------------------------------------------------------------- +# +# VFALCO: This is my oasis of sanity. Nothing having to do with directories, +# source files, or include paths should reside outside the boundaries. +# + +# List of includes passed to the C++ compiler. +# These are all relative to the repo dir. +# +INCLUDE_PATHS = [ + '.', + 'build/proto', + 'src/cpp/leveldb', + 'src/cpp/leveldb/port', + 'src/cpp/leveldb/include', + 'src/cpp/ripple', + 'Subtrees/beast' + ] + +COMPILED_FILES = [ + 'src/cpp/database/sqlite3.c', + 'src/cpp/leveldb_core.cpp', + 'src/cpp/websocket_core.cpp', + 'modules/ripple_basics/ripple_basics.cpp', + 'modules/ripple_client/ripple_client.cpp', + 'modules/ripple_data/ripple_data.cpp', + 'modules/ripple_db/ripple_db.cpp', + 'modules/ripple_json/ripple_json.cpp', + 'modules/ripple_ledger/ripple_ledger.cpp', + 'modules/ripple_main/ripple_main.cpp', + 'modules/ripple_mess/ripple_mess.cpp', + 'modules/ripple_net/ripple_net.cpp', + 'Subtrees/beast/modules/beast_core/beast_core.cpp' + ] + +#------------------------------------------------------------------------------- + +# Map top level source directories to their location in the outputs +# + +VariantDir('build/obj/src', 'src', duplicate=0) +VariantDir('build/obj/modules', 'modules', duplicate=0) +VariantDir('build/obj/Subtrees', 'Subtrees', duplicate=0) + +#------------------------------------------------------------------------------- + +# Add the list of includes to compiler include paths. +# +for path in INCLUDE_PATHS: + env.Append (CPPPATH = [ path ]) + +#------------------------------------------------------------------------------- + # Apparently, only linux uses -ldl if not FreeBSD: env.Append( - LIBS = [ - 'dl', # dynamic linking for linux - ] + LIBS = [ + 'dl', # dynamic linking for linux + ] ) # Apparently, pkg-config --libs protobuf on bsd fails to provide this necessary include dir. @@ -93,101 +147,47 @@ if FreeBSD: env.Append(CXXFLAGS = ['-DOS_FREEBSD']) env.Append( - LIBS = [ - 'protobuf', - 'z' - ] + LIBS = [ + 'protobuf', + 'z' + ] ) -DEBUGFLAGS = ['-g', '-DDEBUG'] -BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED'] +DEBUGFLAGS = ['-g', '-DDEBUG'] +BOOSTFLAGS = ['-DBOOST_TEST_DYN_LINK', '-DBOOST_FILESYSTEM_NO_DEPRECATED'] env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts', '-DSQLITE_THREADSAFE=1']) env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+BOOSTFLAGS+DEBUGFLAGS) env.Append(CXXFLAGS = ['-DUSE_LEVELDB']) -env.Append(CPPPATH = [ 'src/cpp/leveldb', 'src/cpp/leveldb/port', 'src/cpp/leveldb/include']) -env.Append(CPPPATH = [ 'build/proto']) -env.Append(CPPPATH = [ '.', 'src/cpp/ripple']) -env.Append(CPPPATH = [ 'Subtrees/beast' ]) - if (int(GCC_VERSION[0]) > 4 or (int(GCC_VERSION[0]) == 4 and int(GCC_VERSION[1]) >= 7)): env.Append(CXXFLAGS = ['-std=c++11']) if OSX: - env.Append(LINKFLAGS = ['-L/usr/local/opt/openssl/lib']) - env.Append(CXXFLAGS = ['-I/usr/local/opt/openssl/include']) - -RIPPLE_SRCS = [ - 'src/cpp/database/sqlite3.c', - 'src/cpp/leveldb_core.cpp', - 'src/cpp/websocket_core.cpp', - 'modules/ripple_basics/ripple_basics.cpp', - 'modules/ripple_client/ripple_client.cpp', - 'modules/ripple_data/ripple_data.cpp', - 'modules/ripple_db/ripple_db.cpp', - 'modules/ripple_json/ripple_json.cpp', - 'modules/ripple_ledger/ripple_ledger.cpp', - 'modules/ripple_main/ripple_main.cpp', - 'modules/ripple_mess/ripple_mess.cpp', - 'modules/ripple_net/ripple_net.cpp', - 'Subtrees/beast/modules/beast_core/beast_core.cpp' - ] - -# VFALCO: TODO, Remove these ugly loops and just extract the data from RIPPLE_SRCS for the call to VariantDir() -# Put objects files in their own directory. -for dir in ['.', 'ripple', 'database', 'json', 'leveldb/db', 'leveldb/port', 'leveldb/include', 'leveldb/table', 'leveldb/util', 'websocketpp']: - VariantDir('build/obj/'+dir, 'src/cpp/'+dir, duplicate=0) - -for dir in [ - 'ripple_basics', - 'ripple_client', - 'ripple_data', - 'ripple_db', - 'ripple_json', - 'ripple_ledger', - 'ripple_main', - 'ripple_mess', - 'ripple_net' - ]: - VariantDir('build/obj/'+dir, 'modules/'+dir, duplicate=0) - -for dir in [ - 'beast_core' - ]: - VariantDir('build/obj/'+dir, 'Subtrees/beast/modules/'+dir, duplicate=0) + env.Append(LINKFLAGS = ['-L/usr/local/opt/openssl/lib']) + env.Append(CXXFLAGS = ['-I/usr/local/opt/openssl/include']) PROTO_SRCS = env.Protoc([], 'src/cpp/ripple/ripple.proto', PROTOCOUTDIR='build/proto', PROTOCPYTHONOUTDIR=None) env.Clean(PROTO_SRCS, 'site_scons/site_tools/protoc.pyc') -# PROTO_SRCS = [ 'src/cpp/protobuf_core.cpp' ] -# env.Append(CXXFLAGS = ['-Ibuild/proto', '-Isrc/cpp/protobuf/src', '-Isrc/cpp/protobuf/vsprojects' ]) - -# Remove unused source files. -UNUSED_SRCS = [] - -for file in UNUSED_SRCS: - RIPPLE_SRCS.remove(file) # Only tag actual Ripple files. -TAG_SRCS = copy.copy(RIPPLE_SRCS) +TAG_SRCS = copy.copy(COMPILED_FILES) # Derive the object files from the source files. -RIPPLE_OBJS = [] +OBJECT_FILES = [] -RIPPLE_OBJS += PROTO_SRCS +OBJECT_FILES += PROTO_SRCS -for file in RIPPLE_SRCS: - # Strip src/cpp/ or modules/ - RIPPLE_OBJS.append('build/obj/' + file[8:]) +for file in COMPILED_FILES: + OBJECT_FILES.append('build/obj/' + file) # # Targets # -rippled = env.Program('build/rippled', RIPPLE_OBJS) +rippled = env.Program('build/rippled', OBJECT_FILES) -tags = env.CTags('tags', TAG_SRCS) +tags = env.CTags('tags', TAG_SRCS) Default(rippled, tags) -