bool AndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps) { ProjectExplorer::BuildConfiguration *bc = buildConfiguration(); if (m_signPackage) { // check keystore and certificate passwords while (!AndroidManager::checkKeystorePassword(m_keystorePath.toString(), m_keystorePasswd)) { if (!keystorePassword()) return false; // user canceled } while (!AndroidManager::checkCertificatePassword(m_keystorePath.toString(), m_keystorePasswd, m_certificateAlias, m_certificatePasswd)) { if (!certificatePassword()) return false; // user canceled } if (bc->buildType() != ProjectExplorer::BuildConfiguration::Release) emit addOutput(tr("Warning: Signing a debug or profile package."), BuildStep::ErrorMessageOutput); } QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (!version) return false; JavaParser *parser = new JavaParser; parser->setProjectFileList(target()->project()->files(ProjectExplorer::Project::AllFiles)); parser->setSourceDirectory(androidPackageSourceDir()); parser->setBuildDirectory(Utils::FileName::fromString(bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString())); setOutputParser(parser); m_openPackageLocationForRun = m_openPackageLocation; m_apkPath = AndroidManager::androidQtSupport(target())->apkPath(target()).toString(); bool result = AbstractProcessStep::init(earlierSteps); if (!result) return false; return true; }
bool AndroidDeployQtStep::init() { if (AndroidManager::checkForQt51Files(project()->projectDirectory())) emit addOutput(tr("Found old android folder in source directory. Qt 5.2 does not use that folder by default."), ErrorOutput); m_targetArch = AndroidManager::targetArch(target()); m_deviceAPILevel = AndroidManager::minimumSDK(target()); AndroidDeviceInfo info = AndroidConfigurations::instance().showDeviceDialog(project(), m_deviceAPILevel, m_targetArch); if (info.serialNumber.isEmpty()) // aborted return false; if (info.type == AndroidDeviceInfo::Emulator) { m_avdName = info.serialNumber; m_serialNumber.clear(); m_deviceAPILevel = info.sdk; } else { m_avdName.clear(); m_serialNumber = info.serialNumber; } Qt4ProjectManager::Qt4BuildConfiguration *bc = static_cast<Qt4ProjectManager::Qt4BuildConfiguration *>(target()->activeBuildConfiguration()); if (m_signPackage) { // check keystore and certificate passwords while (!AndroidManager::checkKeystorePassword(m_keystorePath.toString(), m_keystorePasswd)) { if (!keystorePassword()) return false; // user canceled } while (!AndroidManager::checkCertificatePassword(m_keystorePath.toString(), m_keystorePasswd, m_certificateAlias, m_certificatePasswd)) { if (!certificatePassword()) return false; // user canceled } if ((bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild)) emit addOutput(tr("Warning: Signing a debug package."), BuildStep::ErrorMessageOutput); } QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (!version) return false; ProjectExplorer::Project *project = target()->project(); JavaParser *parser = new JavaParser; parser->setProjectFileList(project->files(ProjectExplorer::Project::AllFiles)); setOutputParser(parser); QString command = version->qmakeProperty("QT_HOST_BINS"); if (!command.endsWith(QLatin1Char('/'))) command += QLatin1Char('/'); command += QLatin1String("androiddeployqt"); if (Utils::HostOsInfo::isWindowsHost()) command += QLatin1String(".exe"); QString deploymentMethod; if (m_deployAction == MinistroDeployment) deploymentMethod = QLatin1String("ministro"); else if (m_deployAction == DebugDeployment) deploymentMethod = QLatin1String("debug"); else if (m_deployAction == BundleLibrariesDeployment) deploymentMethod = QLatin1String("bundled"); QString outputDir = bc->buildDirectory().appendPath(QLatin1String("android")).toString(); QStringList arguments; arguments << QLatin1String("--input") << m_inputFile << QLatin1String("--output") << outputDir << QLatin1String("--deployment") << deploymentMethod << QLatin1String("--install") << QLatin1String("--ant") << AndroidConfigurations::instance().antToolPath().toString() << QLatin1String("--android-platform") << m_buildTargetSdk << QLatin1String("--jdk") << AndroidConfigurations::instance().openJDKPath().toString(); if (m_verbose) arguments << QLatin1String("--verbose"); if (m_avdName.isEmpty()) arguments << QLatin1String("--device") << info.serialNumber; if (m_signPackage) { arguments << QLatin1String("--sign") << m_keystorePath.toString() << m_certificateAlias << QLatin1String("--storepass") << m_keystorePasswd; if (!m_certificatePasswd.isEmpty()) arguments << QLatin1String("--keypass") << m_certificatePasswd; } ProjectExplorer::ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setWorkingDirectory(bc->buildDirectory().toString()); Utils::Environment env = bc->environment(); // Force output to english for the parsers. Do this here and not in the toolchain's // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); pp->setCommand(command); pp->setArguments(Utils::QtcProcess::joinArgs(arguments)); pp->resolveAll(); m_openPackageLocationForRun = m_openPackageLocation; m_apkPath = AndroidManager::apkPath(target(), m_signPackage ? AndroidManager::ReleaseBuildSigned : AndroidManager::DebugBuild).toString(); m_buildDirectory = bc->buildDirectory().toString(); bool result = AbstractProcessStep::init(); if (!result) return false; AndroidConfigurations::instance().startAVDAsync(m_avdName); return true; }
bool AndroidDeployQtStep::init() { if (AndroidManager::checkForQt51Files(project()->projectDirectory())) emit addOutput(tr("Found old folder \"android\" in source directory. Qt 5.2 does not use that folder by default."), ErrorOutput); m_targetArch = AndroidManager::targetArch(target()); if (m_targetArch.isEmpty()) { emit addOutput(tr("No Android arch set by the .pro file."), ErrorOutput); return false; } m_deviceAPILevel = AndroidManager::minimumSDK(target()); AndroidDeviceInfo info = AndroidConfigurations::showDeviceDialog(project(), m_deviceAPILevel, m_targetArch); if (info.serialNumber.isEmpty()) // aborted return false; if (info.type == AndroidDeviceInfo::Emulator) { m_avdName = info.serialNumber; m_serialNumber.clear(); m_deviceAPILevel = info.sdk; } else { m_avdName.clear(); m_serialNumber = info.serialNumber; } QmakeProjectManager::QmakeBuildConfiguration *bc = static_cast<QmakeProjectManager::QmakeBuildConfiguration *>(target()->activeBuildConfiguration()); if (m_signPackage) { // check keystore and certificate passwords while (!AndroidManager::checkKeystorePassword(m_keystorePath.toString(), m_keystorePasswd)) { if (!keystorePassword()) return false; // user canceled } while (!AndroidManager::checkCertificatePassword(m_keystorePath.toString(), m_keystorePasswd, m_certificateAlias, m_certificatePasswd)) { if (!certificatePassword()) return false; // user canceled } if ((bc->qmakeBuildConfiguration() & QtSupport::BaseQtVersion::DebugBuild)) emit addOutput(tr("Warning: Signing a debug package."), BuildStep::ErrorMessageOutput); } QtSupport::BaseQtVersion *version = QtSupport::QtKitInformation::qtVersion(target()->kit()); if (!version) return false; QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project()); JavaParser *parser = new JavaParser; parser->setProjectFileList(pro->files(ProjectExplorer::Project::AllFiles)); setOutputParser(parser); QString command = version->qmakeProperty("QT_HOST_BINS"); if (!command.endsWith(QLatin1Char('/'))) command += QLatin1Char('/'); command += QLatin1String("androiddeployqt"); if (Utils::HostOsInfo::isWindowsHost()) command += QLatin1String(".exe"); QString deploymentMethod; if (m_deployAction == MinistroDeployment) deploymentMethod = QLatin1String("ministro"); else if (m_deployAction == DebugDeployment) deploymentMethod = QLatin1String("debug"); else if (m_deployAction == BundleLibrariesDeployment) deploymentMethod = QLatin1String("bundled"); QString outputDir = bc->buildDirectory().appendPath(QLatin1String(Constants::ANDROID_BUILDDIRECTORY)).toString(); const QmakeProjectManager::QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile); if (!node) { // should never happen emit addOutput(tr("Internal Error: Could not find .pro file."), BuildStep::ErrorMessageOutput); return false; } QString inputFile = node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile); if (inputFile.isEmpty()) { // should never happen emit addOutput(tr("Internal Error: Unknown Android deployment JSON file location."), BuildStep::ErrorMessageOutput); return false; } QStringList arguments; arguments << QLatin1String("--input") << inputFile << QLatin1String("--output") << outputDir << QLatin1String("--deployment") << deploymentMethod << QLatin1String("--install") << QLatin1String("--ant") << AndroidConfigurations::currentConfig().antToolPath().toString() << QLatin1String("--android-platform") << m_buildTargetSdk << QLatin1String("--jdk") << AndroidConfigurations::currentConfig().openJDKLocation().toString(); parser->setSourceDirectory(Utils::FileName::fromString(node->singleVariableValue(QmakeProjectManager::AndroidPackageSourceDir))); parser->setBuildDirectory(Utils::FileName::fromString(outputDir)); if (m_verbose) arguments << QLatin1String("--verbose"); if (m_avdName.isEmpty()) arguments << QLatin1String("--device") << info.serialNumber; if (m_signPackage) { arguments << QLatin1String("--sign") << m_keystorePath.toString() << m_certificateAlias << QLatin1String("--storepass") << m_keystorePasswd; if (!m_certificatePasswd.isEmpty()) arguments << QLatin1String("--keypass") << m_certificatePasswd; } ProjectExplorer::ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setWorkingDirectory(bc->buildDirectory().toString()); Utils::Environment env = bc->environment(); pp->setEnvironment(env); pp->setCommand(command); pp->setArguments(Utils::QtcProcess::joinArgs(arguments)); pp->resolveAll(); m_openPackageLocationForRun = m_openPackageLocation; m_apkPath = AndroidManager::apkPath(target(), m_signPackage ? AndroidManager::ReleaseBuildSigned : AndroidManager::DebugBuild).toString(); m_buildDirectory = bc->buildDirectory().toString(); bool result = AbstractProcessStep::init(); if (!result) return false; if (AndroidConfigurations::currentConfig().findAvd(m_deviceAPILevel, m_targetArch).isEmpty()) AndroidConfigurations::currentConfig().startAVDAsync(m_avdName); return true; }