3 from sys import executable as python_cmd
5 import distutils.version
11 print 'warning: LLVM disabled: not building swr'
15 if env['LLVM_VERSION'] < distutils.version.LooseVersion('3.9'):
16 print "warning: swr requires LLVM >= 3.9: not building swr"
20 if env['platform'] != 'windows':
21 print "warning: swr scons build only supports windows: not building swr"
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')
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
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', [
45 env.Append(CCFLAGS = [
49 swrroot = '#src/gallium/drivers/swr/'
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'
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'
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'
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'
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'
87 target = 'rasterizer/jitter/builder_x86.h',
88 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
90 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h'
94 target = 'rasterizer/jitter/builder_x86.cpp',
95 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
97 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp'
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'
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'
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'
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'
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'
135 # 5 SWR_MULTISAMPLE_TYPE_COUNT
136 # 2 SWR_MSAA_SAMPLE_PATTERN_COUNT
137 # 3 SWR_INPUT_COVERAGE_COUNT
139 # 2 forcedSampleCount
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'
147 # Auto-generated .cpp files (that need to generate object files)
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',
156 source = built_sources
157 source += env.ParseSourceList(swrroot + 'Makefile.sources', [
159 'ARCHRAST_CXX_SOURCES',
160 'COMMON_CXX_SOURCES',
162 'JITTER_CXX_SOURCES',
166 env.Prepend(LIBS = [ mesautil, mesa, gallium ])
168 env.Prepend(CPPPATH = [
171 'rasterizer/scripts',
174 'rasterizer/archrast',
180 envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
181 if env['platform'] == 'windows':
182 envavx.Append(CCFLAGS = ['/arch:AVX'])
184 envavx.Append(CCFLAGS = ['-mavx'])
186 swrAVX = envavx.SharedLibrary(
191 env.Alias('swrAVX', swrAVX)
194 envavx2 = env.Clone()
196 envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
197 if env['platform'] == 'windows':
198 envavx2.Append(CCFLAGS = ['/arch:AVX2'])
200 envavx2.Append(CCFLAGS = ['-mavx2'])
202 swrAVX2 = envavx2.SharedLibrary(
207 env.Alias('swrAVX2', swrAVX2)
211 swr = env.ConvenienceLibrary(
213 source = loadersource,
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'])
221 env.Alias('swr', swr)
223 env.Prepend(LIBS = [swr])