예제 #1
0
def main(workingDir):
	
	#
	# Make sure the tool is built
	#
	
	toolfolder = os.path.dirname(workingDir)
	destfolder = os.path.join(toolfolder,'bin')
	toolfolder = os.path.join(toolfolder,'tools','bin')
	soundexename = burger.gettoolpath(toolfolder,'packsound',True)
	videoexename = burger.gettoolpath(toolfolder,'packvideo',True)
			
	#
	# Prepare for the output
	#
	
	burger.createfolderifneeded(destfolder)

	#
	# Copy the data files
	#
	
	srcfolder = os.path.join(workingDir,'movie')
	error = convertdata(soundexename,videoexename,srcfolder,destfolder)
	
	if error!=0:
		return error
		
	srcfolder = os.path.join(workingDir,'death')
	error = convertdata(soundexename,videoexename,srcfolder,destfolder)
	
	return error
예제 #2
0
def buildcodewarriormac(fileName,verbose,ignoreerrors):
	fileNamelower = fileName.lower()
	# Codewarrior version was not detected for Mac OSX
	if 'wii' in fileNamelower:
		return 0
	if 'nds' in fileNamelower:
		return 0
	if 'gcn' in fileNamelower:
		return 0

	if 'c10' in fileNamelower:
		cwfile = '/Applications/Metrowerks CodeWarrior 10.0/Metrowerks CodeWarrior/CodeWarrior IDE 10'
	elif 'cw9' in fileNamelower:
		cwfile = '/Applications/Metrowerks CodeWarrior 9.0/Metrowerks CodeWarrior/CodeWarrior IDE 9.6'
	else:
		print 'Codewarrior version was not detected'
		return 0

	mytempdir = os.path.join(os.path.dirname(fileName),'temp')
	errorFile = os.path.basename(fileName)
	errorList = os.path.splitext(errorFile)
	errorFile = os.path.join(mytempdir,errorList[0] + '.err')

	# Make the output folder for errors (If needed)

	burger.createfolderifneeded(mytempdir)

	# Create the build command

	cmd = 'cmdide -proj -bcwef "' + errorFile + '" -y "' + cwfile + '" -z Everything "' + fileName + '"'
	if verbose==True:
		print cmd
	sys.stdout.flush()
	error = subprocess.call(cmd,cwd=os.path.dirname(fileName),shell=True)
	return error
예제 #3
0
def buildcodewarriormac(fileName, verbose, ignoreerrors):
    fileNamelower = fileName.lower()
    # Codewarrior version was not detected for Mac OSX
    if 'wii' in fileNamelower:
        return 0
    if 'nds' in fileNamelower:
        return 0
    if 'gcn' in fileNamelower:
        return 0

    if 'c10' in fileNamelower:
        cwfile = '/Applications/Metrowerks CodeWarrior 10.0/Metrowerks CodeWarrior/CodeWarrior IDE 10'
    elif 'cw9' in fileNamelower:
        cwfile = '/Applications/Metrowerks CodeWarrior 9.0/Metrowerks CodeWarrior/CodeWarrior IDE 9.6'
    else:
        print 'Codewarrior version was not detected'
        return 0

    mytempdir = os.path.join(os.path.dirname(fileName), 'temp')
    errorFile = os.path.basename(fileName)
    errorList = os.path.splitext(errorFile)
    errorFile = os.path.join(mytempdir, errorList[0] + '.err')

    # Make the output folder for errors (If needed)

    burger.createfolderifneeded(mytempdir)

    # Create the build command

    cmd = 'cmdide -proj -bcwef "' + errorFile + '" -y "' + cwfile + '" -z Everything "' + fileName + '"'
    if verbose == True:
        print cmd
    sys.stdout.flush()
    error = subprocess.call(cmd, cwd=os.path.dirname(fileName), shell=True)
    return error
예제 #4
0
def main(workingDir):

    #
    # Make sure the tool is built
    #

    toolfolder = os.path.dirname(workingDir)
    destfolder = os.path.join(toolfolder, 'bin')
    toolfolder = os.path.join(toolfolder, 'tools', 'bin')
    soundexename = burger.gettoolpath(toolfolder, 'packsound', True)
    videoexename = burger.gettoolpath(toolfolder, 'packvideo', True)

    #
    # Prepare for the output
    #

    burger.createfolderifneeded(destfolder)

    #
    # Copy the data files
    #

    srcfolder = os.path.join(workingDir, 'movie')
    error = convertdata(soundexename, videoexename, srcfolder, destfolder)

    if error != 0:
        return error

    srcfolder = os.path.join(workingDir, 'death')
    error = convertdata(soundexename, videoexename, srcfolder, destfolder)

    return error
