Anonymous avatar Anonymous committed 1daa8f5

Initial OpenC and PyS60 1.9.x support

Comments (0)

Files changed (14)

symbian/BuildPygameRelease.py

     args['appuid'] = hex(UID_PYGAMEAPP).replace("L","")
     args['sdluid'] = hex(UID_SDL).replace("L","")
     args['jpeguid']= hex(UID_JPEG).replace("L","")
+    args['pythoninclude'] = config.pythoninclude
     
     dobuild(args)
     

symbian/SConscript.Ogg.py

+Import("*")
 
 # This file is generated with mmp2sconscript
 from scons_symbian import *
 sources = ['deps/ogg/src/bitwise.c', 'deps/ogg/src/framing.c']
 
 includes    = ['/SDLS60/symbian']
-sysincludes = [ EPOC32_INCLUDE, EPOC32_INCLUDE + '/libc', 'deps/ogg/include']
+sysincludes = [ EPOC32_INCLUDE, C_INCLUDE, 'deps/ogg/include']
 defines     = []
 
 SymbianProgram( target, targettype,

symbian/SConscript.SDL.py

+Import("*")
+
 # This file is generated with mmp2sconscript
 from scons_symbian import *
 
-Import("*")
-
 target     = TARGET_NAME
 targettype = "dll"
 
                'inc', '/epoc32/include/SDL', 
                '/epoc32/include/gles', 
                '/epoc32/include/EGL', 
-               '/epoc32/include/libc', 
+               C_INCLUDE, 
                ]
 
-libraries  = ['euser',
+libraries  = C_LIBRARY + ['euser',
  'fbscli',
  'ws32',
  'gdi',
  'hal',
 # 'libc',
 # 'libm',
- 'estlib']
+ ]
 
 # Static libraries
 staticlibs = [ 'vorbis.lib', 'ogg.lib', 
-             'SDL_ttf.lib', 
+             #'SDL_ttf.lib', 
              'libsft2.lib',
              'pygame_libjpeg'
              ]
     'deps/jpeg/',    
 ]
 
+C_LIB_DEFINE = ""
+if not USE_OPENC:
+    # Tell SDL to use "estlib" then
+    C_LIB_DEFINE = 'SYMBIANC'
+else:
+    C_LIB_DEFINE = 'OPENC'
+
+defines.append( C_LIB_DEFINE )
+    
 # png.h does not like __DLL__ define
 SymbianProgram( "pygame_SDL_libpng", TARGETTYPE_LIB,
                 sources = ["deps/SDL_Image/IMG_png.c"],
                 includes = includes,
                 sysincludes = sysincludes + ["deps/libpng"],
-                defines = ["LOAD_PNG"],                
+                defines = ["LOAD_PNG", C_LIB_DEFINE],                
                 )
 staticlibs += ["pygame_SDL_libpng.lib", "pygame_libpng.lib"]
 libraries  += ["ezlib"] # For libpng
 
-defines += ['SYMBIANC', 'SYMBIAN_SERIES60', 
+defines += ['SYMBIAN_SERIES60', 
                'NO_SIGNAL_H', 'ENABLE_EPOC', 
                'DISABLE_JOYSTICK', 'DISABLE_CDROM',                
                ]
-
+    
 includes += ["deps/SDL_ttf/", "deps/sft2/inc/sys"]
 
 SymbianProgram( target, targettype,

symbian/SConscript.Vorbis.py

+Import("*")
+
 # This file is generated with mmp2sconscript
 from scons_symbian import *
 
 
 
 includes    = ['deps/SDL/symbian', 'deps/vorbis/include', 'deps/vorbis/include/vorbis']
-sysincludes = [EPOC32_INCLUDE, EPOC32_INCLUDE + "/libc", 'deps/ogg/include', 'deps/ogg/symbian']
+sysincludes = [EPOC32_INCLUDE, C_INCLUDE, 'deps/ogg/include', 'deps/ogg/symbian']
 
 defines     = []
 if COMPILER == COMPILER_GCCE: 
-    defines     = ['alloca=__builtin_alloca']
-
+    defines += ['alloca=__builtin_alloca']
+if USE_OPENC:
+    defines += [ 'OPENC' ]
+    
 SymbianProgram( target, targettype,
     sources = sources,
     includes    = includes,
     libraries   = libraries,
     defines     = defines,
     uid3 = uid3,
+    winscw_options = "-relax_pointers",   
 )
 

symbian/SConscript.app.py

                            "app/pygame_main.cpp"                           
                            ],
                 includes = ["app", "common",
-                join( EPOC32_INCLUDE, "SDL"), 
-                join( EPOC32_INCLUDE, "libc"),] + python_includes
+                            join( EPOC32_INCLUDE, "SDL"), 
+                            C_INCLUDE ] + python_includes
                 ,
                 defines = [
-                    #"__LOGMAN_ENABLED__", 
+                    "__LOGMAN_ENABLED__", 
                 ],
