###
#This file is a part of the NVDA project.
#URL: http://www.nvda-project.org/
#Copyright 2006-2010 NVDA contributers.
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2.0, as published by
#the Free Software Foundation.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#This license can be found at:
#http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
###

defaultTargetArchitectures=['x86','x86_64']

#User build variables
vars=Variables()
vars.Add(BoolVariable('release','Set to true to build a release version',False))
vars.Add(EnumVariable('logLevel','The level of logging you wish to see, lower is more verbose','15',allowed_values=[str(x) for x in xrange(60)]))
vars.Add(ListVariable('targetArchitectures','Which architectures  to build libraries for','all',defaultTargetArchitectures))

#A very simple base environment only for processing variables
baseEnv=Environment(tools=[],variables=vars)

#Check for any unknown variables
unknown=vars.UnknownVariables().keys()
if len(unknown)>0:
	print "Unknown commandline variables: %s"%unknown
	Exit(1)

#Build nvdaHelper for needed architectures
for arch in baseEnv['targetArchitectures']: 
	try:
		env=baseEnv.Clone(TARGET_ARCH=arch,tools=['windowsSdk','midl','msrpc','boost','default'],variables=vars)
		print "Building for %s"%arch 
	except:
		print "Error setting up %s build environment"%arch 
		continue
	env.SConscript('archBuild_sconscript',exports=['env'],variant_dir='build/%s'%arch)
