]> git.cworth.org Git - apitrace/blob - SConstruct
Flush to ensure the file is in readable state if the process dies.
[apitrace] / SConstruct
1 #############################################################################
2 #
3 # Copyright 2008 Tungsten Graphics, Inc.
4 #
5 # This program is free software: you can redistribute it and/or modify it
6 # under the terms of the GNU Lesser General Public License as published
7 # by the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
9 #
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 # GNU Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public License
16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
17 #
18 #############################################################################
19
20 import os
21 import os.path
22 import sys
23
24 opts = Options('config.py')
25 opts.Add(BoolOption('debug', 'build debug version', 'no'))
26 opts.Add(PathOption('dxsdk', 'DirectX SDK installation dir', os.environ.get('DXSDK_DIR', 'C:\\DXSDK')))
27 opts.Add(EnumOption('MSVS_VERSION', 'Microsoft Visual Studio version', None, allowed_values=('7.1', '8.0', '9.0')))
28
29 env = Environment(
30     options = opts, 
31     ENV = os.environ)
32 Help(opts.GenerateHelpText(env))
33
34 env.Append(CPPDEFINES = [
35     'WIN32', 
36     '_WINDOWS', 
37     '_UNICODE',
38     'UNICODE',
39     '_CRT_SECURE_NO_DEPRECATE',
40     '_CRT_NON_CONFORMING_SWPRINTFS',
41     'WIN32_LEAN_AND_MEAN',
42     '_USRDLL',
43     ('_WIN32_WINNT', '0x0501'), # minimum required OS version
44 ])
45
46 if env['debug']:
47     env.Append(CPPDEFINES = ['_DEBUG'])
48 else:
49     env.Append(CPPDEFINES = ['NDEBUG'])
50 env['PDB'] = '${TARGET.base}.pdb'
51
52 cflags = [
53     '/W4', # warning level
54 ]
55 if env['debug']:
56     cflags += [
57       '/Od', # disable optimizations
58       '/Oy-', # disable frame pointer omission
59     ]
60 else:
61     cflags += [
62       '/Ox', # maximum optimizations
63       '/Os', # favor code space
64     ]
65 cflags += [
66     '/Oi', # enable intrinsic functions
67     '/GF', # enable read-only string pooling
68     '/MT',
69 ]
70 env.Append(CFLAGS = cflags)
71 env.Append(CXXFLAGS = cflags)
72
73 env.Prepend(LIBS = [
74     'kernel32',
75     'user32',
76     'gdi32',
77 ])
78
79 Export('env')
80 SConscript('zlib/SConscript')
81
82 env.Append(CPPPATH = [
83     os.path.join(env['dxsdk'], 'Include'),
84 ])
85
86 conf = Configure(env)
87 has_d3d9 = conf.CheckCHeader('d3d9.h')
88 has_d3d8 = conf.CheckCHeader('d3d8.h')
89 has_d3d7 = conf.CheckCHeader('ddraw.h')
90 env = conf.Finish()
91
92 if has_d3d7:
93     env.Command(
94         target = 'ddraw.cpp', 
95         source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
96         action = 'python $SOURCE > $TARGET',
97     )
98         
99     ddraw = env.SharedLibrary(
100         target = 'ddraw',
101         source = [
102             'ddraw.def',
103             'ddraw.cpp',
104             'log.cpp',
105         ]
106     )
107
108     env.Default(ddraw)
109
110 if has_d3d8:
111     env.Command(
112         target = 'd3d8.cpp', 
113         source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
114         action = 'python $SOURCE > $TARGET',
115     )
116         
117     d3d8 = env.SharedLibrary(
118         target = 'd3d8',
119         source = [
120             'd3d8.def',
121             'd3d8.cpp',
122             'log.cpp',
123         ]
124     )
125
126     env.Default(d3d8)
127
128 if has_d3d9:
129     env.Command(
130         target = 'd3d9.cpp', 
131         source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'windows.py', 'base.py'],
132         action = 'python $SOURCE > $TARGET',
133     )
134         
135     d3d9 = env.SharedLibrary(
136         target = 'd3d9',
137         source = [
138             'd3d9.def',
139             'd3d9.cpp',
140             'log.cpp',
141         ]
142     )
143
144     env.Default(d3d9)
145
146 env.Command(
147     target = 'opengl32.cpp', 
148     source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
149     action = 'python $SOURCE > $TARGET',
150 )
151     
152 opengl32 = env.SharedLibrary(
153     target = 'opengl32',
154     source = [
155         'opengl32.def',
156         'opengl32.cpp',
157         'log.cpp',
158     ]
159 )
160
161 env.Default(opengl32)
162
163 env.Tool('packaging')
164
165 zip = env.Package(
166     NAME           = 'apitrace',
167     VERSION        = '0.3',
168     PACKAGEVERSION = 0,
169     PACKAGETYPE    = 'zip',
170     LICENSE        = 'lgpl',
171     SUMMARY        = 'Tool to trace Direct3D & OpenGL API calls from applications.',
172     SOURCE_URL     = 'http://cgit.freedesktop.org/~jrfonseca/apitrace/',
173     source = [
174         'README',
175         'COPYING',
176         'COPYING.LESSER',
177         'd3d8.dll',
178         'd3d9.dll',
179         'apitrace.xsl',
180         'apitrace.css',
181         'xml2txt.py',
182     ],
183 )
184
185 env.Alias('zip', zip)