Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 229 lines (184 sloc) 7.343 kb
de72cdc7 » erh
2009-08-21 scons
1 # -*- mode: python; -*-
2
0ec0ae99 » banker
2012-03-31 RELEASE v0.5
3 VERSION = "0.5"
5e282b7a » RedBeard0531
2009-11-11 support testing on remote server
4
5 # --- options ----
6 AddOption('--test-server',
7 dest='test_server',
8 default='127.0.0.1',
9 type='string',
10 nargs=1,
11 action='store',
12 help='IP address of server to use for testing')
13
ccd573b6 » banker
2011-04-14 Define --seed-start-port for replica set test
14 AddOption('--seed-start-port',
15 dest='seed_start_port',
16 default=30000,
17 type='int',
18 nargs=1,
19 action='store',
20 help='IP address of server to use for testing')
21
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
22 AddOption('--c99',
23 dest='use_c99',
24 default=False,
25 action='store_true',
26 help='Compile with c99 (recommended for gcc)')
27
560dd92f » Nican
2011-11-08 Add option to compile in 32 bit mode.
28 AddOption('--m32',
29 dest='use_m32',
30 default=False,
31 action='store_true',
32 help='Compile with m32 (recommended, actually required, for 32 bit applications on 64 bit machines)')
33
0b3f46fe » gerald-lindsly
2012-03-05 Minor tweaks for driver sync
34 AddOption('--addrinfo',
35 dest='use_addrinfo',
36 default=False,
37 action='store_true',
38 help='Compile with addrinfo to make use of internet address info when connecting')
39
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
40 AddOption('--d',
41 dest='optimize',
42 default=True,
43 action='store_false',
44 help='disable optimizations')
45
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
46 AddOption('--use-platform',
47 dest='compile_platform',
48 default='GENERIC',
49 type='string',
50 nargs=1,
51 action='store',
52 help='Compile for a specific platform to take advantage '
53 ' of particular system features. For the moment, this include timeouts only.'
54 ' Current options include LINUX, '
55 ' GENERIC, and CUSTOM. If you specific CUSTOM, you must place a'
56 ' system-specific implementation of net.h and net.c in src/platform/custom/')
57
23d333d7 » banker
2011-07-29 Doc updates.
58 import os, sys
a0f63d0f » joshrotenberg
2011-04-22 add doc building to SConstruct and basic docs.py
59
0b3f46fe » gerald-lindsly
2012-03-05 Minor tweaks for driver sync
60 if GetOption('use_m32'):
61 msvs_arch = "x86"
62 else:
63 msvs_arch = "amd64"
64 print msvs_arch
65 env = Environment(ENV=os.environ, MSVS_ARCH=msvs_arch, TARGET_ARCH=msvs_arch)
de72cdc7 » erh
2009-08-21 scons
66
a0f63d0f » joshrotenberg
2011-04-22 add doc building to SConstruct and basic docs.py
67 # ---- Docs ----
68 def build_docs(env, target, source):
23d333d7 » banker
2011-07-29 Doc updates.
69 buildscript_path = os.path.join(os.path.abspath("docs"))
70 sys.path.insert(0, buildscript_path)
71 import buildscripts
a0f63d0f » joshrotenberg
2011-04-22 add doc building to SConstruct and basic docs.py
72 from buildscripts import docs
73 docs.main()
74
75 env.Alias("docs", [], [build_docs])
76 env.AlwaysBuild("docs")
77
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
78 # ---- Platforms ----
79 PLATFORM_TEST_DIR = None
80 if "LINUX" == GetOption('compile_platform'):
541bc862 » z00b
2011-12-10 Build with getaddrinfo by default on linux
81 env.Append( CPPFLAGS=" -D_MONGO_USE_LINUX_SYSTEM -D_POSIX_SOURCE" )
b585e350 » banker
2012-03-20 Move platform files to top level. Either POSIX or default.
82 NET_LIB = "src/env_posix.c"
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
83 PLATFORM_TEST_DIR = "test/platform/linux/"
84 PLATFORM_TESTS = [ "timeouts" ]
85 elif "CUSTOM" == GetOption('compile_platform'):
86 env.Append( CPPFLAGS=" -D_MONGO_USE_CUSTOM_SYSTEM" )
b585e350 » banker
2012-03-20 Move platform files to top level. Either POSIX or default.
87 NET_LIB = "src/env_default.c"
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
88 else:
b585e350 » banker
2012-03-20 Move platform files to top level. Either POSIX or default.
89 NET_LIB = "src/env_default.c"
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
90
91 # ---- Libraries ----
7b0a0aa3 » banker
2012-03-28 Fix OSX compile.
92
93
0827f40a » RedBeard0531
2010-02-04 Everything now builds on windows CDRIVER-9
94 if os.sys.platform in ["darwin", "linux2"]:
a806ff4c » Paul Melnikow
2012-04-04 Use __APPLE__ instead of MONGO_OSX_ for compatibility with Xcode and …
95 env.Append( CPPFLAGS=" -pedantic -Wall -ggdb -DMONGO_HAVE_STDINT" )
43b65ea2 » erh
2009-10-05 checkpoint for bson - some json -> bson tests
96 env.Append( CPPPATH=["/opt/local/include/"] )
97 env.Append( LIBPATH=["/opt/local/lib/"] )
32121ad4 » RedBeard0531
2010-01-25 Don't use -ansi or -std=c99 with c++ code
98
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
99 if GetOption('use_c99'):
32121ad4 » RedBeard0531
2010-01-25 Don't use -ansi or -std=c99 with c++ code
100 env.Append( CFLAGS=" -std=c99 " )
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
101 env.Append( CXXDEFINES="MONGO_HAVE_STDINT" )
32121ad4 » RedBeard0531
2010-01-25 Don't use -ansi or -std=c99 with c++ code
102 else:
103 env.Append( CFLAGS=" -ansi " )
104
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
105 if GetOption('optimize'):
106 env.Append( CPPFLAGS=" -O3 " )
107 # -O3 benchmarks *significantly* faster than -O2 when disabling networking
0827f40a » RedBeard0531
2010-02-04 Everything now builds on windows CDRIVER-9
108 elif 'win32' == os.sys.platform:
109 env.Append( LIBS='ws2_32' )
b08b5f18 » banker
2011-04-05 CDRIVER-21 use getaddrinfo for replica sets; test fixes
110
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
111 #we shouldn't need these options in c99 mode
112 if not GetOption('use_c99'):
113 conf = Configure(env)
114
115 if not conf.CheckType('int64_t'):
116 if conf.CheckType('int64_t', '#include <stdint.h>\n'):
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
117 conf.env.Append( CPPDEFINES="MONGO_HAVE_STDINT" )
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
118 elif conf.CheckType('int64_t', '#include <unistd.h>\n'):
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
119 conf.env.Append( CPPDEFINES="MONGO_HAVE_UNISTD" )
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
120 elif conf.CheckType('__int64'):
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
121 conf.env.Append( CPPDEFINES="MONGO_USE__INT64" )
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
122 elif conf.CheckType('long long int'):
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
123 conf.env.Append( CPPDEFINES="MONGO_USE_LONG_LONG_INT" )
0e16c824 » RedBeard0531
2009-11-16 add --c99 option for scons
124 else:
125 print "*** what is your 64 bit int type? ****"
126 Exit(1)
127
128 env = conf.Finish()
b1058ca0 » RedBeard0531
2009-11-12 better scons configs
129
0827f40a » RedBeard0531
2010-02-04 Everything now builds on windows CDRIVER-9
130 have_libjson = False
131 conf = Configure(env)
132 if conf.CheckLib('json'):
133 have_libjson = True
134 env = conf.Finish()
135
560dd92f » Nican
2011-11-08 Add option to compile in 32 bit mode.
136 if GetOption('use_m32'):
0b3f46fe » gerald-lindsly
2012-03-05 Minor tweaks for driver sync
137 if 'win32' != os.sys.platform:
138 env.Append( CPPFLAGS=" -m32" )
139 env.Append( SHLINKFLAGS=" -m32" )
560dd92f » Nican
2011-11-08 Add option to compile in 32 bit mode.
140
0b3f46fe » gerald-lindsly
2012-03-05 Minor tweaks for driver sync
141 if GetOption('use_addrinfo'):
142 env.Append( CPPFLAGS=" -D_MONGO_USE_GETADDRINFO" )
560dd92f » Nican
2011-11-08 Add option to compile in 32 bit mode.
143
71f302c7 » RedBeard0531
2009-11-09 move endian detection to scons
144 if sys.byteorder == 'big':
58e403eb » RedBeard0531
2010-02-04 make the core libs build under windows CDRIVER-9
145 env.Append( CPPDEFINES="MONGO_BIG_ENDIAN" )
71f302c7 » RedBeard0531
2009-11-09 move endian detection to scons
146
de72cdc7 » erh
2009-08-21 scons
147 env.Append( CPPPATH=["src/"] )
148
0b3f46fe » gerald-lindsly
2012-03-05 Minor tweaks for driver sync
149 env.Append( CPPFLAGS=" -DMONGO_DLL_BUILD" )
24905760 » RedBeard0531
2009-11-24 Move md5 from test/ to src/ and add mongo_ prefixes
150 coreFiles = ["src/md5.c" ]
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
151 mFiles = [ "src/mongo.c", NET_LIB, "src/gridfs.c"]
24e9c5d9 » banker
2011-05-19 CDRIVER-49 CDRIVER-60 CDRIVER-17 Check field names, utf8, and start o…
152 bFiles = [ "src/bson.c", "src/numbers.c", "src/encoding.c"]
31adf5c9 » Chris Lundquist
2012-02-28 minor: add install and uninstall targets to SCons
153
154 mHeaders = ["src/mongo.h"]
155 bHeaders = ["src/bson.h"]
156 headers = mHeaders + bHeaders
157
34560e3e » kreuter
2010-03-02 Add support for building a shared library.
158 mLibFiles = coreFiles + mFiles + bFiles
159 bLibFiles = coreFiles + bFiles
31adf5c9 » Chris Lundquist
2012-02-28 minor: add install and uninstall targets to SCons
160
34560e3e » kreuter
2010-03-02 Add support for building a shared library.
161 m = env.Library( "mongoc" , mLibFiles )
162 b = env.Library( "bson" , bLibFiles )
f3fb0f2a » erh
2009-10-05 build bson and mongoc library independantly
163 env.Default( env.Alias( "lib" , [ m[0] , b[0] ] ) )
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
164
d6a6c56f » z00b
2011-08-09 assign 'soname' in separate environments for libbson and libmongoc
165 # build the objects explicitly so that shared targets use the same
166 # environment (otherwise scons complains)
167 mSharedObjs = env.SharedObject(mLibFiles)
168 bSharedObjs = env.SharedObject(bLibFiles)
169
170 bsonEnv = env.Clone()
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
171 if os.sys.platform == "linux2":
d6a6c56f » z00b
2011-08-09 assign 'soname' in separate environments for libbson and libmongoc
172 env.Append( SHLINKFLAGS = "-shared -Wl,-soname,libmongoc.so." + VERSION )
173 bsonEnv.Append( SHLINKFLAGS = "-shared -Wl,-soname,libbson.so." + VERSION )
174
175 dynm = env.SharedLibrary( "mongoc" , mSharedObjs )
176 dynb = bsonEnv.SharedLibrary( "bson" , bSharedObjs )
31adf5c9 » Chris Lundquist
2012-02-28 minor: add install and uninstall targets to SCons
177 # ---- Install ----
178 prefix = "/usr/local"
179
180 env.Alias("install", env.Install(os.path.join(prefix, "lib"), [dynm[0] , dynb[0] ]))
181 env.Alias("install", env.Install(os.path.join(prefix, "include"), headers))
182
183 env.Command("uninstall", None, Delete(FindInstalledFiles()))
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
184
34560e3e » kreuter
2010-03-02 Add support for building a shared library.
185 env.Default( env.Alias( "sharedlib" , [ dynm[0] , dynb[0] ] ) )
43b65ea2 » erh
2009-10-05 checkpoint for bson - some json -> bson tests
186
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
187 # ---- Benchmarking ----
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
188 benchmarkEnv = env.Clone()
ccd573b6 » banker
2011-04-14 Define --seed-start-port for replica set test
189 benchmarkEnv.Append( CPPDEFINES=[('TEST_SERVER', r'\"%s\"'%GetOption('test_server')),
190 ('SEED_START_PORT', r'%d'%GetOption('seed_start_port'))] )
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
191 benchmarkEnv.Append( LIBS=[m, b] )
192 benchmarkEnv.Prepend( LIBPATH=["."] )
24905760 » RedBeard0531
2009-11-24 Move md5 from test/ to src/ and add mongo_ prefixes
193 benchmarkEnv.Program( "benchmark" , [ "test/benchmark.c"] )
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
194
915c3edc » banker
2011-07-07 CDRIVER-24 Add SONAME for linux compilation.
195 # ---- Tests ----
6870e7b2 » RedBeard0531
2009-11-17 Start of benchmark script
196 testEnv = benchmarkEnv.Clone()
24905760 » RedBeard0531
2009-11-24 Move md5 from test/ to src/ and add mongo_ prefixes
197 testCoreFiles = [ ]
673f6a63 » erh
2009-10-07 hash tests now work
198
e1be4196 » banker
2012-02-13 Added replica set test Env
199 def run_tests( root, tests, env, alias ):
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
200 for name in tests:
bb9ea403 » banker
2012-03-23 minor: build fixes
201 filename = "%s/%s_test.c" % (root, name)
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
202 exe = "test_" + name
e1be4196 » banker
2012-02-13 Added replica set test Env
203 test = env.Program( exe , testCoreFiles + [filename] )
204 test_alias = env.Alias(alias, [test], test[0].abspath + ' 2> ' + os.path.devnull)
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
205 AlwaysBuild(test_alias)
206
d077b66c » banker
2011-08-03 Test for ability to copy subobjects.
207 tests = Split("sizes resize endian_swap bson bson_subobject simple update errors "
e1be4196 » banker
2012-02-13 Added replica set test Env
208 "count_delete auth gridfs validate examples helpers oid functions cursors")
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
209
210 # Run standard tests
e1be4196 » banker
2012-02-13 Added replica set test Env
211 run_tests("test", tests, testEnv, "test")
efdd3131 » banker
2011-07-14 CDRIVER-83 initial separation of code for platform-specific features.
212
213 # Run platform tests
214 if not PLATFORM_TEST_DIR is None:
b1b3fea1 » banker
2012-02-17 minor: scons fix
215 run_tests( PLATFORM_TEST_DIR, PLATFORM_TESTS, testEnv, "test" )
0827f40a » RedBeard0531
2010-02-04 Everything now builds on windows CDRIVER-9
216
217 if have_libjson:
218 tests.append('json')
219 testEnv.Append( LIBS=["json"] )
220
fe9cba1f » RedBeard0531
2009-12-03 changes to compile with C++ code. CDRIVER-2
221 # special case for cpptest
fc1deab5 » banker
2012-03-26 minor: test fix
222 test = testEnv.Program( 'test_cpp' , testCoreFiles + ['test/cpptest.cpp'] )
6c6af365 » RedBeard0531
2010-02-04 passing all tests on windows CDRIVER-9
223 test_alias = testEnv.Alias('test', [test], test[0].abspath + ' 2> '+ os.path.devnull)
fe9cba1f » RedBeard0531
2009-12-03 changes to compile with C++ code. CDRIVER-2
224 AlwaysBuild(test_alias)
e1be4196 » banker
2012-02-13 Added replica set test Env
225
226 # Run replica set test only
227 repl_testEnv = benchmarkEnv.Clone()
228 repl_tests = ["replica_set"]
229 run_tests("test", repl_tests, repl_testEnv, "repl_test")
Something went wrong with that request. Please try again.