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_includedir = env.backtick('llvm-config --includedir').rstrip()
35 print "llvm include dir %s" % llvm_includedir
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', [
43 env.Append(CPPDEFINES = [
44 '__STDC_CONSTANT_MACROS',
49 env.Append(CCFLAGS = [
53 swrroot = '#src/gallium/drivers/swr/'
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'
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'
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'
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'
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'
91 target = 'rasterizer/jitter/builder_x86.h',
92 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
94 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_h'
98 target = 'rasterizer/jitter/builder_x86.cpp',
99 script = swrroot + 'rasterizer/jitter/scripts/gen_llvm_ir_macros.py',
101 command = python_cmd + ' $SCRIPT --output $TARGET --gen_x86_cpp'
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'
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'
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'
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'
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'
139 # Auto-generated .cpp files (that need to generate object files)
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',
147 source = built_sources
148 source += env.ParseSourceList(swrroot + 'Makefile.sources', [
150 'ARCHRAST_CXX_SOURCES',
151 'COMMON_CXX_SOURCES',
153 'JITTER_CXX_SOURCES',
157 env.Prepend(LIBS = [ mesautil, mesa, gallium ])
159 env.Prepend(CPPPATH = [
162 'rasterizer/scripts',
165 'rasterizer/archrast',
171 envavx.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX'])
172 if env['platform'] == 'windows':
173 envavx.Append(CCFLAGS = ['/arch:AVX'])
175 envavx.Append(CCFLAGS = ['-mavx'])
177 swrAVX = envavx.SharedLibrary(
182 env.Alias('swrAVX', swrAVX)
185 envavx2 = env.Clone()
187 envavx2.Append(CPPDEFINES = ['KNOB_ARCH=KNOB_ARCH_AVX2'])
188 if env['platform'] == 'windows':
189 envavx2.Append(CCFLAGS = ['/arch:AVX2'])
191 envavx2.Append(CCFLAGS = ['-mavx2'])
193 swrAVX2 = envavx2.SharedLibrary(
198 env.Alias('swrAVX2', swrAVX2)
202 swr = env.ConvenienceLibrary(
204 source = loadersource,
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'])
212 env.Alias('swr', swr)
214 env.Prepend(LIBS = [swr])