<s> import os <EOL> import shutil <EOL> import Common <EOL> from common import Log <EOL> from common import Resource <EOL> from common import Config <EOL> from common import Project <EOL> import Generator <EOL> import Tools <EOL> class Platform ( Project . Object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config , name ) : <EOL> self . name = name <EOL> self . requireOrdinals = False <EOL> self . exportLinkage = None <EOL> self . entryLinkage = None <EOL> self . language = None <EOL> conf = Resource . getPath ( "<STR_LIT>" , "<STR_LIT>" % self . name , required = False ) <EOL> if conf : <EOL> config . loadFile ( conf ) <EOL> def createBuild ( self , config , library , name , targetName ) : <EOL> raise RuntimeError ( "<STR_LIT>" % self . name ) <EOL> class Build ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config , library , platform , name , targetName ) : <EOL> self . config = config <EOL> self . name = name <EOL> self . platform = platform <EOL> self . targetName = targetName <EOL> self . library = library <EOL> def compile ( self , targetPath ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def collectItem ( self , targetPath , item ) : <EOL> Tools . makePath ( targetPath ) <EOL> path = self . config . getRelativePath ( item ) <EOL> if not os . path . exists ( path ) : <EOL> Log . error ( "<STR_LIT>" % path ) <EOL> return <EOL> if not int ( item . attrs . get ( "<STR_LIT>" , <NUM_LIT:1> ) ) : <EOL> return path <EOL> name = os . path . basename ( path ) <EOL> shutil . copyfile ( path , os . path . join ( targetPath , name ) ) <EOL> return name <EOL> class SymbianBuild ( Build ) : <EOL> def __init__ ( self , * args ) : <EOL> Build . __init__ ( self , * args ) <EOL> def compile ( self , targetPath ) : <EOL> sources = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> sources . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT:src>" ) , item ) ) <EOL> headers = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> if not isinstance ( item , Config . Group ) : <EOL> headers . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT>" ) , item ) ) <EOL> resources = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> if not isinstance ( item , Config . Group ) : <EOL> resources . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT>" ) , item ) ) <EOL> namespace = { <EOL> "<STR_LIT>" : self . targetName , <EOL> "<STR_LIT>" : self . name , <EOL> "<STR_LIT>" : self . config , <EOL> "<STR_LIT>" : self . library , <EOL> "<STR_LIT>" : sources , <EOL> "<STR_LIT>" : headers , <EOL> } <EOL> def generate ( templatePath , outputPath ) : <EOL> Log . debug ( "<STR_LIT>" % ( outputPath [ - <NUM_LIT:1> ] ) ) <EOL> Generator . generate ( templates = [ Resource . getPath ( * templatePath ) ] , <EOL> namespace = namespace , <EOL> outputFile = open ( os . path . join ( * outputPath ) , "<STR_LIT:w>" ) ) <EOL> projectPath = os . path . join ( targetPath , "<STR_LIT>" ) <EOL> headerPath = os . path . join ( targetPath , "<STR_LIT>" ) <EOL> Tools . makePath ( projectPath ) <EOL> Tools . makePath ( headerPath ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ headerPath , "<STR_LIT>" ] ) <EOL> if self . config . targettype . lower ( ) == "<STR_LIT>" : <EOL> if not "<STR_LIT>" in self . config : <EOL> self . config [ "<STR_LIT>" ] = Config . List ( ) <EOL> self . config . resources . append ( Config . Item ( self . name + "<STR_LIT>" ) ) <EOL> self . config . resources . append ( Config . Item ( self . name + "<STR_LIT>" , attrs = { "<STR_LIT:type>" : "<STR_LIT>" } ) ) <EOL> resourcePath = os . path . join ( targetPath , "<STR_LIT>" ) <EOL> Tools . makePath ( resourcePath ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ resourcePath , self . name + "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ resourcePath , self . name + "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ projectPath , self . name + "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ projectPath , "<STR_LIT>" ] ) <EOL> else : <EOL> for arch in [ "<STR_LIT>" , "<STR_LIT>" ] : <EOL> defPath = os . path . join ( targetPath , arch ) <EOL> Tools . makePath ( defPath ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ defPath , self . name + "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ projectPath , "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ projectPath , self . name + "<STR_LIT>" ] ) <EOL> class Win32Build ( Build ) : <EOL> def __init__ ( self , * args ) : <EOL> Build . __init__ ( self , * args ) <EOL> def compile ( self , targetPath ) : <EOL> sources = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> sources . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT:src>" ) , item ) ) <EOL> headers = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> if not isinstance ( item , Config . Group ) : <EOL> headers . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT>" ) , item ) ) <EOL> namespace = { <EOL> "<STR_LIT>" : self . targetName , <EOL> "<STR_LIT>" : self . name , <EOL> "<STR_LIT>" : self . config , <EOL> "<STR_LIT>" : sources , <EOL> "<STR_LIT>" : headers , <EOL> } <EOL> def generate ( templatePath , outputPath ) : <EOL> Generator . generate ( templates = [ Resource . getPath ( * templatePath ) ] , <EOL> namespace = namespace , <EOL> outputFile = open ( os . path . join ( * outputPath ) , "<STR_LIT:w>" ) ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:win32>" , "<STR_LIT>" ] , <EOL> [ targetPath , "<STR_LIT>" ] ) <EOL> class UnixBuild ( Build ) : <EOL> def __init__ ( self , * args ) : <EOL> Build . __init__ ( self , * args ) <EOL> def compile ( self , targetPath ) : <EOL> sources = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> sources . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT:src>" ) , item ) ) <EOL> headers = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> if not isinstance ( item , Config . Group ) : <EOL> headers . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT>" ) , item ) ) <EOL> namespace = { <EOL> "<STR_LIT>" : self . targetName , <EOL> "<STR_LIT>" : self . name , <EOL> "<STR_LIT>" : self . config , <EOL> "<STR_LIT>" : sources , <EOL> "<STR_LIT>" : headers , <EOL> } <EOL> def generate ( templatePath , outputPath ) : <EOL> Generator . generate ( templates = [ Resource . getPath ( * templatePath ) ] , <EOL> namespace = namespace , <EOL> outputFile = open ( os . path . join ( * outputPath ) , "<STR_LIT:w>" ) ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ targetPath , "<STR_LIT>" ] ) <EOL> class AndroidBuild ( Build ) : <EOL> def __init__ ( self , * args ) : <EOL> Build . __init__ ( self , * args ) <EOL> def compile ( self , targetPath ) : <EOL> sources = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> sources . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT:src>" ) , item ) ) <EOL> headers = [ ] <EOL> for item in self . config . get ( "<STR_LIT>" , [ ] ) : <EOL> if not isinstance ( item , Config . Group ) : <EOL> headers . append ( self . collectItem ( os . path . join ( targetPath , "<STR_LIT>" ) , item ) ) <EOL> namespace = { <EOL> "<STR_LIT>" : self . targetName , <EOL> "<STR_LIT>" : self . name , <EOL> "<STR_LIT>" : self . config , <EOL> "<STR_LIT>" : sources , <EOL> "<STR_LIT>" : headers , <EOL> } <EOL> def generate ( templatePath , outputPath ) : <EOL> Generator . generate ( templates = [ Resource . getPath ( * templatePath ) ] , <EOL> namespace = namespace , <EOL> outputFile = open ( os . path . join ( * outputPath ) , "<STR_LIT:w>" ) ) <EOL> Tools . makePath ( os . path . join ( targetPath , "<STR_LIT>" ) ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ targetPath , "<STR_LIT>" , "<STR_LIT>" ] ) <EOL> generate ( [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ] , <EOL> [ targetPath , "<STR_LIT>" ] ) <EOL> class SymbianPlatform ( Platform ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , config ) : <EOL> Platform . __init__ ( self , config , "<STR_LIT>" ) <EOL> self . requireOrdinals = True <EOL> self . exportLinkage = "<STR_LIT>" <EOL> self . entryLinkage = "<STR_LIT>" <EOL> self . language = "<STR_LIT>" <EOL> def createBuild ( self , config , library , name , targetName ) : <EOL> return SymbianBuild ( config , library , self , name , targetName ) <EOL> class SpandexPlatform ( Platform ) : <EOL> def __init__ ( self , config ) : <EOL> Platform . __init__ ( self , config , "<STR_LIT>" ) <EOL> self . requireOrdinals = False <EOL> self . exportLinkage = "<STR_LIT>" <EOL> self . entryLinkage = "<STR_LIT>" <EOL> self . language = "<STR_LIT:c>" <EOL> class Win32Platform ( Platform ) : <EOL> def __init__ ( self , config ) : <EOL> Platform . __init__ ( self , config , "<STR_LIT:win32>" ) <EOL> self . requireOrdinals = False <EOL> self . exportLinkage = "<STR_LIT>" <EOL> self . entryLinkage = "<STR_LIT>" <EOL> self . language = "<STR_LIT:c>" <EOL> def createBuild ( self , config , library , name , targetName ) : <EOL> return Win32Build ( config , library , self , name , targetName ) <EOL> class UnixPlatform ( Platform ) : <EOL> def __init__ ( self , config ) : <EOL> Platform . __init__ ( self , config , "<STR_LIT>" ) <EOL> self . requireOrdinals = False <EOL> self . exportLinkage = "<STR_LIT>" <EOL> self . entryLinkage = "<STR_LIT>" <EOL> self . language = "<STR_LIT:c>" <EOL> def createBuild ( self , config , library , name , targetName ) : <EOL> return UnixBuild ( config , library , self , name , targetName ) <EOL> class AndroidPlatform ( Platform ) : <EOL> def __init__ ( self , config ) : <EOL> Platform . __init__ ( self , config , "<STR_LIT>" ) <EOL> self . requireOrdinals = False <EOL> self . exportLinkage = "<STR_LIT>" <EOL> self . entryLinkage = "<STR_LIT>" <EOL> self . language = "<STR_LIT:c>" <EOL> def createBuild ( self , config , library , name , targetName ) : <EOL> return AndroidBuild ( config , library , self , name , targetName ) <EOL> defaultPlatform = "<STR_LIT>" <EOL> platforms = { <EOL> "<STR_LIT>" : SymbianPlatform , <EOL> "<STR_LIT>" : SpandexPlatform , <EOL> "<STR_LIT:win32>" : Win32Platform , <EOL> "<STR_LIT>" : UnixPlatform , <EOL> "<STR_LIT>" : AndroidPlatform , <EOL> } </s>