예제 #5
0
def main(workingDir):

	#
	# Locate the SDKs folder so the files can be copied there
	#
	
	sdks = burger.getsdksfolder()

	#
	# Files to copy if changed
	#
	
	batchfiles = [
		'build.cmd',
		'candle.cmd',
		'clean.cmd',
		'disasmx36.cmd',
		'doxygen.cmd',
		'getp4changenumber.cmd',
		'git.cmd',
		'light.cmd',
		'makeprojects.cmd',
		'p4.cmd',
		'rebuild.cmd',
		'wdisasm.cmd'
		]
	
	#
	# Ensure the destination directory exists
	#
	
	destfolder = os.path.join(sdks,'windows','bin','x86')
	burger.createfolderifneeded(destfolder)

	#
	# Copy all the changed files
	#

	error = 0
	for item in batchfiles:
		
		#
		# If the file had changed, update it in perforce
		#
		
		sourcefile = os.path.join(workingDir,item)
		destfile = os.path.join(destfolder,item)
		if os.path.isfile(destfile)!=True or \
			burger.comparefiles(sourcefile,destfile)!=True:
			
			error = burger.copyfileandcheckoutifneeded(sourcefile,destfile)
			if error!=0:
				break

	return error
예제 #6
0
def buildcodewarriorwindows(fileName,verbose,ignoreerrors):

	fileNamelower = fileName.lower()
	# Don't use Codewarrior for Mac
	if 'mac' in fileNamelower:
		return 0
		
	# These targets build on Windows hosts
	if 'wii' in fileNamelower:
		print 'Can\'t build ' + fileName + ' yet!'
		return 0
	elif 'nds' in fileNamelower:
		print 'Can\'t build ' + fileName + ' yet!'
		return 0
	elif 'gcn' in fileNamelower:
		print 'Can\'t build ' + fileName + ' yet!'
		return 0
	elif 'w32' in fileNamelower or 'win' in fileNamelower:
		cwfile = os.getenv('CWFolder')
		if cwfile==None:
			print 'Can\'t build ' + fileName + '! CWFolder not set to Codewarrior 9.4 for Windows!'
			return 0
		# Note: CmdIDE is preferred, however, Codewarrior 9.4 has a bug
		# that it will die horribly if the pathname to it
		# has a space, so ide is used instead.
		cwfile = os.path.join(cwfile,'Bin','ide')
	else:
		print 'Codewarrior version was not detected for ' + fileName
		return 0

	mytempdir = os.path.join(os.path.dirname(fileName),'temp')
	errorFile = os.path.basename(fileName)
	errorList = os.path.splitext(errorFile)
	errorFile = os.path.join(mytempdir,errorList[0] + '.err')

	# Make the output folder for errors (If needed)

	burger.createfolderifneeded(mytempdir)

	# Create the build command
	# /s New instance
	# /t Project name
	# /b Build
	# /c close the project after completion
	# /q Close Codewarrior on completion
	
	cmd = '"' + cwfile + '" "' + fileName + '" /t Everything /s /c /q /b'
	if verbose==True:
		print cmd
	sys.stdout.flush()
	error = subprocess.call(cmd,cwd=os.path.dirname(fileName),shell=True)
	return error
예제 #7
0
def buildcodewarriorwindows(fileName, verbose, ignoreerrors):

    fileNamelower = fileName.lower()
    # Don't use Codewarrior for Mac
    if 'mac' in fileNamelower:
        return 0

    # These targets build on Windows hosts
    if 'wii' in fileNamelower:
        print 'Can\'t build ' + fileName + ' yet!'
        return 0
    elif 'nds' in fileNamelower:
        print 'Can\'t build ' + fileName + ' yet!'
        return 0
    elif 'gcn' in fileNamelower:
        print 'Can\'t build ' + fileName + ' yet!'
        return 0
    elif 'w32' in fileNamelower or 'win' in fileNamelower:
        cwfile = os.getenv('CWFolder')
        if cwfile == None:
            print 'Can\'t build ' + fileName + '! CWFolder not set to Codewarrior 9.4 for Windows!'
            return 0
        # Note: CmdIDE is preferred, however, Codewarrior 9.4 has a bug
        # that it will die horribly if the pathname to it
        # has a space, so ide is used instead.
        cwfile = os.path.join(cwfile, 'Bin', 'ide')
    else:
        print 'Codewarrior version was not detected for ' + fileName
        return 0

    mytempdir = os.path.join(os.path.dirname(fileName), 'temp')
    errorFile = os.path.basename(fileName)
    errorList = os.path.splitext(errorFile)
    errorFile = os.path.join(mytempdir, errorList[0] + '.err')

    # Make the output folder for errors (If needed)

    burger.createfolderifneeded(mytempdir)

    # Create the build command
    # /s New instance
    # /t Project name
    # /b Build
    # /c close the project after completion
    # /q Close Codewarrior on completion

    cmd = '"' + cwfile + '" "' + fileName + '" /t Everything /s /c /q /b'
    if verbose == True:
        print cmd
    sys.stdout.flush()
    error = subprocess.call(cmd, cwd=os.path.dirname(fileName), shell=True)
    return error
