-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathSConstruct
More file actions
44 lines (34 loc) · 1.38 KB
/
SConstruct
File metadata and controls
44 lines (34 loc) · 1.38 KB
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
import platform, sys;
import subprocess
import os
# Lets get the version from git
# first get the base version
git_sha = subprocess.Popen(["git","rev-parse","--short=10","HEAD"], stdout=subprocess.PIPE ).communicate()[0].strip()
p1 = subprocess.Popen(["git", "status"], stdout=subprocess.PIPE )
p2 = subprocess.Popen(["grep", "Changed but not updated\\|Changes to be committed"], stdin=p1.stdout,stdout=subprocess.PIPE)
result = p2.communicate()[0].strip()
if result!="":
git_sha += "[MOD]"
print "Building version %s"%git_sha
env = Environment()
env.Append( CPPPATH=['./include'] )
if sys.platform=="linux2" or sys.platform=="linux":
env.Append( CXXFLAGS='-pthread')
elif sys.platform=="sunos5":
env.Append( CXXFLAGS='-pthreads')
env['CXX']='/usr/sfw/bin/g++'
env.Append( LIBS=['socket','resolv','nsl'])
env.Append( CPPFLAGS=['-g','-Wall','-O2'] )
#A library containing several of the objects just to make linking the tests easier
def version_action(target,source,env):
"""
Generate file with current version info
"""
fd=open(target[0].path,'w')
fd.write( "static const char version_cstr[] = \"%s (\" __DATE__ \")\";\nconst char * version()\n{\n return version_cstr;\n}\n" % git_sha )
fd.close()
return 0
build_version = env.Command( 'src/autogen_version.cpp', [], Action(version_action) )
env.AlwaysBuild(build_version)
src = Glob('src/*.cpp')
env.Library('fastjson', src)