forked from Tokutek/mongo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
SConscript.buildinfo
73 lines (60 loc) · 2.46 KB
/
SConscript.buildinfo
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
# -*- mode: python; -*-
# This SConscript describes construction of buildinfo.cpp, which is independent of the
# build variant's target.
import os
import sys
import buildscripts.utils
Import('env windows usev8 usesm')
def getSysInfo():
if windows:
return "windows " + str( sys.getwindowsversion() )
else:
return " ".join( os.uname() )
buildinfo_filename = '#build/buildinfo.cpp'
buildinfo_template = '''
#include <string>
#include <boost/version.hpp>
#include "mongo/util/version.h"
namespace mongo {
const char * gitVersion() { return "%(git_version)s"; }
const char *tokukvVersion() { return "%(tokukv_version)s"; }
const char * compiledJSEngine() { return "%(js_engine)s"; }
const char * loaderFlags() { return "%(loader_flags)s"; }
const char * compilerFlags() { return "%(compiler_flags)s"; }
std::string sysInfo() { return "%(sys_info)s BOOST_LIB_VERSION=" BOOST_LIB_VERSION ; }
} // namespace mongo
'''
def generate_buildinfo(env, target, source, **kw):
if 'FORCEGITVERSION' in env:
git_version = env['FORCEGITVERSION']
else:
git_version = buildscripts.utils.getGitVersion()
if len(env["MONGO_MODULES"]):
git_version += " modules: " + ", ".join(env["MONGO_MODULES"])
if 'FORCETOKUVERSION' in env:
tokukv_version = env['FORCETOKUVERSION']
else:
tokukv_version = buildscripts.utils.getTokukvVersion(env['TOKUKV_PATH'])
if usev8:
js_engine = "V8"
elif usesm:
js_engine = "SpiderMonkey"
else:
js_engine = "Unknown"
contents = str(source[0]) % dict(git_version=git_version,
tokukv_version=tokukv_version,
js_engine=js_engine,
sys_info=getSysInfo(),
loader_flags=env.subst('$LINKFLAGS $LDFLAGS',
source=source, target=target),
compiler_flags=env.subst('$CXXFLAGS $CCFLAGS $CFLAGS',
source=source, target=target))
out = open(str(target[0]), 'wb')
try:
out.write(contents)
finally:
out.close()
env.Command(buildinfo_filename, Value(buildinfo_template), generate_buildinfo)
env.AlwaysBuild(buildinfo_filename)
env.Install('$BUILD_DIR/mongo', buildinfo_filename)
env.Install('$BUILD_DIR/client_build/mongo', buildinfo_filename)