예제 #8
0
def builddoxygen(fullpathname, verbose):

    # Is Doxygen installed?

    doxygenpath = burger.whereisdoxygen()
    if doxygenpath == None:
        return 0

    # Make the output folder for errors (If needed)

    tempdir = os.path.join(os.path.dirname(fullpathname), 'temp')
    burger.createfolderifneeded(tempdir)
    bindir = os.path.join(os.path.dirname(fullpathname), 'bin')
    burger.createfolderifneeded(bindir)
    # Location of the log file
    errorsfile = os.path.join(bindir, 'doxygenerrors.txt')

    # Create the build command
    if burger.getmachosttype() != False:
        # The mac version requires the file to have Linux line feeds!!!
        tempdox = fullpathname + '.tempfile'
        cmd = 'addlf -l "' + fullpathname + '" "' + tempdox + '"'
        if verbose == True:
            print cmd
        subprocess.call(cmd, cwd=os.path.dirname(fullpathname), shell=True)
        cmd = '"' + os.path.join(
            doxygenpath) + '" "' + tempdox + '" 2> "' + errorsfile + '"'
        if verbose == True:
            print cmd
        error = subprocess.call(cmd,
                                cwd=os.path.dirname(fullpathname),
                                shell=True)
        os.remove(tempdox)

    else:
        cmd = '"' + os.path.join(
            doxygenpath) + '" "' + fullpathname + '" 2> "' + errorsfile + '"'
        if verbose == True:
            print cmd
        error = subprocess.call(cmd,
                                cwd=os.path.dirname(fullpathname),
                                shell=True)

    # If the error log has nothing, delete it
    if os.stat(errorsfile).st_size == 0:
        os.remove(errorsfile)

    return error
예제 #9
0
def main(workingDir):

    #
    # The tool to build a DOS app only exists under windows
    #

    if burger.hostmachine() != 'windows':
        return 0

    #
    # Create the output folder
    #

    binfolder = os.path.join(workingDir, 'bin')
    burger.createfolderifneeded(binfolder)

    #
    # Build if needed
    #

    comfile = os.path.join(binfolder, 'resetega.com')
    sourcefile = os.path.join(workingDir, 'resetega.i86')

    if burger.isthesourcenewer(sourcefile, comfile):

        #
        # Use jwasm to create a COM file
        #

        cmd = 'jwasm -bin -Fo"' + comfile + '" "' + sourcefile + '"'
        error = subprocess.call(cmd, cwd=workingDir, shell=True)
        if error != 0:
            return error

        #
        # Update in perforce
        #

        sdks = burger.getsdksfolder()
        destfile = os.path.join(sdks, 'dos', 'bin', 'resetega.com')
        error = burger.copyfileandcheckoutifneeded(comfile, destfile)
        if error != 0:
            return 0

    return 0
예제 #10
0
def main(workingDir):

	#
	# The tool to build a DOS app only exists under windows
	#
	
	if burger.hostmachine()!='windows':
		return 0
		
	#
	# Create the output folder
	#
	
	binfolder = os.path.join(workingDir,'bin')
	burger.createfolderifneeded(binfolder)

	# 
	# Build if needed
	#
	
	comfile = os.path.join(binfolder,'resetega.com')
	sourcefile = os.path.join(workingDir,'resetega.i86')

	if burger.isthesourcenewer(sourcefile,comfile):

		#
		# Use jwasm to create a COM file
		#

		cmd = 'jwasm -bin -Fo"' + comfile + '" "' + sourcefile + '"'
		error = subprocess.call(cmd,cwd=workingDir,shell=True)
		if error!=0:
			return error
	
		#
		# Update in perforce
		#
		
		sdks = burger.getsdksfolder();
		destfile = os.path.join(sdks,'dos','bin','resetega.com')
		error = burger.copyfileandcheckoutifneeded(comfile,destfile)
		if error!=0:
			return 0
	
	return 0
예제 #11
0
def builddoxygen(fullpathname,verbose):

	# Is Doxygen installed?

	doxygenpath = burger.whereisdoxygen()
	if doxygenpath==None:
		return 0

	# Make the output folder for errors (If needed)

	tempdir = os.path.join(os.path.dirname(fullpathname),'temp')
	burger.createfolderifneeded(tempdir)
	bindir = os.path.join(os.path.dirname(fullpathname),'bin')
	burger.createfolderifneeded(bindir)
	# Location of the log file
	errorsfile = os.path.join(bindir,'doxygenerrors.txt')

	# Create the build command
	if burger.getmachosttype()!=False:
		# The mac version requires the file to have Linux line feeds!!!
		tempdox = fullpathname + '.tempfile'
		cmd = 'addlf -l "' + fullpathname +'" "' + tempdox + '"'
		if verbose==True:
			print cmd
		subprocess.call(cmd,cwd=os.path.dirname(fullpathname),shell=True)
		cmd = '"' + os.path.join(doxygenpath) + '" "' + tempdox + '" 2> "' + errorsfile + '"'
		if verbose==True:
			print cmd
		error = subprocess.call(cmd,cwd=os.path.dirname(fullpathname),shell=True)
		os.remove(tempdox)
		
	else:
		cmd = '"' + os.path.join(doxygenpath) + '" "' + fullpathname + '" 2> "' + errorsfile + '"'
		if verbose==True:
			print cmd
		error = subprocess.call(cmd,cwd=os.path.dirname(fullpathname),shell=True)
	
	# If the error log has nothing, delete it
	if os.stat(errorsfile).st_size==0:
		os.remove(errorsfile)
		
	return error
