Export files to private directory in a Qt for Symbian project
Template:ArticleMetaData In a Symbian project, data files can be exported at the correct location under SDK emulator's file system using the prj_exports section of the bld.inf file.
...
PRJ_EXPORTS
// source destination
.\data\image1.png \epoc32\winscw\c\private\E1234567\image1.png
The example above shows how an image is exported from project's data directory to application's private directory on the emulated C drive. Each time you build this project with a new SDK the data files are exported based on the rules above and will be available to the emulated application. The only thing to consider is that if application's UID3/SID changes then these PRJ_EXPORTS rules must be updated as well, to reflect the new home directory.
In a Qt project, the Symbian specific UID3/SID is defined in the *.pro file and these allows us to write PRJ_EXPORTS rules which are automatically updated, by using the UID3/SID value in defining the path:
symbian:{
TARGET.UID3 = 0xE1234567
...
PRIVATEDIR=$$replace(TARGET.UID3, "^0x", "")
...
export_files = "./data/image1.png /epoc32/winscw/c/private/"$${PRIVATEDIR}"/image1.png"
BLD_INF_RULES.prj_exports += export_files
...
}
The solution is based on the qmake function $$replace which is used to extract the value of the UID3, without the 0x prefix, into a new variable, PRIVATEDIR, which is then used to build the path for export's destination.