Unify whitespace and add -headerpad_max_install_names to LINKFLAGS.

This commit is contained in:
jdolan 2013-06-27 00:36:39 -04:00
parent 2d6a36ac81
commit 178ebc262b

817
config.py
View file

@ -1,7 +1,7 @@
import sys, traceback, platform, re, commands, platform, subprocess import sys, traceback, platform, re, commands, platform, subprocess
if __name__ != '__main__': if __name__ != '__main__':
from SCons.Script import * from SCons.Script import *
import utils, urllib2, zipfile, shutil, pprint, subprocess, re, os.path import utils, urllib2, zipfile, shutil, pprint, subprocess, re, os.path
@ -9,351 +9,356 @@ import utils, urllib2, zipfile, shutil, pprint, subprocess, re, os.path
# target = # target =
class Config: class Config:
# aliases # aliases
# 'all' -> for each choices # 'all' -> for each choices
# 'gamecode' for the targets, 'game' 'cgame' 'ui' # 'gamecode' for the targets, 'game' 'cgame' 'ui'
def __init__( self ): def __init__( self ):
# initialize defaults # initialize defaults
self.target_selected = [ 'radiant', 'q3map2', 'q3data', 'setup' ] self.target_selected = [ 'radiant', 'q3map2', 'q3data', 'setup' ]
self.config_selected = [ 'release' ] self.config_selected = [ 'release' ]
# those are global to each config # those are global to each config
self.platform = platform.system() self.platform = platform.system()
self.cc = 'gcc' self.cc = 'gcc'
self.cxx = 'g++' self.cxx = 'g++'
self.install_directory = 'install' self.install_directory = 'install'
# platforms for which to assemble a setup # platforms for which to assemble a setup
self.setup_platforms = [ 'local', 'x86', 'x64', 'win32' ] self.setup_platforms = [ 'local', 'x86', 'x64', 'win32' ]
# paks to assemble in the setup
self.setup_packs = [ 'Q3Pack', 'UrTPack', 'ETPack', 'QLPack' ] # paks to assemble in the setup
self.setup_packs = [ 'Q3Pack', 'UrTPack', 'ETPack', 'QLPack' ]
def __repr__( self ): def __repr__( self ):
return 'config: target=%s config=%s' % ( self.target_selected, self.config_selected ) return 'config: target=%s config=%s' % ( self.target_selected, self.config_selected )
def _processTarget( self, ops ): def _processTarget( self, ops ):
self.target_selected = ops self.target_selected = ops
def _processConfig( self, ops ): def _processConfig( self, ops ):
self.config_selected = ops self.config_selected = ops
def _processCC( self, ops ): def _processCC( self, ops ):
self.cc = ops self.cc = ops
def _processCXX( self, ops ): def _processCXX( self, ops ):
self.cxx = ops self.cxx = ops
def _processInstallDir( self, ops ): def _processInstallDir( self, ops ):
self.install_directory = os.path.normpath( os.path.expanduser( ops[0] ) ) self.install_directory = os.path.normpath( os.path.expanduser( ops[0] ) )
def _processSetupPlatforms( self, ops ): def _processSetupPlatforms( self, ops ):
self.setup_platforms = ops self.setup_platforms = ops
def _processSetupPacks( self, ops ): def _processSetupPacks( self, ops ):
self.setup_packs = ops self.setup_packs = ops
def setupParser( self, operators ): def setupParser( self, operators ):
operators['target'] = self._processTarget operators['target'] = self._processTarget
operators['config'] = self._processConfig operators['config'] = self._processConfig
operators['cc'] = self._processCC operators['cc'] = self._processCC
operators['cxx'] = self._processCXX operators['cxx'] = self._processCXX
operators['install_directory'] = self._processInstallDir operators['install_directory'] = self._processInstallDir
operators['setup_platforms'] = self._processSetupPlatforms operators['setup_platforms'] = self._processSetupPlatforms
operators['setup_packs'] = self._processSetupPacks operators['setup_packs'] = self._processSetupPacks
def emit_radiant( self ): def emit_radiant( self ):
settings = self settings = self
for config_name in self.config_selected: for config_name in self.config_selected:
config = {} config = {}
config['name'] = config_name config['name'] = config_name
config['shared'] = False config['shared'] = False
Export( 'utils', 'settings', 'config' ) Export( 'utils', 'settings', 'config' )
build_dir = os.path.join( 'build', config_name, 'radiant' ) build_dir = os.path.join( 'build', config_name, 'radiant' )
VariantDir( build_dir, '.', duplicate = 0 ) VariantDir( build_dir, '.', duplicate = 0 )
lib_objects = [] lib_objects = []
for project in [ 'libs/synapse/synapse.vcproj', 'libs/cmdlib/cmdlib.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj' ]: for project in [ 'libs/synapse/synapse.vcproj', 'libs/cmdlib/cmdlib.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj' ]:
Export( 'project' ) Export( 'project' )
lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) ) lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) )
Export( 'lib_objects' ) Export( 'lib_objects' )
radiant = SConscript( os.path.join( build_dir, 'SConscript.radiant' ) ) radiant = SConscript( os.path.join( build_dir, 'SConscript.radiant' ) )
Default( InstallAs( os.path.join( self.install_directory, 'radiant.bin' ), radiant ) ) Default( InstallAs( os.path.join( self.install_directory, 'radiant.bin' ), radiant ) )
# PIC versions of the libs for the modules # PIC versions of the libs for the modules
shlib_objects_extra = {} shlib_objects_extra = {}
for project in [ 'libs/synapse/synapse.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/picomodel/picomodel.vcproj', 'libs/cmdlib/cmdlib.vcproj', 'libs/splines/splines.vcproj' ]: for project in [ 'libs/synapse/synapse.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/picomodel/picomodel.vcproj', 'libs/cmdlib/cmdlib.vcproj', 'libs/splines/splines.vcproj' ]:
( libpath, libname ) = os.path.split( project ) ( libpath, libname ) = os.path.split( project )
libname = os.path.splitext( libname )[0] libname = os.path.splitext( libname )[0]
config['shared'] = True config['shared'] = True
Export( 'project', 'config' ) Export( 'project', 'config' )
build_dir = os.path.join( 'build', config_name, 'shobjs' ) build_dir = os.path.join( 'build', config_name, 'shobjs' )
VariantDir( build_dir, '.', duplicate = 0 ) VariantDir( build_dir, '.', duplicate = 0 )
shlib_objects_extra[libname] = SConscript( os.path.join( build_dir, 'SConscript.lib' ) ) shlib_objects_extra[libname] = SConscript( os.path.join( build_dir, 'SConscript.lib' ) )
for project in [ 'plugins/vfsqlpk3/vfsqlpk3.vcproj', for project in [ 'plugins/vfsqlpk3/vfsqlpk3.vcproj',
'plugins/vfspk3/vfspk3.vcproj', 'plugins/vfspk3/vfspk3.vcproj',
'plugins/vfspak/vfspak.vcproj', 'plugins/vfspak/vfspak.vcproj',
'plugins/vfswad/vfswad.vcproj', 'plugins/vfswad/vfswad.vcproj',
'plugins/eclassfgd/fgd.vcproj', 'plugins/eclassfgd/fgd.vcproj',
'plugins/entity/entity.vcproj', 'plugins/entity/entity.vcproj',
'plugins/image/image.vcproj', 'plugins/image/image.vcproj',
'plugins/model/model.vcproj', 'plugins/model/model.vcproj',
'plugins/imagepng/imagepng.vcproj', 'plugins/imagepng/imagepng.vcproj',
'plugins/imagewal/imagewal.vcproj', 'plugins/imagewal/imagewal.vcproj',
'plugins/imagehl/imagehl.vcproj', 'plugins/imagehl/imagehl.vcproj',
'plugins/imagem8/imagem8.vcproj', 'plugins/imagem8/imagem8.vcproj',
'plugins/spritemodel/spritemodel.vcproj', 'plugins/spritemodel/spritemodel.vcproj',
'plugins/textool/textool.vcproj', 'plugins/textool/textool.vcproj',
'plugins/map/map.vcproj', 'plugins/map/map.vcproj',
'plugins/mapxml/mapxml.vcproj', 'plugins/mapxml/mapxml.vcproj',
'plugins/shaders/shaders.vcproj', 'plugins/shaders/shaders.vcproj',
'plugins/surface/surface.vcproj', 'plugins/surface/surface.vcproj',
'plugins/surface_ufoai/surface_ufoai.vcproj', 'plugins/surface_ufoai/surface_ufoai.vcproj',
'plugins/surface_quake2/surface_quake2.vcproj', 'plugins/surface_quake2/surface_quake2.vcproj',
'plugins/surface_heretic2/surface_heretic2.vcproj', 'plugins/surface_heretic2/surface_heretic2.vcproj',
'contrib/camera/camera.vcproj', 'contrib/camera/camera.vcproj',
'contrib/prtview/prtview.vcproj', 'contrib/prtview/prtview.vcproj',
'contrib/hydratoolz/hydratoolz.vcproj', 'contrib/hydratoolz/hydratoolz.vcproj',
'contrib/bobtoolz/bobtoolz.vcproj', 'contrib/bobtoolz/bobtoolz.vcproj',
'contrib/gtkgensurf/gtkgensurf.vcproj', 'contrib/gtkgensurf/gtkgensurf.vcproj',
'contrib/ufoai/ufoai.vcproj', 'contrib/ufoai/ufoai.vcproj',
'contrib/bkgrnd2d/bkgrnd2d.vcproj' 'contrib/bkgrnd2d/bkgrnd2d.vcproj'
]: ]:
( libpath, libname ) = os.path.split( project ) ( libpath, libname ) = os.path.split( project )
libname = os.path.splitext( libname )[0] libname = os.path.splitext( libname )[0]
# The old code assigned shlib_objects to shlib_objects_extra['synapse'], # The old code assigned shlib_objects to shlib_objects_extra['synapse'],
# and this resulted in a non-copy. Stuff is added to shlib_objects below. # and this resulted in a non-copy. Stuff is added to shlib_objects below.
# So we need the explicit copy so we don't modify shlib_objects_extra['synapse']. # So we need the explicit copy so we don't modify shlib_objects_extra['synapse'].
shlib_objects = shlib_objects_extra['synapse'][:] shlib_objects = shlib_objects_extra['synapse'][:]
if ( libname == 'camera' ): if ( libname == 'camera' ):
shlib_objects += shlib_objects_extra['splines'] shlib_objects += shlib_objects_extra['splines']
elif ( libname == 'entity' ): elif ( libname == 'entity' ):
shlib_objects += shlib_objects_extra['mathlib'] shlib_objects += shlib_objects_extra['mathlib']
elif ( libname == 'map' ): elif ( libname == 'map' ):
shlib_objects += shlib_objects_extra['cmdlib'] shlib_objects += shlib_objects_extra['cmdlib']
elif ( libname == 'model' ): elif ( libname == 'model' ):
shlib_objects += shlib_objects_extra['picomodel'] shlib_objects += shlib_objects_extra['picomodel']
shlib_objects += shlib_objects_extra['mathlib'] shlib_objects += shlib_objects_extra['mathlib']
elif ( libname == 'spritemodel' ): elif ( libname == 'spritemodel' ):
shlib_objects += shlib_objects_extra['mathlib'] shlib_objects += shlib_objects_extra['mathlib']
elif ( libname == 'textool' ): elif ( libname == 'textool' ):
shlib_objects += shlib_objects_extra['mathlib'] shlib_objects += shlib_objects_extra['mathlib']
elif ( libname == 'bobtoolz' ): elif ( libname == 'bobtoolz' ):
shlib_objects += shlib_objects_extra['mathlib'] shlib_objects += shlib_objects_extra['mathlib']
shlib_objects += shlib_objects_extra['cmdlib'] shlib_objects += shlib_objects_extra['cmdlib']
Export( 'project', 'shlib_objects' ) Export( 'project', 'shlib_objects' )
module = SConscript( os.path.join( build_dir, 'SConscript.module' ) ) module = SConscript( os.path.join( build_dir, 'SConscript.module' ) )
Default( InstallAs( os.path.join( self.install_directory, 'modules/%s.so' % libname ), module ) ) Default( InstallAs( os.path.join( self.install_directory, 'modules/%s.so' % libname ), module ) )
def emit_q3map2( self, urt = False ): def emit_q3map2( self, urt = False ):
if ( urt ): if ( urt ):
compiler_name = 'q3map2_urt' compiler_name = 'q3map2_urt'
sconscript_name = 'SConscript.q3map2.urt' sconscript_name = 'SConscript.q3map2.urt'
else: else:
compiler_name = 'q3map2' compiler_name = 'q3map2'
sconscript_name = 'SConscript.q3map2' sconscript_name = 'SConscript.q3map2'
settings = self settings = self
for config_name in self.config_selected: for config_name in self.config_selected:
config = {} config = {}
config['name'] = config_name config['name'] = config_name
config['shared'] = False config['shared'] = False
Export( 'utils', 'settings', 'config' ) Export( 'utils', 'settings', 'config' )
build_dir = os.path.join( 'build', config_name, compiler_name ) build_dir = os.path.join( 'build', config_name, compiler_name )
VariantDir( build_dir, '.', duplicate = 0 ) VariantDir( build_dir, '.', duplicate = 0 )
lib_objects = [] lib_objects = []
for project in [ 'tools/quake3/common/quake3-common.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj', 'libs/ddslib/ddslib.vcproj', 'libs/picomodel/picomodel.vcproj', 'libs/md5lib/md5lib.vcproj' ]: for project in [ 'tools/quake3/common/quake3-common.vcproj', 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj', 'libs/ddslib/ddslib.vcproj', 'libs/picomodel/picomodel.vcproj', 'libs/md5lib/md5lib.vcproj' ]:
Export( 'project' ) Export( 'project' )
lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) ) lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) )
Export( 'lib_objects' ) Export( 'lib_objects' )
q3map2 = SConscript( os.path.join( build_dir, sconscript_name ) ) q3map2 = SConscript( os.path.join( build_dir, sconscript_name ) )
Default( InstallAs( os.path.join( self.install_directory, compiler_name ), q3map2 ) ) Default( InstallAs( os.path.join( self.install_directory, compiler_name ), q3map2 ) )
def emit_q3data( self ): def emit_q3data( self ):
settings = self settings = self
for config_name in self.config_selected: for config_name in self.config_selected:
config = {} config = {}
config['name'] = config_name config['name'] = config_name
config['shared'] = False config['shared'] = False
Export( 'utils', 'settings', 'config' ) Export( 'utils', 'settings', 'config' )
build_dir = os.path.join( 'build', config_name, 'q3data' ) build_dir = os.path.join( 'build', config_name, 'q3data' )
VariantDir( build_dir, '.', duplicate = 0 ) VariantDir( build_dir, '.', duplicate = 0 )
lib_objects = [] lib_objects = []
for project in [ 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj', 'libs/ddslib/ddslib.vcproj' ]: for project in [ 'libs/mathlib/mathlib.vcproj', 'libs/l_net/l_net.vcproj', 'libs/ddslib/ddslib.vcproj' ]:
Export( 'project' ) Export( 'project' )
lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) ) lib_objects += SConscript( os.path.join( build_dir, 'SConscript.lib' ) )
Export( 'lib_objects' ) Export( 'lib_objects' )
q3data = SConscript( os.path.join( build_dir, 'SConscript.q3data' ) ) q3data = SConscript( os.path.join( build_dir, 'SConscript.q3data' ) )
Default( InstallAs( os.path.join( self.install_directory, 'q3data' ), q3data ) ) Default( InstallAs( os.path.join( self.install_directory, 'q3data' ), q3data ) )
def emit( self ): def emit( self ):
if 'radiant' in self.target_selected: if 'radiant' in self.target_selected:
self.emit_radiant() self.emit_radiant()
if 'q3map2' in self.target_selected: if 'q3map2' in self.target_selected:
self.emit_q3map2( urt = False ) self.emit_q3map2( urt = False )
self.emit_q3map2( urt = True ) self.emit_q3map2( urt = True )
if 'q3data' in self.target_selected: if 'q3data' in self.target_selected:
self.emit_q3data() self.emit_q3data()
if 'setup' in self.target_selected: if 'setup' in self.target_selected:
self.Setup() self.Setup()
if ( self.platform == 'Linux' ): if ( self.platform == 'Linux' ):
finish_command = Command( 'finish', [], self.FinishBuild ) finish_command = Command( 'finish', [], self.FinishBuild )
Depends( finish_command, DEFAULT_TARGETS ) Depends( finish_command, DEFAULT_TARGETS )
Default( finish_command ) Default( finish_command )
def SetupEnvironment( self, env, config, useGtk = False, useGtkGL = False, useJPEG = False, useZ = False, usePNG = False ): def SetupEnvironment( self, env, config, useGtk = False, useGtkGL = False, useJPEG = False, useZ = False, usePNG = False ):
env['CC'] = self.cc env['CC'] = self.cc
env['CXX'] = self.cxx env['CXX'] = self.cxx
( ret, xml2 ) = commands.getstatusoutput( 'xml2-config --cflags' ) ( ret, xml2 ) = commands.getstatusoutput( 'xml2-config --cflags' )
if ( ret != 0 ): if ( ret != 0 ):
print 'xml2-config failed' print 'xml2-config failed'
assert( False ) assert( False )
xml2libs = commands.getoutput( 'xml2-config --libs' ) xml2libs = commands.getoutput( 'xml2-config --libs' )
env.Append( LINKFLAGS = xml2libs.split( ' ' ) ) env.Append( LINKFLAGS = xml2libs.split( ' ' ) )
baseflags = [ '-pipe', '-Wall', '-fmessage-length=0', '-fvisibility=hidden', xml2.split( ' ' ) ] baseflags = [ '-pipe', '-Wall', '-fmessage-length=0', '-fvisibility=hidden', xml2.split( ' ' ) ]
if ( useGtk ): if ( useGtk ):
env.ParseConfig( 'pkg-config gtk+-2.0 --cflags --libs' ) env.ParseConfig( 'pkg-config gtk+-2.0 --cflags --libs' )
env.ParseConfig( 'pkg-config x11 --cflags --libs' ) env.ParseConfig( 'pkg-config x11 --cflags --libs' )
else: else:
# always setup at least glib # always setup at least glib
env.ParseConfig( 'pkg-config glib-2.0 --cflags --libs' ) env.ParseConfig( 'pkg-config glib-2.0 --cflags --libs' )
if ( useGtkGL ): if ( useGtkGL ):
env.ParseConfig( 'pkg-config glu --cflags --libs' ) env.ParseConfig( 'pkg-config glu --cflags --libs' )
env.ParseConfig( 'pkg-config gtkglext-1.0 --cflags --libs' ) env.ParseConfig( 'pkg-config gtkglext-1.0 --cflags --libs' )
if ( useJPEG ): if ( useJPEG ):
env.Append( LIBS = 'jpeg' ) env.Append( LIBS = 'jpeg' )
if ( usePNG ): if ( usePNG ):
pnglibs = 'png' pnglibs = 'png'
env.Append( LIBS = pnglibs.split( ' ' ) ) env.Append( LIBS = pnglibs.split( ' ' ) )
env.ParseConfig( 'pkg-config zlib --cflags --libs' ) env.ParseConfig( 'pkg-config zlib --cflags --libs' )
if ( useZ ): if ( useZ ):
env.ParseConfig( 'pkg-config zlib --cflags --libs' ) env.ParseConfig( 'pkg-config zlib --cflags --libs' )
env.Append( CCFLAGS = baseflags ) env.Append( CCFLAGS = baseflags )
env.Append( CXXFLAGS = baseflags + [ '-fpermissive', '-fvisibility-inlines-hidden' ] ) env.Append( CXXFLAGS = baseflags + [ '-fpermissive', '-fvisibility-inlines-hidden' ] )
env.Append( CPPPATH = [ 'include', 'libs' ] ) env.Append( CPPPATH = [ 'include', 'libs' ] )
env.Append( CPPDEFINES = [ 'Q_NO_STLPORT' ] ) env.Append( CPPDEFINES = [ 'Q_NO_STLPORT' ] )
if ( config == 'debug' ): if ( config == 'debug' ):
env.Append( CFLAGS = [ '-g' ] ) env.Append( CFLAGS = [ '-g' ] )
env.Append( CXXFLAGS = [ '-g' ] ) env.Append( CXXFLAGS = [ '-g' ] )
env.Append( CPPDEFINES = [ '_DEBUG' ] ) env.Append( CPPDEFINES = [ '_DEBUG' ] )
else: else:
env.Append( CFLAGS = [ '-O2', '-fno-strict-aliasing' ] ) env.Append( CFLAGS = [ '-O2', '-fno-strict-aliasing' ] )
env.Append( CXXFLAGS = [ '-O2', '-fno-strict-aliasing' ] ) env.Append( CXXFLAGS = [ '-O2', '-fno-strict-aliasing' ] )
# this lets us catch libjpg and libpng libraries that we put in the same directory as radiant.bin # this lets us catch libjpg and libpng libraries that we put in the same directory as radiant.bin
env.Append( LINKFLAGS = '-Wl,-rpath,.' ) env.Append( LINKFLAGS = '-Wl,-rpath,.' )
# On Mac, we pad headers so that we may rewrite them for packaging
if ( self.platform == 'Darwin') :
env.Append( LINKFLAGS = [ '-headerpad_max_install_names' ] )
def CheckoutOrUpdate( self, svnurl, path ): def CheckoutOrUpdate( self, svnurl, path ):
if ( os.path.exists( path ) ): if ( os.path.exists( path ) ):
cmd = [ 'svn', 'update', path ] cmd = [ 'svn', 'update', path ]
else: else:
cmd = [ 'svn', 'checkout', svnurl, path ] cmd = [ 'svn', 'checkout', svnurl, path ]
print( repr( cmd ) ) print( repr( cmd ) )
subprocess.check_call( cmd ) subprocess.check_call( cmd )
def FetchGamePaks( self, path ): def FetchGamePaks( self, path ):
for pak in self.setup_packs: for pak in self.setup_packs:
svnurl = 'svn://svn.icculus.org/gtkradiant-gamepacks/%s/trunk' % pak svnurl = 'svn://svn.icculus.org/gtkradiant-gamepacks/%s/trunk' % pak
self.CheckoutOrUpdate( svnurl, os.path.join( path, 'installs', pak ) ) self.CheckoutOrUpdate( svnurl, os.path.join( path, 'installs', pak ) )
def CopyTree( self, src, dst): def CopyTree( self, src, dst):
for root, dirs, files in os.walk( src ): for root, dirs, files in os.walk( src ):
target_dir = os.path.join( dst, root[root.find( '/' )+1:] ) target_dir = os.path.join( dst, root[root.find( '/' )+1:] )
print ( target_dir ) print ( target_dir )
if ( not os.path.exists( target_dir ) ): if ( not os.path.exists( target_dir ) ):
os.mkdir( target_dir ) os.mkdir( target_dir )
for file in files: for file in files:
shutil.copy( os.path.join( root, file ), os.path.join( target_dir, file ) ) shutil.copy( os.path.join( root, file ), os.path.join( target_dir, file ) )
def Setup( self ): def Setup( self ):
try: try:
self.setup_platforms.index( 'local' ) self.setup_platforms.index( 'local' )
except: except:
pass pass
else: else:
# special case, fetch external paks under the local install directory # special case, fetch external paks under the local install directory
self.FetchGamePaks( self.install_directory ) self.FetchGamePaks( self.install_directory )
# NOTE: unrelated to self.setup_platforms - grab support files and binaries and install them # NOTE: unrelated to self.setup_platforms - grab support files and binaries and install them
if ( self.platform == 'Windows' ): if ( self.platform == 'Windows' ):
backup_cwd = os.getcwd() backup_cwd = os.getcwd()
for lib_archive in [ for lib_archive in [
'gtk+-bundle-2.16.6-20100912-3-win32.zip', 'gtk+-bundle-2.16.6-20100912-3-win32.zip',
'gtkglext-1.2.0-3-win32.zip', 'gtkglext-1.2.0-3-win32.zip',
'libxml2-2.7.3-2-win32.zip', 'libxml2-2.7.3-2-win32.zip',
'jpeg-8c-4-win32.zip', 'jpeg-8c-4-win32.zip',
'STLport-5.2.1-4.zip' 'STLport-5.2.1-4.zip'
]: ]:
if ( not os.path.exists( lib_archive ) ): if ( not os.path.exists( lib_archive ) ):
print( 'downloading %s' % lib_archive ) print( 'downloading %s' % lib_archive )
archive_web_request = urllib2.urlopen( 'http://icculus.org/gtkradiant/files/1.6.2/%s' % lib_archive ) archive_web_request = urllib2.urlopen( 'http://icculus.org/gtkradiant/files/1.6.2/%s' % lib_archive )
archive_File = open( lib_archive, 'wb' ) archive_File = open( lib_archive, 'wb' )
while True: while True:
data = archive_web_request.read( 1048576 ) #read 1mb at a time data = archive_web_request.read( 1048576 ) #read 1mb at a time
if not data: if not data:
break break
archive_File.write( data ) archive_File.write( data )
archive_web_request.close() archive_web_request.close()
archive_File.close() archive_File.close()
print( 'unpacking %s' % lib_archive ) print( 'unpacking %s' % lib_archive )
lib_archive_path = os.path.abspath( lib_archive ) lib_archive_path = os.path.abspath( lib_archive )
os.chdir( os.path.dirname( backup_cwd ) ) os.chdir( os.path.dirname( backup_cwd ) )
archive_Zip = zipfile.ZipFile( lib_archive_path, 'r' ) archive_Zip = zipfile.ZipFile( lib_archive_path, 'r' )
archive_Zip.extractall() archive_Zip.extractall()
archive_Zip.close() archive_Zip.close()
os.chdir( backup_cwd ) os.chdir( backup_cwd )
# copy all the dependent runtime data to the install directory # copy all the dependent runtime data to the install directory
srcdir = os.path.dirname( backup_cwd ) srcdir = os.path.dirname( backup_cwd )
for dll in [ for dll in [
'gtk-2.16.6/bin/freetype6.dll', 'gtk-2.16.6/bin/freetype6.dll',
'gtk-2.16.6/bin/intl.dll', 'gtk-2.16.6/bin/intl.dll',
'gtk-2.16.6/bin/libasprintf-0.dll', 'gtk-2.16.6/bin/libasprintf-0.dll',
'gtk-2.16.6/bin/libatk-1.0-0.dll', 'gtk-2.16.6/bin/libatk-1.0-0.dll',
'gtk-2.16.6/bin/libcairo-2.dll', 'gtk-2.16.6/bin/libcairo-2.dll',
'gtk-2.16.6/bin/libexpat-1.dll', 'gtk-2.16.6/bin/libexpat-1.dll',
'gtk-2.16.6/bin/libfontconfig-1.dll', 'gtk-2.16.6/bin/libfontconfig-1.dll',
'gtk-2.16.6/bin/libgailutil-18.dll', 'gtk-2.16.6/bin/libgailutil-18.dll',
'gtk-2.16.6/bin/libgcc_s_dw2-1.dll', 'gtk-2.16.6/bin/libgcc_s_dw2-1.dll',
'gtk-2.16.6/bin/libgdk-win32-2.0-0.dll', 'gtk-2.16.6/bin/libgdk-win32-2.0-0.dll',
'gtk-2.16.6/bin/libgdk_pixbuf-2.0-0.dll', 'gtk-2.16.6/bin/libgdk_pixbuf-2.0-0.dll',
'gtk-2.16.6/bin/libgio-2.0-0.dll', 'gtk-2.16.6/bin/libgio-2.0-0.dll',
'gtk-2.16.6/bin/libglib-2.0-0.dll', 'gtk-2.16.6/bin/libglib-2.0-0.dll',
'gtk-2.16.6/bin/libgmodule-2.0-0.dll', 'gtk-2.16.6/bin/libgmodule-2.0-0.dll',
'gtk-2.16.6/bin/libgobject-2.0-0.dll', 'gtk-2.16.6/bin/libgobject-2.0-0.dll',
'gtk-2.16.6/bin/libgthread-2.0-0.dll', 'gtk-2.16.6/bin/libgthread-2.0-0.dll',
'gtk-2.16.6/bin/libgtk-win32-2.0-0.dll', 'gtk-2.16.6/bin/libgtk-win32-2.0-0.dll',
'gtk-2.16.6/bin/libpango-1.0-0.dll', 'gtk-2.16.6/bin/libpango-1.0-0.dll',
'gtk-2.16.6/bin/libpangocairo-1.0-0.dll', 'gtk-2.16.6/bin/libpangocairo-1.0-0.dll',
'gtk-2.16.6/bin/libpangoft2-1.0-0.dll', 'gtk-2.16.6/bin/libpangoft2-1.0-0.dll',
'gtk-2.16.6/bin/libpangowin32-1.0-0.dll', 'gtk-2.16.6/bin/libpangowin32-1.0-0.dll',
'gtk-2.16.6/bin/libpng14-14.dll', 'gtk-2.16.6/bin/libpng14-14.dll',
'gtk-2.16.6/bin/zlib1.dll', 'gtk-2.16.6/bin/zlib1.dll',
'gtk-2.16.6/lib/GNU.Gettext.dll', 'gtk-2.16.6/lib/GNU.Gettext.dll',
'gtk-2.16.6/lib/gtk-2.0/2.10.0/engines/libpixmap.dll', 'gtk-2.16.6/lib/gtk-2.0/2.10.0/engines/libpixmap.dll',
'gtk-2.16.6/lib/gtk-2.0/2.10.0/engines/libwimp.dll', 'gtk-2.16.6/lib/gtk-2.0/2.10.0/engines/libwimp.dll',
'gtk-2.16.6/lib/gtk-2.0/modules/libgail.dll', 'gtk-2.16.6/lib/gtk-2.0/modules/libgail.dll',
'gtkglext-1.2.0/bin/libgdkglext-win32-1.0-0.dll', 'gtkglext-1.2.0/bin/libgdkglext-win32-1.0-0.dll',
'gtkglext-1.2.0/bin/libgtkglext-win32-1.0-0.dll', 'gtkglext-1.2.0/bin/libgtkglext-win32-1.0-0.dll',
'libxml2-2.7.3/bin/libxml2-2.dll' 'libxml2-2.7.3/bin/libxml2-2.dll'
]: ]:
shutil.copy( os.path.join( srcdir, dll ), 'install' ) shutil.copy( os.path.join( srcdir, dll ), 'install' )
for extra in [ for extra in [
'gtk-2.16.6/etc', 'gtk-2.16.6/etc',
'gtk-2.16.6/share', 'gtk-2.16.6/share',
'gtkglext-1.2.0/share', 'gtkglext-1.2.0/share',
'libxml2-2.7.3/share' 'libxml2-2.7.3/share'
]: ]:
self.CopyTree( os.path.join( srcdir, extra ), 'install' ) self.CopyTree( os.path.join( srcdir, extra ), 'install' )
def FinishBuild( self, target, source, env ): def FinishBuild( self, target, source, env ):
print( 'Lookup and bundle the PNG and JPEG libraries' ) print( 'Lookup and bundle the PNG and JPEG libraries' )
@ -365,8 +370,8 @@ class Config:
# print( module_ldd ) # print( module_ldd )
def find_library( output, libname ): def find_library( output, libname ):
match = filter( lambda l : l.find( libname ) != -1, output.split( '\n' ) )[0] match = filter( lambda l : l.find( libname ) != -1, output.split( '\n' ) )[0]
return re.split( '.*=> (.*) .*', match )[1] return re.split( '.*=> (.*) .*', match )[1]
jpeg_path = find_library( module_ldd, 'libjpeg' ) jpeg_path = find_library( module_ldd, 'libjpeg' )
print( 'JPEG library: %s' % repr( jpeg_path ) ) print( 'JPEG library: %s' % repr( jpeg_path ) )
@ -379,115 +384,115 @@ class Config:
# parse the config statement line to produce/update an existing config list # parse the config statement line to produce/update an existing config list
# the configs expose a list of keywords and accepted values, which the engine parses out # the configs expose a list of keywords and accepted values, which the engine parses out
class ConfigParser: class ConfigParser:
def __init__( self ): def __init__( self ):
self.operators = {} self.operators = {}
def _processOp( self, ops ): def _processOp( self, ops ):
assert( len( ops ) == 1 ) assert( len( ops ) == 1 )
op = ops.pop() op = ops.pop()
if ( op == 'clear' ): if ( op == 'clear' ):
self.configs = [] self.configs = []
self.current_config = None self.current_config = None
elif ( op == 'pop' ): elif ( op == 'pop' ):
self.configs.pop() self.configs.pop()
self.current_config = None self.current_config = None
elif ( op == 'push' ): elif ( op == 'push' ):
self.configs.append( self.current_config ) self.configs.append( self.current_config )
self.current_config = Config() self.current_config = Config()
self._setupParser( self.current_config ) self._setupParser( self.current_config )
def _setupParser( self, c ): def _setupParser( self, c ):
self.operators = { 'op' : self._processOp } self.operators = { 'op' : self._processOp }
c.setupParser( self.operators ) c.setupParser( self.operators )
def _parseStatement( self, s ): def _parseStatement( self, s ):
statement_re = re.compile( '(.*)=(.*)' ) statement_re = re.compile( '(.*)=(.*)' )
value_list_re = re.compile( '([^,]*),?' ) value_list_re = re.compile( '([^,]*),?' )
if ( not statement_re.match( s ) ): if ( not statement_re.match( s ) ):
print 'syntax error (statement match): %s' % repr( s ) print 'syntax error (statement match): %s' % repr( s )
return return
statement_split = statement_re.split( s ) statement_split = statement_re.split( s )
if ( len( statement_split ) != 4 ): if ( len( statement_split ) != 4 ):
print 'syntax error (statement split): %s' % repr( s ) print 'syntax error (statement split): %s' % repr( s )
return return
( foo, name, value, bar ) = statement_split ( foo, name, value, bar ) = statement_split
value_split = value_list_re.split( value ) value_split = value_list_re.split( value )
if ( len( value_split ) < 2 or len( value_split ) % 2 != 1 ): if ( len( value_split ) < 2 or len( value_split ) % 2 != 1 ):
print 'syntax error (value split): %s' % ( repr( value_split ) ) print 'syntax error (value split): %s' % ( repr( value_split ) )
return return
try: try:
value_array = [] value_array = []
value_split.reverse() value_split.reverse()
value_split.pop() value_split.pop()
while ( len( value_split ) != 0 ): while ( len( value_split ) != 0 ):
value_array.append( value_split.pop() ) value_array.append( value_split.pop() )
value_split.pop() value_split.pop()
except: except:
print traceback.print_exception( sys.exc_type, sys.exc_value, sys.exc_traceback ) print traceback.print_exception( sys.exc_type, sys.exc_value, sys.exc_traceback )
print 'syntax error (value to array): %s' % ( repr( value_split ) ) print 'syntax error (value to array): %s' % ( repr( value_split ) )
return return
return ( name, value_array ) return ( name, value_array )
def parseStatements( self, _configs, statements ): def parseStatements( self, _configs, statements ):
self.current_config = None self.current_config = None
self.configs = _configs self.configs = _configs
if ( self.configs is None ): if ( self.configs is None ):
self.configs = [] self.configs = []
for s in statements: for s in statements:
if ( self.current_config is None ): if ( self.current_config is None ):
# use a provided config, or create a default one # use a provided config, or create a default one
if ( len( self.configs ) > 0 ): if ( len( self.configs ) > 0 ):
self.current_config = self.configs.pop() self.current_config = self.configs.pop()
else: else:
self.current_config = Config() self.current_config = Config()
# setup the operator table for this config # setup the operator table for this config
# NOTE: have that in self._processOp too # NOTE: have that in self._processOp too
self._setupParser( self.current_config ) self._setupParser( self.current_config )
ret = self._parseStatement( s ) ret = self._parseStatement( s )
if ( ret is None ): if ( ret is None ):
print 'stop statement parse at %s' % repr( s ) print 'stop statement parse at %s' % repr( s )
break break
( name, value_array ) = ret ( name, value_array ) = ret
try: try:
processor = self.operators[name] processor = self.operators[name]
except: except:
print 'unknown operator %s - stop statement parse at %s' % ( repr( name ), repr( s ) ) print 'unknown operator %s - stop statement parse at %s' % ( repr( name ), repr( s ) )
break break
processor( value_array ) processor( value_array )
if ( not self.current_config is None ): if ( not self.current_config is None ):
self.configs.append( self.current_config ) self.configs.append( self.current_config )
# make sure there is at least one config # make sure there is at least one config
if ( len( self.configs ) == 0 ): if ( len( self.configs ) == 0 ):
print 'pushing a default config' print 'pushing a default config'
self.configs.append( Config() ) self.configs.append( Config() )
return self.configs return self.configs
import unittest import unittest
class TestConfigParse( unittest.TestCase ): class TestConfigParse( unittest.TestCase ):
def setUp( self ): def setUp( self ):
self.parser = ConfigParser() self.parser = ConfigParser()
def testBasicParse( self ): def testBasicParse( self ):
# test basic config parsing # test basic config parsing
# needs to cleanly stop at the first config statement that is not recognized # needs to cleanly stop at the first config statement that is not recognized
configs = self.parser.parseStatements( None, [ 'game=missionpack', 'config=qvm', 'foobar' ] ) configs = self.parser.parseStatements( None, [ 'game=missionpack', 'config=qvm', 'foobar' ] )
print repr( configs ) print repr( configs )
def testMultiParse( self ): def testMultiParse( self ):
# multiple configs seperated by commas # multiple configs seperated by commas
configs = self.parser.parseStatements( None, [ 'target=server,game,cgame' ] ) configs = self.parser.parseStatements( None, [ 'target=server,game,cgame' ] )
print repr( configs ) print repr( configs )
def testOp( self ): def testOp( self ):
# test the operator for multiple configs # test the operator for multiple configs
configs = self.parser.parseStatements( None, [ 'target=core', 'config=release', 'op=push', 'target=game,cgame,ui', 'config=debug' ] ) configs = self.parser.parseStatements( None, [ 'target=core', 'config=release', 'op=push', 'target=game,cgame,ui', 'config=debug' ] )
print repr( configs ) print repr( configs )
if __name__ == '__main__': if __name__ == '__main__':
unittest.main() unittest.main()