예제 #12
0
def main(workingDir):

    #
    # Create the output folder if needed
    #

    toolfolder = os.path.dirname(workingDir)
    destfolder = os.path.join(toolfolder, 'bin')
    burger.createfolderifneeded(destfolder)

    #
    # Update the map files
    #

    filelist = [
        ['icon', 'spaceace.icon#ca0000'],  # Icon file
        ['buildall', 'SpaceAce#b3db03'],  # Application file
        ['spaceacerez', 'SpaceAce#b3db03r']  # Resource file
    ]

    error = 0

    for item in filelist:
        src = os.path.join(workingDir, item[0] + '.a65')
        dest = os.path.join(destfolder, item[1])
        if burger.isthesourcenewer(src, dest) == True:
            cmd = 'a65816 . ' + item[0] + '.a65'
            error = subprocess.call(cmd, cwd=workingDir, shell=True)
            if error != 0:
                return error

    #
    # Do some cleanup
    #

    burger.deletefileifpresent(os.path.join(workingDir,
                                            '_FileInformation.txt'))
    return error
예제 #13
0
def main(workingDir):
	
	#
	# Create the output folder if needed
	#
	
	toolfolder = os.path.dirname(workingDir)
	destfolder = os.path.join(toolfolder,'bin')
	burger.createfolderifneeded(destfolder)

	#
	# Update the map files
	#

	filelist = [
		['icon','spaceace.icon#ca0000'],	# Icon file
		['buildall','SpaceAce#b3db03'],		# Application file
		['spaceacerez','SpaceAce#b3db03r']	# Resource file
	]

	error = 0
	
	for item in filelist:
		src = os.path.join(workingDir,item[0] + '.a65')
		dest = os.path.join(destfolder,item[1])
		if burger.isthesourcenewer(src,dest)==True:
			cmd = 'a65816 . ' + item[0] + '.a65'
			error = subprocess.call(cmd,cwd=workingDir,shell=True)
			if error!=0:
				return error

	#
	# Do some cleanup
	#
	
	burger.deletefileifpresent(os.path.join(workingDir,'_FileInformation.txt'))
	return error
예제 #14
0
def main(workingDir):

	#
	# Was Burgerlib already installed?
	#
	
	sdks = burger.getsdksfolder()

	#
	# Update the changelist header
	#
	
	burger.makeversionheader(workingDir,os.path.join(workingDir,'source','version.h'))

	#
	# Folders for all the target operating systems supported
	#
	
	destinations = [
		'windows',
		'dos',
		'mac',
		'macosx',
		'linux',
		'beos',
		'ps2',
		'ps3',
		'ps4',
		'gamecube',
		'wii',
		'dsi',
		'xbox',
		'xbox360',
		'xboxone',
		'ios',
		'android',
		'shield',
		'ouya']
		
	
	#
	# Ensure the destination directories exist
	#
	
	for dest in destinations:
		burger.createfolderifneeded(os.path.join(sdks,dest,'burgerlib'))

	
	#
	# Ensure the output folder exists
	#
	
	outputfolder = os.path.join(workingDir,'bin')
	burger.createfolderifneeded(outputfolder)

	#
	# Create the super header
	#

	
	burgerhfile = os.path.join(outputfolder,'burger.h')
	cmd = 'makeheader "' + os.path.join(workingDir,'source','templateburgerbase.h') + '" "' + burgerhfile + '"'
	error = subprocess.call(cmd,cwd=workingDir,shell=True)
	if error==0:
	
		# Was there a change in the output?
	
		windowsburgerlib = os.path.join(sdks,'windows','burgerlib')
		testfile = os.path.join(windowsburgerlib,'burger.h')
		if os.path.isfile(testfile)!=True or \
			burger.comparefiles(burgerhfile,testfile)!=True:
			
			# Copy only if changed
	
			for dest in destinations:
				destfolder = os.path.join(sdks,dest,'burgerlib')
				error = burger.copyfileandcheckoutifneeded(burgerhfile,os.path.join(destfolder,'burger.h'))
				if error!=0:
					break


	#
	# Was there a change in special headers?
	#
	
	if error==0:
		specialheaders = [
			'brstartup.h',
			'brgl.h',
			'brglext.h',
			'brglut.h',
			'brglxext.h'
			]
	
		for item in specialheaders:
			brstartuphfile = os.path.join(workingDir,'source',item)
			testfile = os.path.join(sdks,'windows','burgerlib',item)
			if os.path.isfile(testfile)!=True or \
				burger.comparefiles(brstartuphfile,testfile)==False:
				for dest in destinations:
					error = burger.copyfileandcheckoutifneeded(brstartuphfile,os.path.join(sdks,dest,'burgerlib',item))
					if error!=0:
						break
	
	#
	# Did any of the Mac Carbon/Classic resource files change?
	#
	
	if error==0:
		macosfolder = os.path.join(workingDir,'source','mac')
		destfolder = os.path.join(sdks,'mac','burgerlib')
		filedata = os.listdir(macosfolder)
		for file in filedata:
			tfile = file.lower()
			if tfile.endswith('.r'):
				destfile = os.path.join(destfolder,file)
				sourcefile = os.path.join(macosfolder,file)
				if os.path.isfile(destfile)!=True or \
					burger.comparefiles(sourcefile,destfile)==False:
					error = burger.copyfileandcheckoutifneeded(sourcefile,destfile)
					if error!=0:
						break
		
	return error
