swr: [rasterizer core/scripts] Autogen backend initialization function(s)
[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_config = os.environ.get('LLVM_CONFIG', 'llvm-config')
35 llvm_includedir = env.backtick('%s --includedir' % llvm_config).rstrip()
36 print "llvm include dir %s" % llvm_includedir
37
38 # the loader is included in the mesa lib itself
39 # All the remaining files are in loadable modules
40 loadersource = env.ParseSourceList('Makefile.sources', [
41 'LOADER_SOURCES'
42 ])
43
44 if not env['msvc'] :
45 env.Append(CCFLAGS = [
46 '-std=c++11',
47 ])
48
49 swrroot = '#src/gallium/drivers/swr/'
50
51 env.CodeGenerate(
52 target = 'rasterizer/scripts/gen_knobs.cpp',
53 script = swrroot + 'rasterizer/scripts/gen_knobs.py',
54 source = 'rasterizer/scripts/templates/knobs.template',
55 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp'
56 )
57
58 env.CodeGenerate(
59 target = 'rasterizer/scripts/gen_knobs.h',
60 script = swrroot + 'rasterizer/scripts/gen_knobs.py',
61 source = 'rasterizer/scripts/templates/knobs.template',
62 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
63 )
64
65 env.CodeGenerate(
66 target = 'rasterizer/jitter/state_llvm.h',
67 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py',
68 source = 'rasterizer/core/state.h',
69 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
70 )
71
72 env.CodeGenerate(
73 target = 'rasterizer/jitter/builder_gen.h',
74 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
75 source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
76 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_h'
77 )
78
79 env.CodeGenerate(
80 target = 'rasterizer/jitter/builder_gen.cpp',
81 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
82 source = os.path.join(llvm_includedir, 'llvm/IR/IRBuilder.h'),
83 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET --gen_cpp'
84 )
85
86 env.CodeGenerate(
87 target = 'rasterizer/jitter/builder_x86.h',
88 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
89 source = '',
90 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h'
91 )
92
93 env.CodeGenerate(
94 target = 'rasterizer/jitter/builder_x86.cpp',
95 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
96 source = '',
97 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp'
98 )
99
100 env.CodeGenerate(
101 target = 'swr_context_llvm.h',
102 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_types.py',
103 source = 'swr_context.h',
104 command = python_cmd + ' $SCRIPT --input $SOURCE --output $TARGET'
105 )
106
107 env.CodeGenerate(
108 target = 'rasterizer/archrast/gen_ar_event.h',
109 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
110 source = 'rasterizer/archrast/events.proto',
111 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_h'
112 )
113
114 env.CodeGenerate(
115 target = 'rasterizer/archrast/gen_ar_event.cpp',
116 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
117 source = 'rasterizer/archrast/events.proto',
118 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_event_cpp'
119 )
120
121 env.CodeGenerate(
122 target = 'rasterizer/archrast/gen_ar_eventhandler.h',
123 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
124 source = 'rasterizer/archrast/events.proto',
125 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandler_h'
126 )
127
128 env.CodeGenerate(
129 target = 'rasterizer/archrast/gen_ar_eventhandlerfile.h',
130 script = swrroot + 'rasterizer/scripts/gen_archrast.py',
131 source = 'rasterizer/archrast/events.proto',
132 command = python_cmd + ' $SCRIPT --proto $SOURCE --output $TARGET --gen_eventhandlerfile_h'
133 )
134
135 # 5 SWR_MULTISAMPLE_TYPE_COUNT
136 # 2 SWR_MSAA_SAMPLE_PATTERN_COUNT
137 # 3 SWR_INPUT_COVERAGE_COUNT
138 # 2 centroid
139 # 2 forcedSampleCount
140 # 2 canEarlyZ
141 env.CodeGenerate(
142 target = 'rasterizer/core/BackendPixelRate0.cpp',
143 script = swrroot + 'rasterizer/scripts/gen_backends.py',
144 command = python_cmd + ' $SCRIPT --output rasterizer/core --dim 5 2 3 2 2 2 --split 0 --cpp'
145 )
146
147 # Auto-generated .cpp files (that need to generate object files)
148 built_sources = [
149 'rasterizer/scripts/gen_knobs.cpp',
150 'rasterizer/jitter/builder_gen.cpp',
151 'rasterizer/jitter/builder_x86.cpp',
152 'rasterizer/archrast/gen_ar_event.cpp',
153 'rasterizer/core/BackendPixelRate0.cpp',
154 ]
155
156 source = built_sources
157 source += env.ParseSourceList(swrroot + 'Makefile.sources', [
158 'CXX_SOURCES',
159 'ARCHRAST_CXX_SOURCES',
160 'COMMON_CXX_SOURCES',
161 'CORE_CXX_SOURCES',
162 'JITTER_CXX_SOURCES',
163 'MEMORY_CXX_SOURCES'
164 ])
165
166 env.Prepend(LIBS = [ mesautil, mesa, gallium ])
167
168 env.Prepend(CPPPATH = [
169 '.',
170 'rasterizer',
171 'rasterizer/scripts',
172 'rasterizer/core',
173 'rasterizer/jitter',
174 'rasterizer/archrast',
175 ])
176
177 # AVX lib
178 envavx = env.Clone()
179
180 envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
181 if env['platform'] == 'windows':
182 envavx.Append(CCFLAGS = ['/arch:AVX'])
183 else:
184 envavx.Append(CCFLAGS = ['-mavx'])
185
186 swrAVX = envavx.SharedLibrary(
187 target = 'swrAVX',
188 source = source,
189 OBJPREFIX = 'avx_'
190 )
191 env.Alias('swrAVX', swrAVX)
192
193 # AVX2 lib
194 envavx2 = env.Clone()
195
196 envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
197 if env['platform'] == 'windows':
198 envavx2.Append(CCFLAGS = ['/arch:AVX2'])
199 else:
200 envavx2.Append(CCFLAGS = ['-mavx2'])
201
202 swrAVX2 = envavx2.SharedLibrary(
203 target = 'swrAVX2',
204 source = source,
205 OBJPREFIX = 'avx2_'
206 )
207 env.Alias('swrAVX2', swrAVX2)
208
209
210 # main SWR lib
211 swr = env.ConvenienceLibrary(
212 target = 'swr',
213 source = loadersource,
214 )
215
216
217 # treat arch libs as dependencies, even though they are not linked
218 # into swr, so we don't have to build them separately
219 Depends(swr, ['swrAVX', 'swrAVX2'])
220
221 env.Alias('swr', swr)
222
223 env.Prepend(LIBS = [swr])
224
225 Export('swr')