44 #include <project.h> |
44 #include <project.h> |
45 #include <qxmlstream.h> |
45 #include <qxmlstream.h> |
46 #include <qsettings.h> |
46 #include <qsettings.h> |
47 #include <qdebug.h> |
47 #include <qdebug.h> |
48 |
48 |
49 #define PLUGIN_STUB_DIR "qmakepluginstubs" |
|
50 #define SYSBIN_DIR "/sys/bin" |
|
51 // Included from tools/shared |
49 // Included from tools/shared |
52 #include <symbian/epocroot.h> |
50 #include <symbian/epocroot.h> |
|
51 |
|
52 #define SYSBIN_DIR "/sys/bin" |
53 |
53 |
54 #define SUFFIX_DLL "dll" |
54 #define SUFFIX_DLL "dll" |
55 #define SUFFIX_EXE "exe" |
55 #define SUFFIX_EXE "exe" |
56 #define SUFFIX_QTPLUGIN "qtplugin" |
56 #define SUFFIX_QTPLUGIN "qtplugin" |
|
57 |
|
58 static QString fixPathToEpocOS(const QString &src) |
|
59 { |
|
60 QString ret = Option::fixPathToTargetOS(src); |
|
61 return ret.replace('/', '\\'); |
|
62 } |
57 |
63 |
58 static bool isPlugin(const QFileInfo& info, const QString& devicePath) |
64 static bool isPlugin(const QFileInfo& info, const QString& devicePath) |
59 { |
65 { |
60 // Libraries are plugins if deployment path is something else than |
66 // Libraries are plugins if deployment path is something else than |
61 // SYSBIN_DIR with or without drive letter |
67 // SYSBIN_DIR with or without drive letter |
83 const QString& devicePath, |
89 const QString& devicePath, |
84 DeploymentList &deploymentList, |
90 DeploymentList &deploymentList, |
85 QStringList& generatedDirs, |
91 QStringList& generatedDirs, |
86 QStringList& generatedFiles) |
92 QStringList& generatedFiles) |
87 { |
93 { |
88 QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR "/")); |
94 QDir().mkpath(QLatin1String(PLUGIN_STUB_DIR)); |
89 if (!generatedDirs.contains(PLUGIN_STUB_DIR)) |
95 if (!generatedDirs.contains(PLUGIN_STUB_DIR)) |
90 generatedDirs << PLUGIN_STUB_DIR; |
96 generatedDirs << PLUGIN_STUB_DIR; |
91 // Plugin stubs must have different name from the actual plugins, because |
97 // Plugin stubs must have different name from the actual plugins, because |
92 // the toolchain for creating ROM images cannot handle non-binary .dll files properly. |
98 // the toolchain for creating ROM images cannot handle non-binary .dll files properly. |
93 QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "/") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); |
99 QFile stubFile(QLatin1String(PLUGIN_STUB_DIR "/") + info.completeBaseName() + "." SUFFIX_QTPLUGIN); |
166 } |
172 } |
167 QString deploymentDrive = targetPathHasDriveLetter ? targetPath.left(2) : QLatin1String("c:"); |
173 QString deploymentDrive = targetPathHasDriveLetter ? targetPath.left(2) : QLatin1String("c:"); |
168 |
174 |
169 foreach(QString item, project->values("DEPLOYMENT")) { |
175 foreach(QString item, project->values("DEPLOYMENT")) { |
170 QString devicePath = project->first(item + ".path"); |
176 QString devicePath = project->first(item + ".path"); |
171 QString devicePathwDrive = devicePath; |
177 QString devicePathWithoutDrive = devicePath; |
172 |
178 |
173 bool devicePathHasDriveLetter = false; |
179 bool devicePathHasDriveLetter = false; |
174 if (devicePath.size() > 1) { |
180 if (devicePath.size() > 1) { |
175 devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':'); |
181 devicePathHasDriveLetter = devicePath.at(1) == QLatin1Char(':'); |
176 } |
182 } |
177 |
183 |
178 //QTP: Sometime devicePath can contain disk but APP_RESOURCE_DIR not |
184 // Sometimes devicePath can contain disk but APP_RESOURCE_DIR does not, |
179 //convert devicepath to correct format and delete drive letter |
185 // so remove the drive letter for comparison purposes. |
180 if (devicePathHasDriveLetter) |
186 if (devicePathHasDriveLetter) |
181 { |
187 { |
182 devicePathwDrive.remove(0,2); |
188 devicePathWithoutDrive.remove(0,2); |
183 } |
189 } |
184 if (!deployBinaries |
190 if (!deployBinaries |
185 && !devicePathwDrive.isEmpty() |
191 && !devicePathWithoutDrive.isEmpty() |
186 && (0 == devicePathwDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive) |
192 && (0 == devicePathWithoutDrive.compare(project->values("APP_RESOURCE_DIR").join(""), Qt::CaseInsensitive) |
187 || 0 == devicePathwDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) { |
193 || 0 == devicePathWithoutDrive.compare(project->values("REG_RESOURCE_IMPORT_DIR").join(""), Qt::CaseInsensitive))) { |
188 // Do not deploy resources in emulator builds, as that seems to cause conflicts |
194 // Do not deploy resources in emulator builds, as that seems to cause conflicts |
189 // If there is ever a real need to deploy pre-built resources for emulator, |
195 // If there is ever a real need to deploy pre-built resources for emulator, |
190 // BLD_INF_RULES.prj_exports can be used as a workaround. |
196 // BLD_INF_RULES.prj_exports can be used as a workaround. |
191 continue; |
197 continue; |
192 } |
198 } |
193 |
199 |
194 |
|
195 if (devicePath.isEmpty() || devicePath == QLatin1String(".")) { |
200 if (devicePath.isEmpty() || devicePath == QLatin1String(".")) { |
196 devicePath = targetPath; |
201 devicePath = targetPath; |
197 } |
202 } |
198 // check if item.path is relative (! either / or \) |
203 // check if item.path is relative (! either / or \) |
199 else if (!(devicePath.at(0) == QLatin1Char('/') |
204 else if (!(devicePath.at(0) == QLatin1Char('/') |
200 || devicePath.at(0) == QLatin1Char('\\') |
205 || devicePath.at(0) == QLatin1Char('\\') |
201 || devicePathHasDriveLetter)) { |
206 || devicePathHasDriveLetter)) { |
202 // create output path |
207 // Create output path |
203 devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('/') + devicePath)); |
208 devicePath = Option::fixPathToLocalOS(QDir::cleanPath(targetPath + QLatin1Char('/') + devicePath)); |
204 } else { |
209 } else { |
205 if (0 == platform.compare(QLatin1String("winscw"), Qt::CaseInsensitive)) { |
210 if (!platform.compare(QLatin1String(EMULATOR_DEPLOYMENT_PLATFORM))) { |
206 if (devicePathHasDriveLetter) { |
211 if (devicePathHasDriveLetter) { |
207 devicePath = epocRoot() + "epoc32/winscw/" + devicePath.remove(1, 1); |
212 devicePath = epocRoot() + "epoc32/winscw/" + devicePath.remove(1, 1); |
208 } else { |
213 } else { |
209 devicePath = epocRoot() + "epoc32/winscw/c" + devicePath; |
214 devicePath = epocRoot() + "epoc32/winscw/c" + devicePath; |
210 } |
215 } |
211 } else { |
216 } else { |
212 //The logic of the calling the initProjectDeploySymbian function depends only |
|
213 //from devicePathHasDriveLetter in pro files. |
|
214 //:QTP:QTPROD-92 Deployment of plugins requires WINSCW build before ARM build |
|
215 if (!devicePathHasDriveLetter) { |
217 if (!devicePathHasDriveLetter) { |
216 if (targetPathHasDriveLetter) { |
218 if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) { |
|
219 //For plugin deployment under ARM no needed drive letter |
|
220 devicePath = epocRoot() + "epoc32/data/z" + devicePath; |
|
221 } else if (targetPathHasDriveLetter) { |
217 // Drive letter needed if targetpath contains one and it is not already in |
222 // Drive letter needed if targetpath contains one and it is not already in |
218 if ( 0 == platform.compare(QLatin1String("armv5"), Qt::CaseInsensitive) ) { |
223 devicePath = deploymentDrive + devicePath; |
219 //For plugin deployment under ARM no needed drive letter |
|
220 devicePath = epocRoot() + "epoc32/data/z" + devicePath; |
|
221 } else { |
|
222 devicePath = deploymentDrive + devicePath; |
|
223 } |
|
224 } else { |
|
225 // Only deployment for ARM need full path for the deployment |
|
226 if (0 == platform.compare(QLatin1String("armv5"), Qt::CaseInsensitive) ) { |
|
227 devicePath = epocRoot() + "epoc32/data/z" + devicePath; |
|
228 } |
|
229 } |
224 } |
230 |
|
231 } else { |
225 } else { |
232 //it is necessary to delete drive letter for ARM deployment |
226 //it is necessary to delete drive letter for ARM deployment |
233 if (!platform.compare("armv5")) { |
227 if (!platform.compare(QLatin1String(ROM_DEPLOYMENT_PLATFORM))) { |
234 devicePath.remove(0,2); |
228 devicePath.remove(0,2); |
235 devicePath = epocRoot() + "epoc32/data/z" + devicePath; |
229 devicePath = epocRoot() + "epoc32/data/z" + devicePath; |
236 } |
230 } |
237 } |
231 } |
238 } |
232 } |
260 nameFilter = QLatin1String("*"); |
254 nameFilter = QLatin1String("*"); |
261 searchPath = info.absoluteFilePath(); |
255 searchPath = info.absoluteFilePath(); |
262 dirSearch = true; |
256 dirSearch = true; |
263 } else { |
257 } else { |
264 if (info.exists() || source.indexOf('*') != -1) { |
258 if (info.exists() || source.indexOf('*') != -1) { |
265 //QTP-Prod: Temporary solution due Option::fixPathToLocalOS. This function always replaces / to \ for Windows |
259 nameFilter = source.split(QDir::separator()).last(); |
266 //in the source. Changes fixPathToLocalOS requires more investigation and testing. |
|
267 #if defined(Q_OS_WIN32) |
|
268 nameFilter = source.split('\\').last(); |
|
269 #else |
|
270 nameFilter = source.split('/').last(); |
|
271 #endif |
|
272 searchPath = info.absolutePath(); |
260 searchPath = info.absolutePath(); |
273 } else { |
261 } else { |
274 // Entry was not found. That is ok if it is a binary, since those do not necessarily yet exist. |
262 // Entry was not found. That is ok if it is a binary, since those do not necessarily yet exist. |
275 // Dlls need to be processed even when not deploying binaries for the stubs |
263 // Dlls need to be processed even when not deploying binaries for the stubs |
276 if (isBinary(info)) { |
264 if (isBinary(info)) { |
277 if (deployBinaries) { |
265 if (deployBinaries) { |
278 // Executables and libraries are deployed to \sys\bin |
266 // Executables and libraries are deployed to \sys\bin |
279 QFileInfo releasePath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/"); |
267 QFileInfo targetPath(epocRoot() + "epoc32/release/" + platform + "/" + build + "/"); |
280 if(devicePathHasDriveLetter) { |
268 if(devicePathHasDriveLetter) { |
281 deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "/" + info.fileName(), false, true), |
269 deploymentList.append(CopyItem( |
282 Option::fixPathToLocalOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") + info.fileName()))); |
270 Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(), |
|
271 false, true), |
|
272 fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") |
|
273 + info.fileName()))); |
283 } else { |
274 } else { |
284 deploymentList.append(CopyItem(Option::fixPathToLocalOS(releasePath.absolutePath() + "/" + info.fileName(), false, true), |
275 deploymentList.append(CopyItem( |
285 Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + info.fileName()))); |
276 Option::fixPathToLocalOS(targetPath.absolutePath() + "/" + info.fileName(), |
|
277 false, true), |
|
278 fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") |
|
279 + info.fileName()))); |
286 } |
280 } |
287 } |
281 } |
288 if (isPlugin(info, devicePath)) { |
282 if (isPlugin(info, devicePath)) { |
289 createPluginStub(info, devicePath, deploymentList, generatedDirs, generatedFiles); |
283 createPluginStub(info, devicePath, deploymentList, generatedDirs, generatedFiles); |
290 continue; |
284 continue; |
291 } |
285 } |
292 } else { |
286 } else { |
293 // Generate deployment even if file doesn't exist, as this may be the case |
287 // Generate deployment even if file doesn't exist, as this may be the case |
294 // when generating .pkg files. |
288 // when generating .pkg files. |
295 deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()), |
289 deploymentList.append(CopyItem(Option::fixPathToLocalOS(info.absoluteFilePath()), |
296 Option::fixPathToLocalOS(devicePath + "/" + info.fileName()))); |
290 fixPathToEpocOS(devicePath + "/" + info.fileName()))); |
297 continue; |
291 continue; |
298 } |
292 } |
299 } |
293 } |
300 } |
294 } |
301 |
295 |
313 if (!iteratorInfo.isDir()) { |
307 if (!iteratorInfo.isDir()) { |
314 if (isPlugin(iterator.fileInfo(), devicePath)) { |
308 if (isPlugin(iterator.fileInfo(), devicePath)) { |
315 // This deploys pre-built plugins. Other pre-built binaries will deploy normally, |
309 // This deploys pre-built plugins. Other pre-built binaries will deploy normally, |
316 // as they have SYSBIN_DIR target path. |
310 // as they have SYSBIN_DIR target path. |
317 if (deployBinaries) { |
311 if (deployBinaries) { |
318 deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), |
312 if (devicePathHasDriveLetter) { |
319 Option::fixPathToLocalOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") + iterator.fileName()))); |
313 deploymentList.append(CopyItem( |
|
314 Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), |
|
315 fixPathToEpocOS(devicePath.left(2) + QLatin1String(SYSBIN_DIR "/") |
|
316 + iterator.fileName()))); |
|
317 } else { |
|
318 deploymentList.append(CopyItem( |
|
319 Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), |
|
320 fixPathToEpocOS(deploymentDrive + QLatin1String(SYSBIN_DIR "/") |
|
321 + iterator.fileName()))); |
|
322 } |
320 } |
323 } |
321 createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize), deploymentList, generatedDirs, generatedFiles); |
324 createPluginStub(info, devicePath + "/" + absoluteItemPath.right(diffSize), |
|
325 deploymentList, generatedDirs, generatedFiles); |
322 continue; |
326 continue; |
323 } else { |
327 } else { |
324 deploymentList.append(CopyItem(Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), |
328 deploymentList.append(CopyItem( |
325 Option::fixPathToLocalOS(devicePath + "/" + absoluteItemPath.right(diffSize) + "/" + iterator.fileName()))); |
329 Option::fixPathToLocalOS(absoluteItemPath + "/" + iterator.fileName()), |
|
330 fixPathToEpocOS(devicePath + "/" + absoluteItemPath.right(diffSize) |
|
331 + "/" + iterator.fileName()))); |
326 } |
332 } |
327 } |
333 } |
328 } |
334 } |
329 } |
335 } |
330 } |
336 } |
331 } |
337 } |
332 |
|
333 //:QTP:QTPROD-92 Deployment of plugins requires WINSCW build before ARM build |
|
334 void writeSbsDeploymentList(const DeploymentList& depList, QTextStream& t) |
|
335 { |
|
336 for (int i = 0; i < depList.size(); ++i) { |
|
337 t << "START EXTENSION qt/qmake_emulator_deployment" << endl; |
|
338 QString fromItem = depList.at(i).from; |
|
339 QString toItem = depList.at(i).to; |
|
340 fromItem.replace("\\", "/"); |
|
341 toItem.replace("\\", "/"); |
|
342 t << "OPTION DEPLOY_SOURCE " << fromItem << endl; |
|
343 t << "OPTION DEPLOY_TARGET " << toItem << endl; |
|
344 t << "END" << endl; |
|
345 } |
|
346 } |
|