예제 #15
0
def generate(solution):
	import makeprojects
	
	#
	# Find the files to put into the project
	#
	
	codefiles,includedirectories = solution.getfilelist()

	#
	# Configure the xcode writer to the type
	# of solution requested
	#
	
	solution.xcode.defaults(solution)
	
	#
	# Ensure the slashes are correct for XCode
	#
	
	for item in codefiles:
		item.filename = burger.converttolinuxslashes(item.filename)

	#
	# Determine the ide and target type for the final file name
	#

	idecode = solution.getidecode()
	platformcode = solution.getplatformcode()
	xcodeprojectfile = Project(solution.projectname,idecode,platformcode)
	rootproject = xcodeprojectfile.pbxprojects[0]
	
	#
	# Let's create the solution file!
	#
	
	solutionfoldername = os.path.join(solution.workingDir,xcodeprojectfile.projectnamecode + '.xcodeproj')
	burger.createfolderifneeded(solutionfoldername)
	projectfilename = os.path.join(solutionfoldername,'project.pbxproj')
	
	#
	# Add the configuration file reference (or not)
	#
	
	if solution.xcode.configfilename!=None:
		configfilereference = xcodeprojectfile.addfilereference(solution.xcode.configfilename,'text.xcconfig')
	else:
		configfilereference = None
		
	#
	# Add the frameworks to the build list
	#

	for framework in solution.xcode.frameworks:
		item = makeprojects.SourceFile(framework,'','frameworks')
		codefiles.append(item)	

	#
	# Insert all of the files found into the file references
	#
	
	for item in codefiles:
		# Remove unsupported file types
		if item.type!='windowsresource' and \
			item.type!='macresource' and \
			item.type!='hlsl':
			xcodeprojectfile.addfilereference(item.filename,item.type)

	#
	# What's the final output file?
	#
	
	if solution.kind=='library':
		if solution.platform=='ios':
			libextension = 'ios.a'
		else:
			libextension = 'osx.a'
		outputfilereference = xcodeprojectfile.addfilereference('lib' + solution.projectname + idecode + libextension,'lib')
	else:
		if solution.kind=='game':
			outputfilereference = xcodeprojectfile.addfilereference(solution.projectname + '.app','exe')
		else:
			outputfilereference = xcodeprojectfile.addfilereference(solution.projectname,'exe')
	
	#
	# If a fat library, add references for dev and sim targets
	#

	ioslibrary = False
	if solution.platform=='ios':
		if solution.kind=='library':
			ioslibrary = True
	
	if ioslibrary == True:
		devfilereference = xcodeprojectfile.addfilereference('lib' + solution.projectname + idecode + 'dev.a','lib')
		simfilereference = xcodeprojectfile.addfilereference('lib' + solution.projectname + idecode + 'sim.a','lib')
		
		#
		# Two targets for "fat" libraries
		#
		
		buildphase1 = xcodeprojectfile.addsourcesbuildphase(devfilereference)
		buildphase2 = xcodeprojectfile.addsourcesbuildphase(simfilereference)
		framephase1 = xcodeprojectfile.addframeworksbuildphase(devfilereference)
		framephase2 = xcodeprojectfile.addframeworksbuildphase(simfilereference)
		
		#
		# Add source files to compile for the ARM and the Intel libs
		#
		
		for item in xcodeprojectfile.pbxfilereferences:
			if item.type=='cpp' or item.type=='glsl':
				buildphase1.append(xcodeprojectfile.addbuildfile(item,devfilereference))
				buildphase2.append(xcodeprojectfile.addbuildfile(item,simfilereference))
			elif item.type=='frameworks':
				framephase1.append(xcodeprojectfile.addbuildfile(item,devfilereference))
				framephase2.append(xcodeprojectfile.addbuildfile(item,simfilereference))

	else:
		devfilereference = None
		simfilereference = None
		buildphase1 = xcodeprojectfile.addsourcesbuildphase(outputfilereference)
		framephase1 = xcodeprojectfile.addframeworksbuildphase(outputfilereference)
		for item in xcodeprojectfile.pbxfilereferences:
			if item.type=='cpp' or item.type=='glsl':
				buildphase1.append(xcodeprojectfile.addbuildfile(item,outputfilereference))
			elif item.type=='frameworks':
				framephase1.append(xcodeprojectfile.addbuildfile(item,outputfilereference))
	
	#
	# Create the root file group and the Products group
	#
	
	groupproducts = xcodeprojectfile.addgroup('Products',None)
	
	grouproot = xcodeprojectfile.addgroup(xcodeprojectfile.projectname,None)
	grouproot.appendgroup(groupproducts)

	# No frameworks group unless one is warranted
	
	frameworksgroup = None
		
	#
	# Insert all the file references into groups
	#
	
	for item in xcodeprojectfile.pbxfilereferences:
		# Products go into a special group
		if item.type=='exe':
			groupproducts.append(item)
		elif item.type=='lib':
			groupproducts.append(item)
		elif item.type=='frameworks':
			
			# Create the group if needed
			
			if frameworksgroup==None:
				frameworksgroup = xcodeprojectfile.addgroup('Frameworks',None)
				grouproot.appendgroup(frameworksgroup)
			
			frameworksgroup.append(item)
		else:
			# Isolate the path
			index = item.filename.rfind('/')
			if index==-1:
				# Put in the root group
				grouproot.append(item)
			else:
				# Separate the path and name
				base = item.filename[index+1:]
				path = item.filename[0:index]
				#
				# See if a group already exists
				#
				found = False
				for matchgroup in xcodeprojectfile.pbxgroups:
					if matchgroup.path!=None and matchgroup.path==path:
						# Add to a pre-existing group
						matchgroup.append(item)
						found = True
						break
				if found==True:
					continue
				
				# Group not found. Iterate and create the group
				# May need multiple levels
				
				#
				# Hack to remove preceding ../ entries
				#
				
				if path.startswith('../'):
					index = 3
				elif path.startswith('../../'):
					index = 6
				else:
					index = 0
				
				notdone = True
				previousgroup = grouproot
				while notdone:
					endindex = path[index:].find('/')
					if endindex==-1:
						# Final level, create group and add reference
						matchgroup = xcodeprojectfile.addgroup(path[index:],path)
						matchgroup.append(item)
						previousgroup.appendgroup(matchgroup)
						notdone = False
					else:
						#
						# See if a group already exists
						#
						temppath = path[0:index+endindex]
						found = False
						for matchgroup in xcodeprojectfile.pbxgroups:
							if matchgroup.path==None:
								continue
							if matchgroup.path==temppath:
								found = True
								break
						
						if found!=True:
							matchgroup = xcodeprojectfile.addgroup(path[index:index+endindex],temppath)
							previousgroup.appendgroup(matchgroup)
						previousgroup = matchgroup
						index = index+endindex+1
		
	#
	# Create the config list for the root project
	#
	
	configlistref = xcodeprojectfile.addxcconfigurationlist('PBXProject',xcodeprojectfile.projectnamecode)
	for item in solution.configurations:
		configlistref.configurations.append(xcodeprojectfile.addxcbuildconfigurationlist(item,configfilereference,configlistref,None,False))
	rootproject.configlistref = configlistref
	rootproject.rootgroup = grouproot

	#
	# Create the PBXNativeTarget config chunks
	#
	
	sdkroot = None
	if solution.platform=='ios':
		sdkroot = 'iphoneos'

	if solution.kind=='library':
		outputtype = 'com.apple.product-type.library.static'
	elif solution.kind=='screensaver':
		outputtype = 'com.apple.product-type.bundle'
	elif solution.kind=='game':
		outputtype = 'com.apple.product-type.application'
	else:
		outputtype = 'com.apple.product-type.tool'
	
	#
	# For a normal project, attach the config to a native target and we're done
	#
	
	if ioslibrary==False:
		configlistref = xcodeprojectfile.addxcconfigurationlist('PBXNativeTarget',xcodeprojectfile.projectname)
		install = False
		if solution.kind=='game':
			install = True
		for item in solution.configurations:
			configlistref.configurations.append(xcodeprojectfile.addxcbuildconfigurationlist(item,None,configlistref,sdkroot,install))
		if solution.kind=='library':
			finalname = xcodeprojectfile.projectnamecode
		else:
			finalname = xcodeprojectfile.projectname
		nativetarget1 = xcodeprojectfile.addnativeproject(finalname,outputfilereference,xcodeprojectfile.projectname,outputtype)
		nativetarget1.configlistref = configlistref
		rootproject.append(nativetarget1)
		nativetarget1.append(buildphase1.uuid,'Sources')
		nativetarget1.append(framephase1.uuid,'Frameworks')

	#
	# For fat binary iOS projects, it's a lot messier
	#
	
	else:
		targetname = xcodeprojectfile.projectnamecode
		configlistref = xcodeprojectfile.addxcconfigurationlist('PBXNativeTarget',targetname)
		for item in solution.configurations:
			configlistref.configurations.append(xcodeprojectfile.addxcbuildconfigurationlist(item,None,configlistref,None,False))
		nativetarget1 = xcodeprojectfile.addnativeproject(targetname,outputfilereference,xcodeprojectfile.projectname,outputtype)
		nativetarget1.configlistref = configlistref
		rootproject.append(nativetarget1)

		targetname = solution.projectname + idecode + 'dev'
		configlistref = xcodeprojectfile.addxcconfigurationlist('PBXNativeTarget',targetname)
		for item in solution.configurations:
			configlistref.configurations.append(xcodeprojectfile.addxcbuildconfigurationlist(item,None,configlistref,'iphoneos',False))
		nativeprojectdev = xcodeprojectfile.addnativeproject(targetname,devfilereference,xcodeprojectfile.projectname,outputtype)
		nativeprojectdev.configlistref = configlistref
		rootproject.append(nativeprojectdev)
	
		nativeprojectdev.append(buildphase1.uuid,'Sources')
		nativeprojectdev.append(framephase1.uuid,'Frameworks')
		devcontainer = xcodeprojectfile.addcontaineritemproxy(nativeprojectdev,xcodeprojectfile.uuid)

		targetname = solution.projectname + idecode + 'sim'
		configlistref = xcodeprojectfile.addxcconfigurationlist('PBXNativeTarget',targetname)
		for item in solution.configurations:
			configlistref.configurations.append(xcodeprojectfile.addxcbuildconfigurationlist(item,None,configlistref,'iphonesimulator',False))
		nativeprojectsim = xcodeprojectfile.addnativeproject(targetname,simfilereference,xcodeprojectfile.projectname,outputtype)
		nativeprojectsim.configlistref = configlistref
		rootproject.append(nativeprojectsim)
	
		nativeprojectsim.append(buildphase2.uuid,'Sources')
		nativeprojectsim.append(framephase2.uuid,'Frameworks')
		simcontainer = xcodeprojectfile.addcontaineritemproxy(nativeprojectsim,xcodeprojectfile.uuid)

		nativetarget1.depend(xcodeprojectfile.adddependency(devcontainer,nativeprojectdev).uuid,'PBXTargetDependency')
		nativetarget1.depend(xcodeprojectfile.adddependency(simcontainer,nativeprojectsim).uuid,'PBXTargetDependency')

	#
	# Add in a shell script build phase if needed
	#
	
	#
	# Is this an application?
	#
	
	if solution.platform=='macosx':
		if solution.kind=='tool':
			input = ['${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}']
			output = '${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}'
			command = 'if [ ! -d ${SRCROOT}/bin ]; then mkdir ${SRCROOT}/bin; fi\\n' \
				'${CP} ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME} ${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}'
			shellbuildphase = xcodeprojectfile.addshellscriptbuildphase(input,output,command)
			nativetarget1.append(shellbuildphase.uuid,'ShellScript')
		elif solution.kind=='game':
			input = ['${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}.app/Contents/MacOS/${EXECUTABLE_NAME}']
			output = '${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}.app/Contents/MacOS/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}'
			command = 'if [ ! -d ${SRCROOT}/bin ]; then mkdir ${SRCROOT}/bin; fi\\n' \
				'${CP} -r ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}.app/ ${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}.app/\\n' \
				'mv ${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}.app/Contents/MacOS/${EXECUTABLE_NAME} ${SRCROOT}/bin/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}.app/Contents/MacOS/${EXECUTABLE_NAME}${IDESUFFIX}${SUFFIX}'
			shellbuildphase = xcodeprojectfile.addshellscriptbuildphase(input,output,command)
			nativetarget1.append(shellbuildphase.uuid,'ShellScript')

	#
	# Is there a final folder?
	#
	
	if solution.finalfolder!=None:
		if ioslibrary==False:
			input = ['${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME}']
		else:
			input = [
				'${BUILD_ROOT}/' + solution.projectname + idecode + 'dev${SUFFIX}/lib' + solution.projectname + idecode + 'dev.a',
				'${BUILD_ROOT}/' + solution.projectname + idecode + 'sim${SUFFIX}/lib' + solution.projectname + idecode + 'sim.a'
			]
		finalfolder = solution.finalfolder.replace('(','{')
		finalfolder = finalfolder.replace(')','}')
		if ioslibrary==True:
			command = '${SDKS}/macosx/bin/p4 edit ' + finalfolder + '${FINAL_OUTPUT}\\nlipo -output ' + \
				finalfolder + '${FINAL_OUTPUT} -create ${BUILD_ROOT}/' + solution.projectname + idecode + \
				'dev${SUFFIX}/lib' + solution.projectname + idecode + 'dev.a ${BUILD_ROOT}/' + solution.projectname + idecode + 'sim${SUFFIX}/lib' + solution.projectname + idecode + 'sim.a\\n';
		elif solution.kind=='library':
			command = '${SDKS}/macosx/bin/p4 edit ' + finalfolder + '${FINAL_OUTPUT}\\n${CP} ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME} ' + finalfolder + '${FINAL_OUTPUT}\\n'
		else:
			command = 'if [ \\"${CONFIGURATION}\\" == \\"Release\\" ]; then\\n${SDKS}/macosx/bin/p4 edit ' + finalfolder + '${FINAL_OUTPUT}\\n${CP} ${CONFIGURATION_BUILD_DIR}/${EXECUTABLE_NAME} ' + finalfolder + '${FINAL_OUTPUT}\\nfi\\n'
		shellbuildphase = xcodeprojectfile.addshellscriptbuildphase(input,solution.finalfolder + '${FINAL_OUTPUT}',command)
		nativetarget1.append(shellbuildphase.uuid,'ShellScript')
		
	#
	# Serialize the XCode file
	#
	
	fp = StringIO.StringIO()
	xcodeprojectfile.write(fp)
	
	#
	# Did it change?
	#
	
	if burger.comparefiletostring(projectfilename,fp):
		if solution.verbose==True:
			print projectfilename + ' was not changed'
	else:
		burger.perforceedit(projectfilename)
		fp2 = open(projectfilename,'w')
		fp2.write(fp.getvalue())
		fp2.close()
	fp.close()
	return 0
