Source

pygame / symbian / SConstruct

Full commit
from scons_symbian import *

gcce.GCCE_OPTIMIZATION_FLAGS = "-O2 -fno-unit-at-a-time"

# Pygame's installer package
PACKAGE_NAME = ARGUMENTS.get( "package",    "pygame.sis" )
PACKAGE_TITLE = ARGUMENTS.get( "sisappname", "pygame for S60" )
#: Name of the python dll to use
PYTHON_LIB_NAME = ARGUMENTS.get( "pythondll", "pygame_python" )
#: Path to the libraries of pygame
PATH_PY_LIBS = ARGUMENTS.get( "pylibs", "data/pygame/libs" )
#: Name of the used sdl.dll ( pygame_sdl.dll )
SDL_DLL_NAME = ARGUMENTS.get( "sdldll", "pygame_sdl" )
#: Name of the used jpeg.dll
JPEG_DLL_NAME = ARGUMENTS.get( "jpegdll", "pygame_libjpeg" )
#: Name of the used libpng.dll
PNG_DLL_NAME = ARGUMENTS.get( "pngdll", "pygame_libpng" )

UID_PACKAGE    = ARGUMENTS.get( "sisuid" )
UID_PYGAMEAPP  = ARGUMENTS.get( "appuid" )
UID_SDL        = ARGUMENTS.get( "sdluid" )
UID_JPEG       = ARGUMENTS.get( "jpeguid" )
UID_PNG        = ARGUMENTS.get( "pnguid" )

CAPABILITIES  = ARGUMENTS.get( "capabilities", "").split("+")
if len(CAPABILITIES) == 0: CAPABILITIES = CAPS_SELF_SIGNED

SISVERSION    = ARGUMENTS.get( "sisversion", "1,0,0").split(",")
PYTHON_INCLUDE = ARGUMENTS.get( "pythoninclude", EPOC32_INCLUDE + "/python")

# SIS certificate 
CERT = ARGUMENTS.get("cert", None)
KEY  = ARGUMENTS.get("privkey", None)
PASSPHRASE  = ARGUMENTS.get("passphrase", "" )


EMBEDDED_PYTHON_SIS = ARGUMENTS.get( "pythonsis", "none" )
if EMBEDDED_PYTHON_SIS.lower() != "none" and COMPILER != COMPILER_WINSCW:
    # Read the UID
    f=open( EMBEDDED_PYTHON_SIS,'rb')
    # First 16 bytes are for UIDs
    # See: http://homepage.ntlworld.com/thouky/software/psifs/sis.html
    data=f.read(16)
    f.close()
    import struct
    uids = struct.unpack("IIII", data )
    EMBEDDED_PYTHON_SIS_UID = hex(uids[2]).replace("L","")
    print "Read UID %s from '%s'" % ( EMBEDDED_PYTHON_SIS_UID, EMBEDDED_PYTHON_SIS  )
else:
    EMBEDDED_PYTHON_SIS = ""
    EMBEDDED_PYTHON_SIS_UID = 0x0
      
Export("PACKAGE_NAME PYTHON_LIB_NAME PATH_PY_LIBS SDL_DLL_NAME CAPABILITIES PYTHON_INCLUDE")

# Build external libraries. Conditional because needed only once and takes extra time after that.
if ARGUMENTS.get( "buildlibs", True ):
    SConscript( "SConscript.sft2.py" )
    SConscript( "SConscript.Ogg.py" )    
    SConscript( "SConscript.Vorbis.py" )
    
    UID3 = UID_JPEG
    TARGET_NAME = JPEG_DLL_NAME  
    Export("TARGET_NAME UID3")
    SConscript( "SConscript.jpeg.py" )  
    
    UID3 = UID_PNG
    TARGET_NAME = PNG_DLL_NAME  
    Export("TARGET_NAME UID3")
    SConscript( "SConscript.libpng.py" )  
    
    TARGET_NAME = SDL_DLL_NAME  
    UID3        = UID_SDL     
    Export( "TARGET_NAME UID3" )
    SConscript( "SConscript.SDL.py" )
    
# Build pygame.lib
SConscript( "SConscript.pygame.py")

# Build pygame application
Export("UID_PYGAMEAPP CAPABILITIES")

SConscript( "SConscript.app.py")

#===============================================================================
# Create the package
#===============================================================================
pkgtemplate = "pygame_pkgtemplate.txt"

# Python is embedded as a sis
pkgargs = {
    "version" : SISVERSION,
    "uid"     : UID_PACKAGE,
    "appname" : PACKAGE_TITLE,
    'cert':      CERT,
    'key':       KEY,
    'passwd':    PASSPHRASE,
    "EMBEDDED_PYTHON_SIS"     : EMBEDDED_PYTHON_SIS, 
    "EMBEDDED_PYTHON_SIS_UID" : EMBEDDED_PYTHON_SIS_UID,
}

Depends( PACKAGE_NAME, EMBEDDED_PYTHON_SIS )
SymbianPackage(PACKAGE_NAME, pkgargs=pkgargs, pkgtemplate = pkgtemplate )