#coded for Python 2.7.10

#builds all spatial audio sample projects
import os
import sys
from python_common import projectNames

fileAbsolutePath = os.path.dirname(os.path.realpath(__file__))

if len(sys.argv) != 2:
	print "This script must be passed the absolute path of the destination directory.  For example:\n%s C:\\spatialaudio " % __file__
	exit()

destinationAbsolutePath = sys.argv[1]
rootPath = "%s\.." % fileAbsolutePath

#copy the entire directory except the samples subdirectory and some irrelevant Visual Studio files
os.system(r"robocopy %s %s /xd *samples* /xd *.vs* /xf *.db /xf /S" % (rootPath, destinationAbsolutePath))

#copy each sample individually, ignoring unnecessary directories
rootSamplesPath = "%s\samples" % rootPath
destinationSamplesPath = "%s\samples" % destinationAbsolutePath
for projectName in projectNames:
	os.system(r"robocopy %s\%s %s\%s /xd bin /xd gen /xd obj /S" % (rootSamplesPath, projectName, destinationSamplesPath, projectName))
	
#now copy all other subdirectories in samples (except the just-copied sample directories themselves)
ignoreString = ""
projectNameIndex=0
for projectName in projectNames:
	ignoreString += r"/xd %s " % (projectNames[projectNameIndex])
	projectNameIndex += 1

os.system(r"robocopy %s %s %s /S" % (rootSamplesPath, destinationSamplesPath, ignoreString))