-                libraries = ["euser", "estlib", "avkon", "apparc", 
+                libraries = C_LIBRARY + ["euser", "avkon", "apparc", 
                              "cone","eikcore", "libGLES_CM",                             
                              PYTHON_LIB_NAME,
                              SDL_DLL_NAME,
                              "pygame.lib",
                              'pygame_libjpeg',
-                             #"LogMan"
+                             "LogMan"
                              ],
                 uid3=UID_PYGAMEAPP,
                 icons = [ ("../lib/pygame_icon.svg", "pygame") ],
                 capabilities = CAPABILITIES,
                 epocheapsize = ( 0x5000, 0x200000 ),
                 epocstacksize = 0x14000,
+                winscw_options = "-w noempty",
 )
 
 # Install pygame app resources

symbian/SConscript.jpeg.py

-# This file is generated with mmp2sconscript
+""" Defines project for JPEG library """
+Import("*")
+
 from scons_symbian import *
 
 Import("TARGET_NAME UID3 PACKAGE_NAME CAPABILITIES")
 # Built as dll because needed by SDL and the application
 target     = TARGET_NAME
 targettype = "dll"
-libraries  = ['euser', 'estlib']
+libraries  = C_LIBRARY + ['euser']
 
 # Static libs
 libraries += []
 
 
 includes    = []
