root / trunk / winbuild.py

Revision 1316, 2.8 kB (checked in by glslang, 1 year ago)

+ initial hdrflow and olibs merge

  • Property svn:eol-style set to native
Line 
1
2#
3#
4#
5
6import sys
7import os
8import optparse
9import string
10
11def accept_args( args ):
12        parser = optparse.OptionParser( )
13        parser.add_option( "-t", "--toolset-version", dest="toolset", metavar="toolset-version", help="compiler toolset (e.g. vc71)" )
14        parser.add_option( "-b", "--build-type", dest="build", metavar="build-type", help="build type (e.g. rebuild)" )
15        parser.add_option( "-c", "--configuration", dest="configuration", metavar="configuration", help="configuration (e.g. debug)" )
16        parser.usage = "winbuild [options]"
17       
18        ( options, args ) = parser.parse_args( args )
19       
20        libraries = [ 'openpluginlib', 'openimagelib', 'openmedialib', 'openobjectlib', 'openassetlib' ]
21        if( len( args ) > 0 ): libraries = args
22       
23        ( toolset, build, configuration ) = ( options.toolset, options.build, options.configuration )
24       
25        def validate( value, name, default ):
26                if( value is None ):
27                        print "WARNING: %s was not specified. Defaults to %s." % ( name, default )
28                        return default
29                       
30                return value
31                       
32        toolset = validate( toolset, 'toolset', 'vc8' )
33        build = validate( build, 'build type', 'rebuild' )
34        configuration = validate( configuration, 'configuration', 'all' )
35       
36        return( toolset, build, configuration, libraries )
37
38class openlibraries_build:
39        def __init__( self, toolset, build, configuration, libraries ):
40                self.toolset            = toolset
41                self.build                      = build
42                self.configuration      = configuration
43                self.libraries          = libraries
44               
45        def run( self ):
46                self.system( [ self.build_cmd( ) ] )
47                       
48        def toolset_init( self ):
49                if( self.toolset == 'vc71' ):
50                        toolinit='call "%VS71COMNTOOLS%vsvars32.bat"'
51                elif( self.toolset == 'vc8' ):
52                        toolinit='call "%VS80COMNTOOLS%vsvars32.bat"'
53
54                return toolinit
55       
56        def build_cmd( self ):
57                commands = self.toolset_init( ) + '\n';
58                for i in self.libraries:
59                        if( self.configuration == 'debug' ):
60                                commands += 'devenv %s\%s_%s.sln /%s "Multi-threaded Debug DLL"\n' % ( self.toolset, i, self.toolset, self.build )
61                        elif( self.configuration == 'release' ):
62                                commands += 'devenv %s\%s_%s.sln /%s "Multi-threaded Release DLL"\n' % ( self.toolset, i, self.toolset, self.build )
63                        else:
64                                commands += 'devenv %s\%s_%s.sln /%s "Multi-threaded Debug DLL"\n' % ( self.toolset, i, self.toolset, self.build )
65                                commands += 'devenv %s\%s_%s.sln /%s "Multi-threaded Release DLL"\n' % ( self.toolset, i, self.toolset, self.build )
66               
67                return commands
68       
69        def system( self, commands ):
70                if os.path.exists( "tmp.cmd" ):
71                        os.chmod( "tmp.cmd", 0777 )
72                        os.unlink( "tmp.cmd" )
73
74                f = open( "tmp.cmd", "w" )
75                f.write( string.join( commands, "\n" ) )
76                f.close( )
77                rc = os.system( "tmp.cmd" )
78                os.chmod( "tmp.cmd", 0777 )
79                os.unlink( "tmp.cmd" )
80
81                return rc       
82
83def main( ):
84        ( toolset, build, configuration, libraries ) = accept_args( sys.argv[ 1: ] )
85       
86        openlibraries_build( toolset, build, configuration, libraries ).run( )
87       
88if( __name__ == "__main__" ):
89        main( )
Note: See TracBrowser for help on using the browser.