diff --git a/SConstruct b/SConstruct new file mode 100644 index 0000000000..953d4fd604 --- /dev/null +++ b/SConstruct @@ -0,0 +1,44 @@ +# +# Newcoin - SConstruct +# + +import glob + +env = Environment( + tools = ['default', 'protoc'] + ) + +# Use openssl +env.ParseConfig('pkg-config --cflags --libs openssl') + +env.Append(LIBS = [ + 'boost_system-mt', + 'boost_filesystem-mt', + 'boost_program_options-mt', + 'boost_thread-mt', + 'protobuf', + 'dl', # dynamic linking + 'z' + ]) + +DEBUGFLAGS = ['-g', '-DDEBUG'] + +env.Append(LINKFLAGS = ['-rdynamic', '-pthread']) +env.Append(CCFLAGS = ['-pthread', '-Wall', '-Wno-sign-compare', '-Wno-char-subscripts']) +env.Append(CXXFLAGS = ['-O0', '-pthread', '-Wno-invalid-offsetof', '-Wformat']+DEBUGFLAGS) + +DB_SRCS = glob.glob('database/*.c*') +JSON_SRCS = glob.glob('json/*.cpp') +NEWCOIN_SRCS = glob.glob('*.cpp') +PROTO_SRCS = env.Protoc([], 'newcoin.proto', PROTOCPYTHONOUTDIR=None) +UTIL_SRCS = glob.glob('util/*.cpp') + +UNUSED_SRCS = ['HttpReply.cpp', 'ValidationCollection.cpp'] + +for file in UNUSED_SRCS: + NEWCOIN_SRCS.remove(file) + +NEWCOIN_SRCS += DB_SRCS + JSON_SRCS + UTIL_SRCS + PROTO_SRCS + +env.Program('newcoind', NEWCOIN_SRCS) + diff --git a/site_scons/site_tools/protoc.py b/site_scons/site_tools/protoc.py new file mode 100644 index 0000000000..dc47634d4f --- /dev/null +++ b/site_scons/site_tools/protoc.py @@ -0,0 +1,84 @@ +#!python +""" +protoc.py: Protoc Builder for SCons + +This Builder invokes protoc to generate C++ and Python +from a .proto file. + +NOTE: Java is not currently supported. + +From: http://www.scons.org/wiki/ProtocBuilder +""" + +__author__ = "Scott Stafford" + +import SCons.Action +import SCons.Builder +import SCons.Defaults +import SCons.Node.FS +import SCons.Util + +from SCons.Script import File, Dir + +import os.path + +protocs = 'protoc' + +ProtocAction = SCons.Action.Action('$PROTOCCOM', '$PROTOCCOMSTR') +def ProtocEmitter(target, source, env): + dirOfCallingSConscript = Dir('.').srcnode() + env.Prepend(PROTOCPROTOPATH = dirOfCallingSConscript.path) + + source_with_corrected_path = [] + for src in source: + commonprefix = os.path.commonprefix([dirOfCallingSConscript.path, src.srcnode().path]) + if len(commonprefix)>0: + source_with_corrected_path.append( src.srcnode().path[len(commonprefix + os.sep):] ) + else: + source_with_corrected_path.append( src.srcnode().path ) + + source = source_with_corrected_path + + for src in source: + modulename = os.path.splitext(src)[0] + + if env['PROTOCOUTDIR']: + base = os.path.join(env['PROTOCOUTDIR'] , modulename) + target.extend( [ base + '.pb.cc', base + '.pb.h' ] ) + + if env['PROTOCPYTHONOUTDIR']: + base = os.path.join(env['PROTOCPYTHONOUTDIR'] , modulename) + target.append( base + '_pb2.py' ) + + try: + target.append(env['PROTOCFDSOUT']) + except KeyError: + pass + + #~ print "PROTOC SOURCE:", [str(s) for s in source] + #~ print "PROTOC TARGET:", [str(s) for s in target] + + return target, source + +ProtocBuilder = SCons.Builder.Builder(action = ProtocAction, + emitter = ProtocEmitter, + srcsuffix = '$PROTOCSRCSUFFIX') + +def generate(env): + """Add Builders and construction variables for protoc to an Environment.""" + try: + bld = env['BUILDERS']['Protoc'] + except KeyError: + bld = ProtocBuilder + env['BUILDERS']['Protoc'] = bld + + env['PROTOC'] = env.Detect(protocs) or 'protoc' + env['PROTOCFLAGS'] = SCons.Util.CLVar('') + env['PROTOCPROTOPATH'] = SCons.Util.CLVar('') + env['PROTOCCOM'] = '$PROTOC ${["-I%s"%x for x in PROTOCPROTOPATH]} $PROTOCFLAGS --cpp_out=$PROTOCCPPOUTFLAGS$PROTOCOUTDIR ${PROTOCPYTHONOUTDIR and ("--python_out="+PROTOCPYTHONOUTDIR) or ""} ${PROTOCFDSOUT and ("-o"+PROTOCFDSOUT) or ""} ${SOURCES}' + env['PROTOCOUTDIR'] = '${SOURCE.dir}' + env['PROTOCPYTHONOUTDIR'] = "python" + env['PROTOCSRCSUFFIX'] = '.proto' + +def exists(env): + return env.Detect(protocs)