fix gcc warnings
[plumiferos.git] / tools / btools.py
blob7e2061ae789e18e50226de4fc9b9b7c307de001d
1 import sys
2 import StringIO
3 import SCons.Options
4 import SCons.Options.BoolOption
6 Options = SCons.Options
7 BoolOption = SCons.Options.BoolOption
9 def print_arguments(args, bc):
10 if len(args):
11 for k,v in args.iteritems():
12 print '\t'+bc.OKBLUE+k+bc.ENDC+' = '+bc.OKGREEN + v + bc.ENDC
13 else:
14 print '\t'+bc.WARNING+'No command-line arguments given'+bc.ENDC
16 def validate_arguments(args, bc):
17 opts_list = [
18 'BF_PYTHON', 'BF_PYTHON_VERSION', 'BF_PYTHON_INC', 'BF_PYTHON_BINARY', 'BF_PYTHON_LIB', 'BF_PYTHON_LIBPATH', 'BF_PYTHON_LINKFLAGS',
19 'WITH_BF_OPENAL', 'BF_OPENAL', 'BF_OPENAL_INC', 'BF_OPENAL_LIB', 'BF_OPENAL_LIBPATH',
20 'WITH_BF_SDL', 'BF_SDL', 'BF_SDL_INC', 'BF_SDL_LIB', 'BF_SDL_LIBPATH',
21 'BF_PTHREADS', 'BF_PTHREADS_INC', 'BF_PTHREADS_LIB', 'BF_PTHREADS_LIBPATH',
22 'WITH_BF_FMOD',
23 'WITH_BF_OPENEXR', 'BF_OPENEXR', 'BF_OPENEXR_INC', 'BF_OPENEXR_LIB', 'BF_OPENEXR_LIBPATH',
24 'WITH_BF_FFMPEG', 'BF_FFMPEG_LIB', 'BF_FFMPEG', 'BF_FFMPEG_INC',
25 'WITH_BF_JPEG', 'BF_JPEG', 'BF_JPEG_INC', 'BF_JPEG_LIB', 'BF_JPEG_LIBPATH',
26 'WITH_BF_PNG', 'BF_PNG', 'BF_PNG_INC', 'BF_PNG_LIB', 'BF_PNG_LIBPATH',
27 'BF_TIFF', 'BF_TIFF_INC',
28 'WITH_BF_ZLIB', 'BF_ZLIB', 'BF_ZLIB_INC', 'BF_ZLIB_LIB', 'BF_ZLIB_LIBPATH',
29 'WITH_BF_INTERNATIONAL',
30 'BF_GETTEXT', 'BF_GETTEXT_INC', 'BF_GETTEXT_LIB', 'BF_GETTEXT_LIBPATH',
31 'WITH_BF_ICONV', 'BF_ICONV', 'BF_ICONV_INC', 'BF_ICONV_LIB', 'BF_ICONV_LIBPATH',
32 'WITH_BF_ODE', 'BF_ODE', 'BF_ODE_INC', 'BF_ODE_LIB',
33 'WITH_BF_GAMEENGINE', 'WITH_BF_BULLET', 'BF_BULLET', 'BF_BULLET_INC', 'BF_BULLET_LIB',
34 'BF_SOLID', 'BF_SOLID_INC', 'BF_WINTAB', 'BF_WINTAB_INC',
35 'WITH_BF_YAFRAY',
36 'BF_FREETYPE', 'BF_FREETYPE_INC', 'BF_FREETYPE_LIB', 'BF_FREETYPE_LIBPATH',
37 'WITH_BF_QUICKTIME', 'BF_QUICKTIME', 'BF_QUICKTIME_INC', 'BF_QUICKTIME_LIB', 'BF_QUICKTIME_LIBPATH',
38 'WITH_BF_STATICOPENGL', 'BF_OPENGL', 'BF_OPENGL_INC', 'BF_OPENGL_LIB', 'BF_OPENGL_LIBPATH', 'BF_OPENGL_LIB_STATIC', 'BF_OPENGL_LINKFLAGS',
39 'WITH_BF_FTGL', 'BF_FTGL', 'BF_FTGL_INC', 'BF_FTGL_LIB',
40 'WITH_BF_FFMPEG',
41 'WITH_BF_PLAYER',
42 'CFLAGS', 'CCFLAGS', 'CPPFLAGS',
43 'REL_CFLAGS', 'REL_CCFLAGS',
44 'C_WARN', 'CC_WARN', 'LLIBS', 'PLATFORM_LINKFLAGS',
45 'BF_PROFILE_FLAGS', 'LCGDIR', 'WITH_BF_VERSE',
46 'BF_VERSE_INCLUDE',
47 'VERSE_BUILD_BINARY', 'VERSE_BUILD_DIR', 'VERSE_REGEN_PROTO',
48 'BF_TWEAK_MODE',
49 'WITHOUT_BF_INSTALL',
50 'BF_FANCY'
53 arg_list = ['BF_DEBUG', 'BF_QUIET', 'BF_CROSS', 'BF_UPDATE',
54 'BF_INSTALLDIR', 'BF_TOOLSET', 'BF_BINNAME',
55 'BF_BUILDDIR', 'BF_FANCY', 'BF_QUICK', 'BF_PROFILE',
56 'BF_DEBUG_FLAGS', 'BF_BSC',
57 'BF_PRIORITYLIST', 'BF_BUILDINFO','CC', 'CXX', "BF_QUICKDEBUG", "BF_LISTDEBUG", 'LCGDIR']
59 all_list = opts_list + arg_list
60 okdict = {}
62 for k,v in args.iteritems():
63 if k in all_list:
64 okdict[k] = v
65 else:
66 print '\t'+bc.WARNING+'Invalid argument: '+bc.ENDC+k+'='+v
68 return okdict
70 def print_targets(targs, bc):
71 if len(targs)>0:
72 for t in targs:
73 print '\t'+bc.OKBLUE+t+bc.ENDC
74 else:
75 print '\t'+bc.WARNING+'No targets given, using '+bc.ENDC+bc.OKGREEN+'default'+bc.ENDC
77 def validate_targets(targs, bc):
78 valid_list = ['.', 'blender', 'blenderstatic', 'blenderplayer', 'webplugin',
79 'blendernogame', 'blenderstaticnogame', 'release',
80 'everything', 'clean', 'install-bin', 'install', 'nsis']
81 oklist = []
82 for t in targs:
83 if t in valid_list:
84 oklist.append(t)
85 else:
86 print '\t'+bc.WARNING+'Invalid target: '+bc.ENDC+t
87 return oklist
91 class idBuffering:
92 def buffered_spawn( self, sh, escape, cmd, args, env ):
93 stderr = StringIO.StringIO()
94 stdout = StringIO.StringIO()
95 command_string = ''
96 for i in args:
97 if ( len( command_string ) ):
98 command_string += ' '
99 command_string += i
100 try:
101 retval = self.env['PSPAWN']( sh, escape, cmd, args, env, stdout, stderr )
102 except OSError, x:
103 if x.errno != 10:
104 raise x
105 print 'OSError ignored on command: %s' % command_string
106 retval = 0
107 sys.stdout.write( stdout.getvalue() )
108 sys.stderr.write( stderr.getvalue() )
109 return retval
111 # get a clean error output when running multiple jobs
112 def SetupBufferedOutput( env ):
113 buf = idBuffering()
114 buf.env = env
115 env['SPAWN'] = buf.buffered_spawn
118 def read_opts(cfg, args):
119 localopts = Options.Options(cfg, args)
120 localopts.AddOptions(
121 ('VERSE_BUILD_BINARY', 'Build a release or debug binary.', 'release'),
122 ('VERSE_BUILD_DIR', 'Target directory for intermediate files.', "${BF_BUILDDIR}/extern/verse"),
123 ('VERSE_REGEN_PROTO', 'Whether to regenerate the protocol files', 'yes'),
124 (BoolOption('WITH_BF_VERSE', 'Use VERSE if true', 'false')),
125 ('BF_VERSE_INCLUDE', 'verse include dir', '/usr/include'),
126 ('LCGDIR', 'location of cvs lib dir'),
127 ('VERSE_BUILD_BINARY', 'Build a release or debug binary.', 'release'),
128 ('VERSE_BUILD_DIR', 'Target directory for intermediate files.', "${BF_BUILDDIR}/extern/verse"),
129 ('VERSE_REGEN_PROTO', 'Whether to regenerate the protocol files', 'yes'),
130 ('BF_DEBUG_LIBS', 'list of libraries to build with debug symbols'),
131 ('BF_PYTHON', 'base path for python', ''),
132 ('BF_PYTHON_VERSION', 'Python version to use', ''),
133 ('BF_PYTHON_INC', 'include path for Python headers', ''),
134 ('BF_PYTHON_BINARY', 'Path to the Python interpreter', ''),
135 ('BF_PYTHON_LIB', 'Python library', ''),
136 ('BF_PYTHON_LIBPATH', 'Library path', ''),
137 ('BF_PYTHON_LINKFLAGS', 'Python link flags', ''),
138 (BoolOption('BF_NO_ELBEEM', 'Disable Fluid Sim', 'false')),
139 (BoolOption('WITH_BF_YAFRAY', 'Enable Yafray', 'true')),
140 (BoolOption('WITH_BF_OPENAL', 'Use OpenAL if true', '')),
141 ('BF_OPENAL', 'base path for OpenAL', ''),
142 ('BF_OPENAL_INC', 'include path for python headers', ''),
143 ('BF_OPENAL_LIB', 'Path to OpenAL library', ''),
144 ('BF_OPENAL_LIBPATH', 'Path to OpenAL library', ''),
146 (BoolOption('WITH_BF_SDL', 'Use SDL if true', '')),
147 ('BF_SDL', 'SDL base path', ''),
148 ('BF_SDL_INC', 'SDL include path', ''), #$(shell $(BF_SDL)/bin/sdl-config --cflags)
149 ('BF_SDL_LIB', 'SDL library', ''), #$(shell $(BF_SDL)/bin/sdl-config --libs) -lSDL_mixer
150 ('BF_SDL_LIBPATH', 'SDL library path', ''),
152 ('BF_PTHREADS', 'Pthreads base path', ''),
153 ('BF_PTHREADS_INC', 'Pthreads include path', ''),
154 ('BF_PTHREADS_LIB', 'Pthreads library', ''),
155 ('BF_PTHREADS_LIBPATH', 'Pthreads library path', ''),
157 (BoolOption('WITH_BF_FMOD', 'Use FMOD if true', 'false')),
158 # BF_FMOD = $(LCGDIR)/fmod
160 (BoolOption('WITH_BF_OPENEXR', 'Use OPENEXR if true', 'true')),
161 ('BF_OPENEXR', 'OPENEXR base path', ''),
162 ('BF_OPENEXR_INC', 'OPENEXR include path', ''),
163 ('BF_OPENEXR_LIB', 'OPENEXR library', ''),
164 ('BF_OPENEXR_LIBPATH', 'OPENEXR library path', ''),
166 (BoolOption('WITH_BF_FFMPEG', 'Use FFMPEG if true', 'false')),
167 ('BF_FFMPEG', 'FFMPEG base path', ''),
168 ('BF_FFMPEG_LIB', 'FFMPEG library', ''),
170 ('BF_FFMPEG_INC', 'FFMPEG includes', ''),
171 ('BF_FFMPEG_LIBPATH', 'FFMPEG library path', ''),
174 (BoolOption('WITH_BF_JPEG', 'Use JPEG if true', 'true')),
175 ('BF_JPEG', 'JPEG base path', ''),
176 ('BF_JPEG_INC', 'JPEG include path', ''),
177 ('BF_JPEG_LIB', 'JPEG library', ''),
178 ('BF_JPEG_LIBPATH', 'JPEG library path', ''),
180 (BoolOption('WITH_BF_PNG', 'Use PNG if true', 'true')),
181 ('BF_PNG', 'PNG base path', ''),
182 ('BF_PNG_INC', 'PNG include path', ''),
183 ('BF_PNG_LIB', 'PNG library', ''),
184 ('BF_PNG_LIBPATH', 'PNG library path', ''),
186 ('BF_TIFF', 'TIFF base path', ''),
187 ('BF_TIFF_INC', 'TIFF include path', ''),
189 (BoolOption('WITH_BF_ZLIB', 'Use ZLib if true', 'true')),
190 ('BF_ZLIB', 'ZLib base path', ''),
191 ('BF_ZLIB_INC', 'ZLib include path', ''),
192 ('BF_ZLIB_LIB', 'ZLib library', ''),
193 ('BF_ZLIB_LIBPATH', 'ZLib library path', ''),
195 (BoolOption('WITH_BF_INTERNATIONAL', 'Use Gettext and Freetype if true', 'true')),
197 ('BF_GETTEXT', 'gettext base path', ''),
198 ('BF_GETTEXT_INC', 'gettext include path', ''),
199 ('BF_GETTEXT_LIB', 'gettext library', ''),
200 ('BF_GETTEXT_LIBPATH', 'gettext library path', ''),
202 (BoolOption('WITH_BF_ICONV', 'Use iconv if true', 'true')),
203 ('BF_ICONV', 'iconv base path', ''),
204 ('BF_ICONV_INC', 'iconv include path', ''),
205 ('BF_ICONV_LIB', 'iconv library', ''),
206 ('BF_ICONV_LIBPATH', 'iconv library path', ''),
208 (BoolOption('WITH_BF_GAMEENGINE', 'Build with gameengine' , 'true')),
210 (BoolOption('WITH_BF_ODE', 'Use ODE if true', 'true')),
211 ('BF_ODE', 'ODE base path', ''),
212 ('BF_ODE_INC', 'ODE include path' , ''),
213 ('BF_ODE_LIB', 'ODE library', ''),
215 (BoolOption('WITH_BF_BULLET', 'Use Bullet if true', 'true')),
216 ('BF_BULLET', 'Bullet base dir', ''),
217 ('BF_BULLET_INC', 'Bullet include path', ''),
218 ('BF_BULLET_LIB', 'Bullet library', ''),
220 ('BF_SOLID', 'Solid base dir', '#/extern/solid'),
221 ('BF_SOLID_INC', 'Solid include path', ''),
222 ('BF_WINTAB', 'WinTab base dir', ''),
223 ('BF_WINTAB_INC', 'WinTab include dir', ''),
225 ##WITH_BF_NSPR = 'true'
226 ##BF_NSPR = $(LCGDIR)/nspr
227 ##BF_NSPR_INC = -I$(BF_NSPR)/include -I$(BF_NSPR)/include/nspr
228 ##BF_NSPR_LIB =
229 ### Uncomment the following line to use Mozilla inplace of netscape
230 ##CPPFLAGS += -DMOZ_NOT_NET
231 ### Location of MOZILLA/Netscape header files...
232 ##BF_MOZILLA = $(LCGDIR)/mozilla
233 ##BF_MOZILLA_INC = -I$(BF_MOZILLA)/include/mozilla/nspr -I$(BF_MOZILLA)/include/mozilla -I$(BF_MOZILLA)/include/mozilla/xpcom -I$(BF_MOZILLA)/include/mozilla/idl
234 ##BF_MOZILLA_LIB =
235 ### Will fall back to look in BF_MOZILLA_INC/nspr and BF_MOZILLA_LIB
236 ### if this is not set.
238 ### Be paranoid regarding library creation (do not update archives)
239 ##BF_PARANOID = 'true'
241 ### enable freetype2 support for text objects
242 ('BF_FREETYPE', 'Freetype base path', ''),
243 ('BF_FREETYPE_INC', 'Freetype include path', ''),
244 ('BF_FREETYPE_LIB', 'Freetype library', ''),
245 ('BF_FREETYPE_LIBPATH', 'Freetype library path', ''),
247 (BoolOption('WITH_BF_QUICKTIME', 'Use QuickTime if true', 'false')),
248 ('BF_QUICKTIME', 'QuickTime base path', ''),
249 ('BF_QUICKTIME_INC', 'QuickTime include path', ''),
250 ('BF_QUICKTIME_LIB', 'QuickTime library', ''),
251 ('BF_QUICKTIME_LIBPATH', 'QuickTime library path', ''),
253 (BoolOption('WITH_BF_STATICOPENGL', 'Use MESA if true', 'true')),
254 ('BF_OPENGL', 'OpenGL base path', ''),
255 ('BF_OPENGL_INC', 'OpenGL include path', ''),
256 ('BF_OPENGL_LIB', 'OpenGL libraries', ''),
257 ('BF_OPENGL_LIBPATH', 'OpenGL library path', ''),
258 ('BF_OPENGL_LIB_STATIC', 'OpenGL static libraries', ''),
259 ('BF_OPENGL_LINKFLAGS', 'OpenGL link flags', ''),
261 (BoolOption('WITH_BF_FTGL', 'Use FTGL if true', 'true')),
262 ('BF_FTGL', 'FTGL base path', ''),
263 ('BF_FTGL_INC', 'FTGL include path', ''),
264 ('BF_FTGL_LIB', 'FTGL libraries', ''),
266 (BoolOption('WITH_BF_PLAYER', 'Build blenderplayer if true', 'false')),
268 ('CFLAGS', 'C-compiler flags', ''),
269 ('CCFLAGS', 'C++-compiler flags', ''),
270 ('CPPFLAGS', 'Defines', ''),
271 ('REL_CFLAGS', 'C release flags', ''),
272 ('REL_CCFLAGS', 'C++ release flags', ''),
274 ('C_WARN', 'C warning flags', ''),
275 ('CC_WARN', 'C++ warning flags', ''),
277 ('LLIBS', 'Platform libs', ''),
278 ('PLATFORM_LINKFLAGS', 'Platform linkflags', ''),
280 (BoolOption('BF_PROFILE', 'Add profiling information if true', 'false')),
281 ('BF_PROFILE_FLAGS', 'Profiling flags', ''),
283 (BoolOption('BF_DEBUG', 'Add debug flags if true', 'false')),
284 ('BF_DEBUG_FLAGS', 'Debug flags', ''),
286 (BoolOption('BF_BSC', 'Create .bsc files (msvc only)', 'true')),
288 ('BF_BUILDDIR', 'Build dir', ''),
289 ('BF_INSTALLDIR', 'Installation dir', ''),
291 ('CC', 'C compiler to use', ''),
292 ('CXX', 'C++ compiler to use', ''),
294 (BoolOption('BF_BUILDINFO', 'Buildtime in splash if true', 'true')),
296 (BoolOption('BF_TWEAK_MODE', 'Enable tweak mode if true', 'false')),
297 (BoolOption('WITHOUT_BF_INSTALL', 'dont install if true', 'false')),
298 (BoolOption('BF_FANCY', 'Enable fancy output if true', 'true')),
300 ) # end of opts.AddOptions()
302 return localopts