-sysincludes = ['/epoc32/include', '/epoc32/include/libc']
+sysincludes = ['/epoc32/include', C_INCLUDE ]
 defines     = ['JPEG_DLL']
 
 SymbianProgram( target, targettype,

symbian/SConscript.libpng.py

+""" Defines project for PNG library """
+
+Import("*")
+
 # This file is generated with mmp2sconscript
 from scons_symbian import *
 from glob import glob
 # Built as dll because needed by SDL and the application
 target     = TARGET_NAME
 targettype = TARGETTYPE_LIB
-libraries  = ['euser', 'estlib']
+libraries  = C_LIBRARY + ['euser']
 
 # Static libs
 libraries += []
 
 
 includes    = ['deps/libpng/']
-sysincludes = ['/epoc32/include', '/epoc32/include/libc']
+sysincludes = ['/epoc32/include', C_INCLUDE ]
 defines     = []
 
 SymbianProgram( target, targettype,

symbian/SConscript.pygame.py

+Import("*")
 
 from scons_symbian import *
 import glob
 
-Import("*")
-
 python_includes = [ PYTHON_INCLUDE ]
 
 #music.c
 
 pygame_sources.append("common/builtins.c")
 
+if USE_OPENC:
+    C_LIB_INCLUDE = "OPENC"
+else:
+    C_LIB_INCLUDE = ""
+    
 # Build pygame library
 SymbianProgram( "pygame", TARGETTYPE_LIB,
                 sources = pygame_sources,
-                defines = [                    
+                defines = [ 
+                   C_LIB_INCLUDE                   
                 ],
                 includes = python_includes + [
                              "common",                             
                              join( "deps", "jpeg"),
                              join( "deps", "SDL_image"),
                              join( EPOC32_INCLUDE, "SDL"),
-                             join( EPOC32_INCLUDE, "libc"),                             
+                             C_INCLUDE,                             
                              #join( "..", "..", "tools", "debug" )
                            ],
                 package = PACKAGE_NAME,
-                libraries = [
-                     PYTHON_LIB_NAME,
-                     "euser", "estlib", "avkon", "apparc", 
+                libraries = C_LIBRARY + [
+                     PYTHON_LIB_NAME,                     
+                     "euser", "avkon", "apparc", 
                      "cone","eikcore", "libGLES_CM",                     
                      SDL_DLL_NAME,
                      ],
+                winscw_options = "-w noempty",
                 )
 
 # Install pygame python libraries

symbian/SConscript.sft2.py

-
+Import("*")
 
 # This file is generated with mmp2sconscript
 from scons_symbian import *
 
+
 target     = "libsft2"
 targettype = "lib"
-libraries  = ['euser', 'estlib', 'gdi', 'fbscli']
+libraries  = C_LIBRARY + ['euser', 'gdi', 'fbscli']
 
 # Static libs
 libraries += []
 
 
 includes    = ['deps/sft2/inc']
-sysincludes = [ EPOC32_INCLUDE +'/libc', EPOC32_INCLUDE, 'deps/sft2/inc/sys']
+sysincludes = [ C_INCLUDE, EPOC32_INCLUDE, 'deps/sft2/inc/sys']
 defines     = ['FT2_BUILD_LIBRARY', 
     #'LOGN_ENABLE', 
     #'LOGP_ENABLE', 

symbian/SConstruct

 
 # Pygame's installer package
 PACKAGE_NAME = ARGUMENTS.get( "package",    "pygame.sis" )
+
+#: Name of the title on installer.
 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" )
 
+#: Using OpenC or estlib?
+USE_OPENC = ARGUMENTS.get( "openc", True )
+if USE_OPENC:
+    C_LIBRARY = ["libc", "libm"]
+    C_INCLUDE = join( EPOC32_INCLUDE, "stdapis" )
+else:
+    C_LIBRARY = ["estlib"]
+    C_INCLUDE = join( EPOC32_INCLUDE, "libc" )
+     
 UID_PACKAGE    = ARGUMENTS.get( "sisuid" )
 UID_PYGAMEAPP  = ARGUMENTS.get( "appuid" )
 UID_SDL        = ARGUMENTS.get( "sdluid" )
     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 = None
     EMBEDDED_PYTHON_SIS_UID = 0x0
       
-Export("PACKAGE_NAME PYTHON_LIB_NAME PATH_PY_LIBS SDL_DLL_NAME CAPABILITIES PYTHON_INCLUDE")
+Export("PACKAGE_NAME PYTHON_LIB_NAME PATH_PY_LIBS SDL_DLL_NAME CAPABILITIES PYTHON_INCLUDE USE_OPENC C_LIBRARY C_INCLUDE")
 
 # Build external libraries. Conditional because needed only once and takes extra time after that.
 if ARGUMENTS.get( "buildlibs", True ):

symbian/app/pygame_main.cpp

 #include <sdl.h>
 #include <Python.h>
+
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2
 #include <CSPyInterpreter.h>
+#endif
 
 #include "logmanutils.h"
 
-extern int Frames;
-extern int Ticks;
-extern int Done;
-
-void panic(char* aWhen)
-{
-	fprintf(stderr, "SDL error: %s: %s\n", aWhen, SDL_GetError());
-	SDL_Delay(1000);
-	SDL_Quit();
-	exit(-1);
-}
-
-extern "C"
-struct _inittab _PyGame_Inittab[];
+extern "C" struct _inittab _PyGame_Inittab[];
 
 #define NL "\n"
 
-char* PYGAME_MAIN_SCRIPT_PATH[1] = {"\\data\\pygame\\pygame_main.py"};
+#ifndef PYGAME_MAIN_SCRIPT_PATH
+#define PYGAME_MAIN_SCRIPT_PATH "\\data\\pygame\\pygame_main.py"
+#endif
+static const char* gPygameMainScriptPath[1] = {PYGAME_MAIN_SCRIPT_PATH};
 
 int main(int argc, char** argv)
 {
 	// Execute the main script
-
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2
 	CSPyInterpreter* interp = CSPyInterpreter::NewInterpreterL();
-
+#else	
+	SPy_DLC_Init();
+	SPy_SetAllocator(SPy_DLC_Alloc, SPy_DLC_Realloc, SPy_DLC_Free, NULL);
+#endif
+	Py_Initialize();
+	
 	// Add built-in pygame modules
 	PyImport_ExtendInittab(_PyGame_Inittab);
 			
 	LOGMAN_SENDLOG( "Entering interpreter");
-	TInt result = interp->RunScript(1, PYGAME_MAIN_SCRIPT_PATH);
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2
+	TInt result = interp->RunScript(1, gPygameMainScriptPath);
+#else	
+	
+	LOGMAN_SENDLOGF8( "Opening file:%s", gPygameMainScriptPath[0] );
+	
+	FILE *fp = fopen(gPygameMainScriptPath[0], "r");
+	if (!fp) {
+		LOGMAN_SENDLOG( "Failed to open main script" );
+		return -1;
+	}
+	
+	// This allows us to retrieve the path of the main script in Python from sys.argv[0]
+	PySys_SetArgv(1, (char**)gPygameMainScriptPath);
+	
+	int result = PyRun_SimpleFile(fp, gPygameMainScriptPath[0]);
+	fclose(fp);
+#endif
+		
 	LOGMAN_SENDLOGF( "Interpreter result:%d", result )
-	
+
+#if PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION == 2	
 	PyEval_RestoreThread(PYTHON_TLS->thread_state);
 	Py_Finalize();
+	delete interp;
+#else
+	Py_Finalize();
+	SPy_DLC_Fini();
+#endif
 	
-	delete interp;
-
 	SDL_Quit();
 	return result;
 }

symbian/configure.py

         
     vars = [ x for x in dir(defaults) if not x.startswith("_") ]
     values = [ getattr( defaults, x ) for x in vars ]
-    defaults = zip( vars, values )
+    oldvalues = zip( vars, values )
     
+    print "=" * 79
     result = {}
     for name,value in args:
         if name not in vars:
             print "Possible configuration values are:\n", " | ".join( vars )
             raise SystemExit( )
         
+        old = getattr(defaults, name )
         try:
             # Evaluate booleans and integers
             result[name] = eval(value)
         except:
             result[name] = value
             
-        print name, "reconfigured to", value
+        print name, "reconfigured '%s' => '%s'" % ( str(old), str( value ))
     
-    for name, value in defaults:
+    for name, value in oldvalues:
         if name not in result:
             result[name] = value
     
     
     # Create the module
     print
+    print "-" * 79
     f=open("build_config.py",'w');
     keys = result.keys();keys.sort()
     for name in keys:
         value = result[name]
-        line = "%s = %s\n" % ( name, repr(value))
+        line = "%-15s = %s\n" % ( name, repr(value))
         print line.strip()
         f.write(line)
     f.close()
     
-    
+    print "=" * 79
     
 if __name__ == "__main__":
-    start()    
+    start()    

symbian/default_build_config.py

 pys60_ce_src = ''
 pys60_sis    = 'pygame_python.sis'
 pythondll    = 'pygame_python'
-
+pythoninclude= r'/epoc32/include/python25'
 # Defaults for certificates
 cert         = None
 privkey      = None

symbian/how_to_build.txt

 Checkout vorbis to symbian/deps/vorbis
 - IMPORTANT: Revision 7543
 - SVN: http://svn.xiph.org/trunk/vorbis
+- Changes for OpenC
+-- os.h:
+	#if defined(__SYMBIAN32__) && defined(__WINS__)
+	#include <sys/types.h> // <-- Add this
+	void* _alloca(size_t size);
+	#  define alloca _alloca
+	#endif
 
 Get SDL for Series60
 - Available at: http://koti.mbnet.fi/mertama/sdl.html
 
 Get Symbian FreeType2 port to symbian/deps/sft2
 - SVN: https://sft2.svn.sourceforge.net/svnroot/sft2/trunk/sft2
-
+- Changes for OpenC
+-- libsft2.cpp:
+  #include <sys/reent.h> // <-- Remove
+  ...
+  CloseSTDLIB(); in ~CSymbianFreeType() // <-- Remove
 
 Get SDL_image to symbian/deps/SDL_image
 - http://www.libsdl.org/projects/SDL_image/
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.