]> git.cworth.org Git - apitrace/blob - SConstruct
Basic support for tracing d3d7.
[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 ])
44
45 if env['debug']:
46     env.Append(CPPDEFINES = ['_DEBUG'])
47 else:
48     env.Append(CPPDEFINES = ['NDEBUG'])
49 env['PDB'] = '${TARGET.base}.pdb'
50
51 cflags = [
52     '/W4', # warning level
53 ]
54 if env['debug']:
55     cflags += [
56       '/Od', # disable optimizations
57       '/Oy-', # disable frame pointer omission
58     ]
59 else:
60     cflags += [
61       '/Ox', # maximum optimizations
62       '/Os', # favor code space
63     ]
64 cflags += [
65     '/Oi', # enable intrinsic functions
66     '/GF', # enable read-only string pooling
67     '/MT',
68 ]
69 env.Append(CFLAGS = cflags)
70 env.Append(CXXFLAGS = cflags)
71
72 env.Prepend(LIBS = [
73     'kernel32',
74     'user32',
75     'gdi32',
76 ])
77
78 Export('env')
79 SConscript('zlib/SConscript')
80
81 env.Append(CPPPATH = [
82     os.path.join(env['dxsdk'], 'Include'),
83 ])
84
85 conf = Configure(env)
86 has_d3d9 = conf.CheckCHeader('d3d9.h')
87 has_d3d8 = conf.CheckCHeader('d3d8.h')
88 has_d3d7 = conf.CheckCHeader('ddraw.h')
89 env = conf.Finish()
90
91 if has_d3d7:
92     env.Command(
93         target = 'ddraw.cpp', 
94         source = ['ddraw.py', 'd3d.py', 'd3dtypes.py', 'd3dcaps.py', 'windows.py', 'base.py'],
95         action = 'python $SOURCE > $TARGET',
96     )
97         
98     ddraw = env.SharedLibrary(
99         target = 'ddraw',
100         source = [
101             'ddraw.def',
102             'ddraw.cpp',
103             'log.cpp',
104         ]
105     )
106
107     env.Default(ddraw)
108
109 if has_d3d8:
110     env.Command(
111         target = 'd3d8.cpp', 
112         source = ['d3d8.py', 'd3d8types.py', 'd3d8caps.py', 'windows.py', 'base.py'],
113         action = 'python $SOURCE > $TARGET',
114     )
115         
116     d3d8 = env.SharedLibrary(
117         target = 'd3d8',
118         source = [
119             'd3d8.def',
120             'd3d8.cpp',
121             'log.cpp',
122         ]
123     )
124
125     env.Default(d3d8)
126
127 if has_d3d9:
128     env.Command(
129         target = 'd3d9.cpp', 
130         source = ['d3d9.py', 'd3d9types.py', 'd3d9caps.py', 'windows.py', 'base.py'],
131         action = 'python $SOURCE > $TARGET',
132     )
133         
134     d3d9 = env.SharedLibrary(
135         target = 'd3d9',
136         source = [
137             'd3d9.def',
138             'd3d9.cpp',
139             'log.cpp',
140         ]
141     )
142
143     env.Default(d3d9)
144
145 env.Command(
146     target = 'opengl32.cpp', 
147     source = ['opengl32.py', 'gl.py', 'windows.py', 'base.py'],
148     action = 'python $SOURCE > $TARGET',
149 )
150     
151 opengl32 = env.SharedLibrary(
152     target = 'opengl32',
153     source = [
154         'opengl32.def',
155         'opengl32.cpp',
156         'log.cpp',
157     ]
158 )
159
160 env.Default(opengl32)
161
162 env.Tool('packaging')
163
164 zip = env.Package(
165     NAME           = 'd3dtrace',
166     VERSION        = '0.2',
167     PACKAGEVERSION = 0,
168     PACKAGETYPE    = 'zip',
169     LICENSE        = 'lgpl',
170     SUMMARY        = 'Tool to trace Direct3D API calls from applications.',
171     SOURCE_URL     = 'http://cgit.freedesktop.org/~jrfonseca/d3dtrace/',
172     source = [
173         'README',
174         'COPYING',
175         'COPYING.LESSER',
176         'd3d8.dll',
177         'd3d9.dll',
178         'd3dtrace.xsl',
179         'd3dtrace.css',
180         'xml2txt.py',
181     ],
182 )
183
184 env.Alias('zip', zip)