0de51a791693d56c333cbac5ae6743f4ad507a3b
[mesa.git] / src / gallium / drivers / swr / SConscript
1 Import('*')
2
3 from sys import executable as python_cmd
4 import os.path
5 import distutils.version
6
7 if not env['swr']:
8 Return()
9
10 if not env['llvm']:
11 print 'warning: LLVM disabled: not building swr'
12 env['swr'] = False
13 Return()
14
15 if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'):
16 print "warning: swr requires LLVM >= 3.9: not building swr"
17 env['swr'] = False
18 Return()
19
20 if env['platform'] != 'windows':
21 print "warning: swr scons build only supports windows: not building swr"
22 env['swr'] = False
23 Return()
24
25 env.MSVC2013Compat()
26
27 env = env.Clone()
28
29 # construct llvm include dir
30 if env['platform'] == 'windows':
31 # on windows there is no llvm-config, so LLVM is defined
32 llvm_includedir = os.path.join(os.environ['LLVM'], 'include')
33 else:
34 llvm_includedir = env.backtick('llvm-config --includedir').rstrip()
35 print "llvm include dir %s" % llvm_includedir
36
37 # the loader is included in the mesa lib itself
38 # All the remaining files are in loadable modules
39 loadersource = env.ParseSourceList('Makefile.sources', [
40 'LOADER_SOURCES'
41 ])
42
43 env.Append(CPPDEFINES = [
44 '__STDC_CONSTANT_MACROS',
45 '__STDC_LIMIT_MACROS'
46 ])
47
48 if not env['msvc'] :
49 env.Append(CCFLAGS = [
50 '-std=c++11',
51 ])
52
53 swrroot = '#src/gallium/drivers/swr/'
54
55 env.CodeGenerate(
56 target = 'rasterizer/scripts/gen_knobs.cpp',
57 script = swrroot + 'rasterizer/scripts/gen_knobs.py',
58 source = 'rasterizer/scripts/templates/knobs.template',
59 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp'
60 )
61
62 env.CodeGenerate(
63 target = 'rasterizer/scripts/gen_knobs.h',
64 script = swrroot + 'rasterizer/scripts/gen_knobs.py',
65 source = 'rasterizer/scripts/templates/knobs.template',
66 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
67 )
68
69 env.CodeGenerate(
70 target = 'rasterizer/jitter/state_llvm.h',
71 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py',
72 source = 'rasterizer/core/state.h',
73 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
74 )
75
76 env.CodeGenerate(
77 target = 'rasterizer/jitter/builder_gen.h',
78 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
79 source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
80 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
81 )
82
83 env.CodeGenerate(
84 target = 'rasterizer/jitter/builder_gen.cpp',
85 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
86 source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
87 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp'
88 )
89
90 env.CodeGenerate(
91 target = 'rasterizer/jitter/builder_x86.h',
92 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
93 source = '',
94 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h'
95 )
96
97 env.CodeGenerate(
98 target = 'rasterizer/jitter/builder_x86.cpp',
99 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
100 source = '',
101 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp'
102 )
103
104 env.CodeGenerate(
105 target = 'swr_context_llvm.h',
106 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py',
107 source = 'swr_context.h',
108 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
109 )
110
111 env.CodeGenerate(
112 target = 'rasterizer/archrast/gen_ar_event.h',
113 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
114 source = 'rasterizer/archrast/events.proto',
115 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h'
116 )
117
118 env.CodeGenerate(
119 target = 'rasterizer/archrast/gen_ar_event.cpp',
120 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
121 source = 'rasterizer/archrast/events.proto',
122 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp'
123 )
124
125 env.CodeGenerate(
126 target = 'rasterizer/archrast/gen_ar_eventhandler.h',
127 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
128 source = 'rasterizer/archrast/events.proto',
129 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h'
130 )
131
132 env.CodeGenerate(
133 target = 'rasterizer/archrast/gen_ar_eventhandlerfile.h',
134 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
135 source = 'rasterizer/archrast/events.proto',
136 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h'
137 )
138
139 # Auto-generated .cpp files (that need to generate object files)
140 built_sources = [
141 'rasterizer/scripts/gen_knobs.cpp',
142 'rasterizer/jitter/builder_gen.cpp',
143 'rasterizer/jitter/builder_x86.cpp',
144 'rasterizer/archrast/gen_ar_event.cpp',
145 ]
146
147 source = built_sources
148 source += env.ParseSourceList(swrroot + 'Makefile.sources', [
149 'CXX_SOURCES',
150 'ARCHRAST_CXX_SOURCES',
151 'COMMON_CXX_SOURCES',
152 'CORE_CXX_SOURCES',
153 'JITTER_CXX_SOURCES',
154 'MEMORY_CXX_SOURCES'
155 ])
156
157 env.Prepend(LIBS = [ mesautil, mesa, gallium ])
158
159 env.Prepend(CPPPATH = [
160 '.',
161 'rasterizer',
162 'rasterizer/scripts',
163 'rasterizer/core',
164 'rasterizer/jitter',
165 'rasterizer/archrast',
166 ])
167
168 # AVX lib
169 envavx = env.Clone()
170
171 envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
172 if env['platform'] == 'windows':
173 envavx.Append(CCFLAGS = ['/arch:AVX'])
174 else:
175 envavx.Append(CCFLAGS = ['-mavx'])
176
177 swrAVX = envavx.SharedLibrary(
178 target = 'swrAVX',
179 source = source,
180 OBJPREFIX = 'avx_'
181 )
182 env.Alias('swrAVX', swrAVX)
183
184 # AVX2 lib
185 envavx2 = env.Clone()
186
187 envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
188 if env['platform'] == 'windows':
189 envavx2.Append(CCFLAGS = ['/arch:AVX2'])
190 else:
191 envavx2.Append(CCFLAGS = ['-mavx2'])
192
193 swrAVX2 = envavx2.SharedLibrary(
194 target = 'swrAVX2',
195 source = source,
196 OBJPREFIX = 'avx2_'
197 )
198 env.Alias('swrAVX2', swrAVX2)
199
200
201 # main SWR lib
202 swr = env.ConvenienceLibrary(
203 target = 'swr',
204 source = loadersource,
205 )
206
207
208 # treat arch libs as dependencies, even though they are not linked
209 # into swr, so we don't have to build them separately
210 Depends(swr, ['swrAVX', 'swrAVX2'])
211
212 env.Alias('swr', swr)
213
214 env.Prepend(LIBS = [swr])
215
216 Export('swr')