예제 #16
0
def main(workingDir):

    #
    # Was Burgerlib already installed?
    #

    sdks = burger.getsdksfolder()

    #
    # Update the changelist header
    #

    burger.makeversionheader(workingDir,
                             os.path.join(workingDir, 'source', 'version.h'))

    #
    # Folders for all the target operating systems supported
    #

    destinations = [
        'windows', 'dos', 'mac', 'macosx', 'linux', 'beos', 'ps2', 'ps3',
        'ps4', 'gamecube', 'wii', 'dsi', 'xbox', 'xbox360', 'xboxone', 'ios',
        'android', 'shield', 'ouya'
    ]

    #
    # Ensure the destination directories exist
    #

    for dest in destinations:
        burger.createfolderifneeded(os.path.join(sdks, dest, 'burgerlib'))

    #
    # Ensure the output folder exists
    #

    outputfolder = os.path.join(workingDir, 'bin')
    burger.createfolderifneeded(outputfolder)

    #
    # Create the super header
    #

    burgerhfile = os.path.join(outputfolder, 'burger.h')
    cmd = 'makeheader "' + os.path.join(
        workingDir, 'source',
        'templateburgerbase.h') + '" "' + burgerhfile + '"'
    error = subprocess.call(cmd, cwd=workingDir, shell=True)
    if error == 0:

        # Was there a change in the output?

        windowsburgerlib = os.path.join(sdks, 'windows', 'burgerlib')
        testfile = os.path.join(windowsburgerlib, 'burger.h')
        if os.path.isfile(testfile)!=True or \
         burger.comparefiles(burgerhfile,testfile)!=True:

            # Copy only if changed

            for dest in destinations:
                destfolder = os.path.join(sdks, dest, 'burgerlib')
                error = burger.copyfileandcheckoutifneeded(
                    burgerhfile, os.path.join(destfolder, 'burger.h'))
                if error != 0:
                    break

    #
    # Was there a change in special headers?
    #

    if error == 0:
        specialheaders = [
            'brstartup.h', 'brgl.h', 'brglext.h', 'brglut.h', 'brglxext.h'
        ]

        for item in specialheaders:
            brstartuphfile = os.path.join(workingDir, 'source', item)
            testfile = os.path.join(sdks, 'windows', 'burgerlib', item)
            if os.path.isfile(testfile)!=True or \
             burger.comparefiles(brstartuphfile,testfile)==False:
                for dest in destinations:
                    error = burger.copyfileandcheckoutifneeded(
                        brstartuphfile,
                        os.path.join(sdks, dest, 'burgerlib', item))
                    if error != 0:
                        break

    #
    # Did any of the Mac Carbon/Classic resource files change?
    #

    if error == 0:
        macosfolder = os.path.join(workingDir, 'source', 'mac')
        destfolder = os.path.join(sdks, 'mac', 'burgerlib')
        filedata = os.listdir(macosfolder)
        for file in filedata:
            tfile = file.lower()
            if tfile.endswith('.r'):
                destfile = os.path.join(destfolder, file)
                sourcefile = os.path.join(macosfolder, file)
                if os.path.isfile(destfile)!=True or \
                 burger.comparefiles(sourcefile,destfile)==False:
                    error = burger.copyfileandcheckoutifneeded(
                        sourcefile, destfile)
                    if error != 0:
                        break

    return error