Sunday, August 5, 2007

XCode Plugin for Symbian OS

I found a very interesting XCode plugin that allows for Symbian development on the Mac. Although I have Parallels, I find it really frustrating to have to constantly switch your IDE.

A compiled release of the plugin can be found on:
http://www.tomsci.com/xcodeplugin/

In version 1.1, there is a convenient utility called "installsdk.app" that extracts the SDK directories from the setup.exe for windows so you don't need a windows installation to unpack the necessary directory structure. I am currently using the "Series 60 2nd Edition, Feature Pack 3" to program for the Nokia N70. Extracting the SDK seemed to work pretty well.

However for python extension development, I also needed to download and extract the "Python for Series 60 1.2 for Series 60 2nd Edition Feature Pack 3 SDK". Unfortunately, the "installsdk.app" did not support extracting this SDK. In order to resolve this, I needed to install everything on a windows machine, then transfer the resulting SDK tree over to the mac. This is relatively easy if you have a VM running like Parallels. As mentioned in an earlier pyrex post, make sure that python-port-s60\symbian_python\symbian\pyconfig.h in the SDK directory has BAD_STATIC_FORWARD defined.

With the copied SDK tree, I was able to build my existing vanilla Symbian projects out of the box. One confusing thing for people who are used to develop on the Mac is that the build target is actually in the EPOCROOT path. For example, $EPOCROOT\epoc32\release\armi\urel\ (depending on your build settings).

After a little digging, I found that the "abld freeze" step required for DLLs is supported in XCode. Here is a snippet from the XCode readme:
"* DEF files are supported for DLLs - everything is specified in the build settings. To perform a freeze, change the "Freeze Settings" to "Freeze during next build" then perform a build. There is no separate command equivalent to "abld freeze", you just do a build with this setting on and it freezes as part of the build process."

The only problem remaining is that PETRAN (build 175) on the mac seems to be more sensitive to initialized data. I am able to successfully build a .pyd file on windows with PETRAN (build 192). However on the mac, I get the following error during the build:

PETRAN - PE file preprocessor V01.00 (Build 175)
Copyright (c) 1996-2001 Symbian Ltd.

NumberOfFunctions[1]
ERROR: Dll 'mylibrary.pyd' has initialised data.


I found an interesting article about the problem on NewLC. But I don't understand exactly why its only a problem on the mac. Perhaps it is a difference in the versions of PETRAN ...

Update: For the PETRAN problem, it turns out that the MMP importer for XCode does not properly process the following MMP commands:

EPOCDATALINKADDRESS 0x33300000
EPOCALLOWDLLDATA
EPOCCALLDLLENTRYPOINTS

That should result in the following parameters being added to the petran command:
-allow -datalinkaddress 0x33300000

I haven't figured out how to fix the XCode project to properly include these command-line parameters, until then you may have to add the commands manually from the command line.

Friday, August 3, 2007

Building s60 pyrex libraries

Pyrex is a great tool for building python extensions. Generally, pyrex libraries help you build a wrapper around a standard c++ library, which looks like any other c++ library, to allow accessing this library from python.

See the following Nokia forum post on pyrex To start, you need to make sure that the python SDK is installed. You need to make sure that python-port-s60\symbian_python\symbian\pyconfig.h in the SDK directory has BAD_STATIC_FORWARD defined.

When building s60pyrex libraries, it is important to freeze the library exports, otherwise only the .dll library (not the .lib) will be built:

Here are the sequence of commands
- abld reallyclean
- bldmake bldfiles
- abld build armi urel
- abld freeze armi (freeze exports for DLL)
- abld clean (*important - rebuild dll*)
- abld build armi urel

Thursday, August 2, 2007

Centering Text

One of the things that has been perplexing us is how to center text in Python.

The Canvas.text() api only allows for a specific X,Y location. We are still looking for a textbox object or something similar to allow for centered text. Does anyone know of a solution?