Debian Codegraph @

Source/Tests/SConscript

raw
1 target = 'test'
2
3 tests = Split("""
4 compression.cpp
5 decompress.cpp
6 DialogTemplate.cpp
7 endian.cpp
8 mmap.cpp
9 Platform.cpp
10 ResourceEditor.cpp
11 specmatch.cpp
12 textrunner.cpp
13 winchar.cpp
14 """)
15
16 required = Split("""
17 DialogTemplate.cpp
18 dirreader.cpp
19 growbuf.cpp
20 mmap.cpp
21 BinInterop.cpp
22 ResourceEditor.cpp
23 util.cpp
24 winchar.cpp
25 """)
26
27 required_exehead = Split("""
28 Tests/memcpy.c
29 """)
30
31 lzma_files = Split("""
32 clzma.cpp
33 7zip/7zGuids.cpp
34 7zip/7zip/Common/OutBuffer.cpp
35 7zip/7zip/Common/StreamUtils.cpp
36 7zip/7zip/Compress/LZ/LZInWindow.cpp
37 7zip/7zip/Compress/LZMA/LZMAEncoder.cpp
38 7zip/7zip/Compress/RangeCoder/RangeCoderBit.cpp
39 7zip/Common/Alloc.cpp
40 7zip/Common/CRC.cpp
41 7zip/LZMADecode.c
42 """)
43
44 required += lzma_files
45
46 bzip2_files = Split("""
47 bzip2/blocksort.c
48 bzip2/bzlib.c
49 bzip2/compress.c
50 bzip2/huffman.c
51 """)
52
53 bzip2_exehead_files = Split("""
54 bzip2/bzlib.c
55 bzip2/decompress.c
56 """)
57
58 required += bzip2_files
59 required_exehead += bzip2_exehead_files
60
61 zlib_exehead_files = Split("""
62 zlib/INFBLOCK.C
63 """)
64
65 required_exehead += zlib_exehead_files
66
67 cppunitlibs = Split("""
68 cppunit
69 """)
70
71 extralibs = Split("""
72 dl
73 gdi32
74 iconv
75 pthread
76 user32
77 oleaut32
78 """)
79
80 scripts = Split("""
81 icon1.nsi
82 icon2.nsi
83 preprocessor.nsi
84 winver.nsi
85 """)
86
87 Import('env AddAvailableLibs AddZLib')
88
89 # Test scripts
90 env.TestScript(scripts)
91
92 # Use available libraries
93 if env['PLATFORM'] == 'win32':
94 # XXX will cause problems if tests are cross compiled
95 # on freebsd, libversion.a exists and gives trouble if linked
96 extralibs += ['version']
97
98 AddAvailableLibs(env, extralibs)
99 AddZLib(env, env['PLATFORM'])
100
101 # compile using msvcrt (that's how cppunit.lib is built)
102 if 'msvc' in env['TOOLS'] or 'mstoolkit' in env['TOOLS']:
103 env.Append(CCFLAGS = ['/MD'])
104
105 # uses exceptions
106 env.Append(CCFLAGS = ['$EXCEPTION_FLAG'])
107
108 # for lzma
109 env.Append(CPPDEFINES = ['COMPRESS_MF_BT'])
110
111 # test for CppUnit
112 conf = env.Configure()
113 cppunit = conf.CheckLibWithHeader(cppunitlibs, 'cppunit/extensions/HelperMacros.h', 'C++')
114 conf.Finish()
115
116 if cppunit:
117
118 # compile files from parent directory
119 required_obj = []
120
121 for i in required:
122 b = 'required/%s' % i.split('.')[0]
123 s = '#Source/%s' % i
124 o = env.Object(b, s)
125
126 required_obj.append(o)
127
128 # exehead files special treatment
129 exehead_env = env.Clone()
130 exehead_env.Append(CCFLAGS = ['$C_FLAG'])
131 exehead_env.Append(
132 CPPDEFINES = [
133 'EXEHEAD',
134 'NSIS_COMPRESS_USE_ZLIB' # just so config.h won't complain
135 ]
136 )
137
138 for i in required_exehead:
139 b = 'required/exehead/%s' % i.split('.')[0]
140 s = '#Source/%s' % i
141 o = exehead_env.Object(b, s)
142
143 required_obj.append(o)
144
145 # build test program
146 tests = env.Program(target, tests + required_obj)
147 if env['PLATFORM'] == 'win32' and 'ZLIB_W32_DLL' in env:
148 import os.path
149 env.Depends(tests, env.InstallAs(
150 os.path.basename(str(env['ZLIB_W32_DLL'])),
151 env['ZLIB_W32_DLL']))
152
153 # alias running the test to 'test'
154 test = env.Alias('test-code', [tests], tests[0].abspath)
155
156 # always test when asked to
157 AlwaysBuild(test)
158
159 else:
160
161 # no CppUnit
162 def err(target, source, env):
163 print('*** error: CppUnit must be installed for testing!')
164 return 1
165
166 cmd = env.Command(target, [tests], Action(err, ''))
167 env.Alias('test-code', cmd)