SConstruct
branchpyrit
changeset 99 f3abdaa2e8fb
parent 95 ca7d4c665531
child 100 c005054bf4c1
equal deleted inserted replaced
98:64638385798a 99:f3abdaa2e8fb
    40 if sys.platform == 'win32':
    40 if sys.platform == 'win32':
    41 	tools = ['mingw']
    41 	tools = ['mingw']
    42 else:
    42 else:
    43 	tools = ['default']
    43 	tools = ['default']
    44 
    44 
    45 env = Environment(tools = tools, CPPPATH = ['.','#include'])
    45 env = Environment(tools = tools, CPPPATH = ['.','#include','#build/include'])
    46 
    46 
    47 opt = Options(['build/.optioncache'])
    47 vars = Variables(files=['build/.varscache'])
    48 opt.AddOptions(
    48 vars.AddVariables(
    49 	BoolOption('simd', 'allow SSE intrinsics', True),
    49 	BoolVariable('simd', 'allow SSE intrinsics', True),
    50 	('precision', 'floating point number precision (single/double)', "single"),
    50 	('precision', 'floating point number precision (single/double)', "single"),
    51 	('flags', 'add additional compiler flags', ""),
    51 	('flags', 'add additional compiler flags', ""),
    52 	BoolOption('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
    52 	BoolVariable('force_flags', "use only flags specified by 'flags' option (do not autodetect arch/sse flags)", False),
    53 	('ldflags', 'add additional linker flags', ""),
    53 	('ldflags', 'add additional linker flags', ""),
    54 	BoolOption('profile', "enable gcc's profiling support (-pg)", False),
    54 	BoolVariable('profile', "enable gcc's profiling support (-pg)", False),
    55 )
    55 )
    56 if env['PLATFORM'] == 'win32':
    56 if env['PLATFORM'] == 'win32':
    57 	opt.AddOptions(
    57 	vars.AddVariables(
    58 		BoolOption('mingw', 'use Mingw and GCC compiler, if available', False),
    58 		BoolVariable('mingw', 'use Mingw and GCC compiler, if available', False),
    59 		('pythonpath', 'path to Python installation',
    59 		('pythonpath', 'path to Python installation',
    60 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
    60 			'C:\\Python%c%c' % (sys.version[0], sys.version[2])),
    61 	)
    61 	)
    62 else:
    62 else:
    63 	opt.AddOptions(
    63 	vars.AddVariables(
    64 		BoolOption('intelc', 'use Intel C++ Compiler, if available', False),
    64 		BoolVariable('intelc', 'use Intel C++ Compiler, if available', False),
    65 	)
    65 	)
    66 
    66 
    67 
    67 
    68 opt.Update(env)
    68 vars.Update(env)
    69 opt.Save('build/.optioncache', env)
    69 vars.Save('build/.varscache', env)
    70 Help(opt.GenerateHelpText(env))
    70 Help(vars.GenerateHelpText(env))
    71 
    71 
       
    72 if env.GetOption('help') == True or env.GetOption('clean') == True:
       
    73     Return()
    72 
    74 
    73 ### configure
    75 ### configure
    74 
    76 
    75 platform = 'unknown'
    77 platform = 'unknown'
    76 def CheckPlatform(context):
    78 def CheckPlatform(context):
   100 	return intelc
   102 	return intelc
   101 
   103 
   102 def CheckGCC(context):
   104 def CheckGCC(context):
   103 	global gcc, gccversion
   105 	global gcc, gccversion
   104 	context.Message('Checking for GCC compiler... ')
   106 	context.Message('Checking for GCC compiler... ')
   105 	gcc = "g++" in env['TOOLS']
   107 	testenv = Environment()
       
   108 	gcc = "g++" in testenv['TOOLS']
   106 	if gcc:
   109 	if gcc:
   107 		gccversion = env['CCVERSION']
   110 		gccversion = testenv['CCVERSION']
   108 		context.Result(gccversion)
   111 		context.Result(gccversion)
   109 	else:
   112 	else:
   110 		gccversion = ''
   113 		gccversion = ''
   111 		context.Result(False)
   114 		context.Result(False)
   112 	return gcc
   115 	return gcc
   131 	(cpu, cpuflags_gcc, cpuflags_intelc) = os.popen('tools'+os.sep+'cpuflags %s %s'
   134 	(cpu, cpuflags_gcc, cpuflags_intelc) = os.popen('tools'+os.sep+'cpuflags %s %s'
   132 		% (''.join(gccversion.rsplit('.',1)), intelcversion) ).read().split('\n')[:3]
   135 		% (''.join(gccversion.rsplit('.',1)), intelcversion) ).read().split('\n')[:3]
   133 	context.Result(cpu)
   136 	context.Result(cpu)
   134 	return True
   137 	return True
   135 
   138 
   136 conf_dir = "#/build/.sconf_temp"
   139 conf_dir = "#build/.sconf_temp"
   137 log_file="#/build/config.log"
   140 log_file="#build/config.log"
   138 config_h="#/include/config.h"
   141 config_h="#build/include/config.h"
   139 conf = Configure(env, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
   142 conf = Configure(env, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
       
   143     clean=False, help=False,
   140 	custom_tests = {
   144 	custom_tests = {
   141 		'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags,
   145 		'CheckPlatform' : CheckPlatform, 'CheckCPUFlags' : CheckCPUFlags,
   142 		'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC, 'CheckMSVC' : CheckMSVC})
   146 		'CheckIntelC' : CheckIntelC, 'CheckGCC' : CheckGCC, 'CheckMSVC' : CheckMSVC})
   143 conf.CheckPlatform()
   147 conf.CheckPlatform()
   144 
   148 
   229 	print 'Error: Cannot build without pthread.'
   233 	print 'Error: Cannot build without pthread.'
   230 	Exit(1)
   234 	Exit(1)
   231 
   235 
   232 
   236 
   233 # configure libpng
   237 # configure libpng
   234 if conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
   238 if conf.CheckLibWithHeader('zlib', 'zlib.h', 'C') and conf.CheckLibWithHeader('libpng', 'png.h', 'C'):
   235 	conf.Define('HAVE_PNG')
   239 	conf.Define('HAVE_PNG')
   236 
   240 
   237 env = conf.Finish()
   241 env = conf.Finish()
   238 
   242 
   239 
   243 
   241 pyenv = env.Clone()
   245 pyenv = env.Clone()
   242 have_python = True
   246 have_python = True
   243 if platform == 'win32':
   247 if platform == 'win32':
   244 	pythonver = '%c%c' % (sys.version[0], sys.version[2])
   248 	pythonver = '%c%c' % (sys.version[0], sys.version[2])
   245 	pythonlib = 'python'+pythonver
   249 	pythonlib = 'python'+pythonver
   246 	pythonpath = [env['pythonpath'],
   250 	pythonpath = [env['pythonpath']]
   247 		'C:\\Program Files\\Python'+pythonver]
       
   248 	pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath])
   251 	pyenv.Append(CPPPATH=[s+'\\include' for s in pythonpath])
   249 	pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath])
   252 	pyenv.Append(LIBPATH=[s+'\\libs' for s in pythonpath])
   250 	pyenv.Replace(SHLIBSUFFIX='.pyd')
   253 	pyenv.Replace(SHLIBSUFFIX='.pyd')
   251 	conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h)
   254 	conf = Configure(pyenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
       
   255 	                 clean=False, help=False)
   252 	if not conf.CheckLib(pythonlib):
   256 	if not conf.CheckLib(pythonlib):
   253 		have_python = False
   257 		have_python = False
   254 	pyenv = conf.Finish()
   258 	pyenv = conf.Finish()
   255 else:
   259 else:
   256 	try:
   260 	try:
   284 	else:
   288 	else:
   285 		context.Result("no (some demos won't be built)")
   289 		context.Result("no (some demos won't be built)")
   286 	return False
   290 	return False
   287 
   291 
   288 conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
   292 conf = Configure(sdlenv, conf_dir=conf_dir, log_file=log_file, config_h=config_h,
       
   293     clean=False, help=False,
   289 	custom_tests = {'CheckSDL' : CheckSDL} )
   294 	custom_tests = {'CheckSDL' : CheckSDL} )
   290 have_sdl = conf.CheckSDL()
   295 have_sdl = conf.CheckSDL()
   291 sdlenv = conf.Finish()
   296 sdlenv = conf.Finish()
   292 
   297 
   293 
   298