--- /dev/null
+# Written by Victor Grishchenko, Arno Bakker \r
+# see LICENSE.txt for license information\r
+#\r
+# Requirements:\r
+# - scons: Cross-platform build system http://www.scons.org/\r
+# - libevent2: Event driven network I/O http://www.libevent.org/\r
+# * Install in \build\libevent-2.0.14-stable\r
+# For debugging:\r
+# - googletest: Google C++ Test Framework http://code.google.com/p/googletest/\r
+# * Install in \build\gtest-1.4.0\r
+#\r
+\r
+\r
+import os\r
+import re\r
+import sys\r
+\r
+DEBUG = True\r
+\r
+TestDir='tests'\r
+\r
+target = 'swift'\r
+source = [ 'bin.cpp', 'binmap.cpp','binheap.cpp', 'sha1.cpp','hashtree.cpp',\r
+ 'transfer.cpp', 'channel.cpp', 'sendrecv.cpp', 'send_control.cpp', \r
+ 'compat.cpp','avgspeed.cpp', 'availability.cpp']\r
+\r
+\r
+env = Environment()\r
+if sys.platform == "win32":\r
+ #libevent2path = '\\build\\libevent-2.0.14-stable'\r
+ libevent2path = '\\build\\ttuki\\libevent-2.0.15-arno-http'\r
+\r
+ # "MSVC works out of the box". Sure.\r
+ # Make sure scons finds cl.exe, etc.\r
+ env.Append ( ENV = { 'PATH' : os.environ['PATH'] } )\r
+\r
+ # Make sure scons finds std MSVC include files\r
+ if not 'INCLUDE' in os.environ:\r
+ print "swift: Please run scons in a Visual Studio Command Prompt"\r
+ sys.exit(-1)\r
+ \r
+ include = os.environ['INCLUDE']\r
+ include += libevent2path+'\\include;'\r
+ include += libevent2path+'\\WIN32-Code;'\r
+ if DEBUG:\r
+ include += '\\build\\gtest-1.4.0\\include;'\r
+ \r
+ env.Append ( ENV = { 'INCLUDE' : include } )\r
+ \r
+ if 'CXXPATH' in os.environ:\r
+ cxxpath = os.environ['CXXPATH']\r
+ else:\r
+ cxxpath = ""\r
+ cxxpath += include\r
+ if DEBUG:\r
+ env.Append(CXXFLAGS="/Zi /MTd")\r
+ env.Append(LINKFLAGS="/DEBUG")\r
+ env.Append(CXXPATH=cxxpath)\r
+ env.Append(CPPPATH=cxxpath)\r
+\r
+ # getopt for win32\r
+ source += ['getopt.c','getopt_long.c']\r
+ \r
+ # Set libs to link to\r
+ # Advapi32.lib for CryptGenRandom in evutil_rand.obj\r
+ libs = ['ws2_32','libevent','Advapi32'] \r
+ if DEBUG:\r
+ libs += ['gtestd']\r
+ \r
+ # Update lib search path\r
+ libpath = os.environ['LIBPATH']\r
+ libpath += libevent2path+';'\r
+ if DEBUG:\r
+ libpath += '\\build\\gtest-1.4.0\\msvc\\gtest\\Debug;'\r
+\r
+ # Somehow linker can't find uuid.lib\r
+ libpath += 'C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Lib;'\r
+ \r
+ # TODO: Make the swift.exe a Windows program not a Console program\r
+ if not DEBUG:\r
+ env.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS")\r
+ \r
+ APPSOURCE=['swift.cpp','httpgw.cpp','statsgw.cpp','cmdgw.cpp','getopt.c','getopt_long.c']\r
+ \r
+else:\r
+ libevent2path = '/arno/pkgs/libevent-2.0.15-arno-http'\r
+\r
+ # Enable the user defining external includes\r
+ if 'CPPPATH' in os.environ:\r
+ cpppath = os.environ['CPPPATH']\r
+ else:\r
+ cpppath = ""\r
+ print "To use external libs, set CPPPATH environment variable to list of colon-separated include dirs"\r
+ cpppath += libevent2path+'/include:'\r
+ env.Append(CPPPATH=".:"+cpppath)\r
+ #env.Append(LINKFLAGS="--static")\r
+\r
+ #if DEBUG:\r
+ # env.Append(CXXFLAGS="-g")\r
+\r
+ # Large-file support always\r
+ env.Append(CXXFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE")\r
+\r
+ # Set libs to link to\r
+ libs = ['stdc++','libevent','pthread']\r
+ if 'LIBPATH' in os.environ:\r
+ libpath = os.environ['LIBPATH']\r
+ else:\r
+ libpath = ""\r
+ print "To use external libs, set LIBPATH environment variable to list of colon-separated lib dirs"\r
+ libpath += libevent2path+'/lib:'\r
+\r
+ linkflags = '-Wl,-rpath,'+libevent2path+'/lib'\r
+ env.Append(LINKFLAGS=linkflags);\r
+\r
+\r
+ APPSOURCE=['swift.cpp','httpgw.cpp','statsgw.cpp','cmdgw.cpp']\r
+\r
+if DEBUG:\r
+ env.Append(CXXFLAGS="-DDEBUG")\r
+\r
+env.StaticLibrary (\r
+ target='libswift',\r
+ source = source,\r
+ LIBS=libs,\r
+ LIBPATH=libpath )\r
+\r
+env.Program(\r
+ target='swift',\r
+ source=APPSOURCE,\r
+ #CPPPATH=cpppath,\r
+ LIBS=[libs,'libswift'],\r
+ LIBPATH=libpath+':.')\r
+ \r
+Export("env")\r
+Export("libs")\r
+Export("libpath")\r
+Export("DEBUG")\r
+# Arno: uncomment to build tests\r
+SConscript('tests/SConscript')\r