-
Notifications
You must be signed in to change notification settings - Fork 1
/
SConstruct
84 lines (70 loc) · 2.3 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
env = Environment()
# Configure this...
lib='comms'
libs=['']
# Only in Win32...
if env['PLATFORM']=='win32':
libs=['Ws2_32.lib']
testlibs=['comms']
# Fixed constants
libdir='lib'
bindir='bin'
testdir='test'
srcdir='src'
target=libdir+'/'+lib
testTarget=bindir+'/test-'+lib
extensions='*.c'
headers=' *.h'
api='src/comms.h'
map='bin/comms.map'
# Fixed code
import os
import sys
import glob
import shutil
#def runUnitTest(env,target,source):
# import subprocess
# app=str(source[0].abspath)
# if not subprocess.call(app):
# open(str(target[0],'w').write("PASSED\n")
srcs=[]
for extension in extensions.split():
srcs+=glob.glob(os.path.join(srcdir,extension))
testsrcs=[]
for extension in extensions.split():
testsrcs+=glob.glob(os.path.join(testdir,extension))
# Fix bad vc9 detection using the environment variables instead
#include_path=os.environ['INCLUDE']
#env.PrependENVPath('INCLUDE', include_path)
#lib_path=os.environ['LIB']
#env.PrependENVPath('LIB', lib_path)
#env.Append(LIBPATH='#/'+libdir)
#env.Append(LIBS = libs)
# Main target: the DLL
#env.Append(LINKFLAGS='/MAP:lib/conn.map');
mainTarget=env.SharedLibrary(target,srcs, LIBS = libs, LIBPATH='#/'+libdir) # register=1 falla en WinXP
# Test target: unit test program (depends on main target)
test=env.Program(testTarget,testsrcs, LIBS=testlibs, LIBPATH='#/'+libdir)
#env.AddPostAction(test,test[0].abspath)
Depends(test, mainTarget)
env.AlwaysBuild(test)
#Command("test.passed",'test',runUnitTest)
# Binary installation target depends on main target
dlls=glob.glob(libdir+'/*.dll');
installation=Install(bindir,dlls)
Depends(installation,mainTarget)
# Source Zip target (depends on main target)
hdrs=[]
for header in headers.split():
hdrs+=glob.glob(os.path.join(srcdir,header))
for header in headers.split():
hdrs+=glob.glob(os.path.join(testdir,header))
allsources=['SConstruct']+testsrcs+srcs+hdrs
srczip=Zip(lib+".zip",allsources)
Depends(srczip,mainTarget)
# Binary Zip target depends on main target
allbins=[api]+glob.glob(os.path.join('bin','*.dll'))+glob.glob(os.path.join('bin','*.so'))
binzip=Zip(lib+".bin.zip",allbins)
Depends(binzip,mainTarget)
# Latest release installation target depends on main target
latest=Install('latest', [mainTarget, api]) # ,map