-
Notifications
You must be signed in to change notification settings - Fork 9
/
SConstruct
144 lines (114 loc) · 4.2 KB
/
SConstruct
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# Written by Victor Grishchenko, Arno Bakker
# see LICENSE.txt for license information
#
# Requirements:
# - scons: Cross-platform build system http://www.scons.org/
# - libevent2: Event driven network I/O http://www.libevent.org/
# * Install in \build\libevent-2.0.14-stable
# For debugging:
# - googletest: Google C++ Test Framework http://code.google.com/p/googletest/
# * Install in \build\gtest-1.4.0
#
import os
import re
import sys
DEBUG = True
TestDir='tests'
target = 'swift'
source = [ 'bin.cpp', 'binmap.cpp', 'sha1.cpp','hashtree.cpp',
'transfer.cpp', 'channel.cpp', 'sendrecv.cpp', 'send_control.cpp',
'compat.cpp','avgspeed.cpp', 'avail.cpp', 'cmdgw.cpp',
'storage.cpp', 'zerostate.cpp', 'zerohashtree.cpp']
# cmdgw.cpp now in there for SOCKTUNNEL
env = Environment()
if sys.platform == "win32":
libevent2path = '\\build\\libevent-2.0.19-stable'
#libevent2path = '\\build\\ttuki\\libevent-2.0.15-arno-http'
# "MSVC works out of the box". Sure.
# Make sure scons finds cl.exe, etc.
env.Append ( ENV = { 'PATH' : os.environ['PATH'] } )
# Make sure scons finds std MSVC include files
if not 'INCLUDE' in os.environ:
print "swift: Please run scons in a Visual Studio Command Prompt"
sys.exit(-1)
include = os.environ['INCLUDE']
include += libevent2path+'\\include;'
include += libevent2path+'\\WIN32-Code;'
if DEBUG:
include += '\\build\\gtest-1.4.0\\include;'
env.Append ( ENV = { 'INCLUDE' : include } )
if 'CXXPATH' in os.environ:
cxxpath = os.environ['CXXPATH']
else:
cxxpath = ""
cxxpath += include
if DEBUG:
env.Append(CXXFLAGS="/Zi /MTd")
env.Append(LINKFLAGS="/DEBUG")
else:
env.Append(CXXFLAGS="/DNDEBUG") # disable asserts
env.Append(CXXPATH=cxxpath)
env.Append(CPPPATH=cxxpath)
# getopt for win32
source += ['getopt.c','getopt_long.c']
# Set libs to link to
# Advapi32.lib for CryptGenRandom in evutil_rand.obj
libs = ['ws2_32','libevent','Advapi32']
if DEBUG:
libs += ['gtestd']
# Update lib search path
libpath = os.environ['LIBPATH']
libpath += libevent2path+';'
if DEBUG:
libpath += '\\build\\gtest-1.4.0\\msvc\\gtest\\Debug;'
# Somehow linker can't find uuid.lib
libpath += 'C:\\Program Files\\Microsoft SDKs\\Windows\\v6.0A\\Lib;'
# TODO: Make the swift.exe a Windows program not a Console program
if not DEBUG:
env.Append(LINKFLAGS="/SUBSYSTEM:WINDOWS")
APPSOURCE=['swift.cpp','httpgw.cpp','statsgw.cpp','getopt.c','getopt_long.c']
else:
libevent2path = '/arno/pkgs/libevent-2.0.15-arno-http'
# Enable the user defining external includes
if 'CPPPATH' in os.environ:
cpppath = os.environ['CPPPATH']
else:
cpppath = ""
print "To use external libs, set CPPPATH environment variable to list of colon-separated include dirs"
cpppath += libevent2path+'/include:'
env.Append(CPPPATH=".:"+cpppath)
#env.Append(LINKFLAGS="--static")
#if DEBUG:
# env.Append(CXXFLAGS="-g")
# Large-file support always
env.Append(CXXFLAGS="-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE")
# Set libs to link to
libs = ['stdc++','libevent','pthread']
if 'LIBPATH' in os.environ:
libpath = os.environ['LIBPATH']
else:
libpath = ""
print "To use external libs, set LIBPATH environment variable to list of colon-separated lib dirs"
libpath += libevent2path+'/lib:'
linkflags = '-Wl,-rpath,'+libevent2path+'/lib'
env.Append(LINKFLAGS=linkflags);
APPSOURCE=['swift.cpp','httpgw.cpp','statsgw.cpp']
if DEBUG:
env.Append(CXXFLAGS="-DDEBUG")
env.StaticLibrary (
target='libswift',
source = source,
LIBS=libs,
LIBPATH=libpath )
env.Program(
target='swift',
source=APPSOURCE,
#CPPPATH=cpppath,
LIBS=[libs,'libswift'],
LIBPATH=libpath+':.')
Export("env")
Export("libs")
Export("libpath")
Export("DEBUG")
# Arno: uncomment to build tests
#SConscript('tests/SConscript')