forked from qt-creator/qt-creator
Android: Move some generic apk build step code to base
Change-Id: Id11e5d684e2e1003178d06b4421ec34df334fca2 Reviewed-by: Vikas Pachdha <vikas.pachdha@qt.io>
This commit is contained in:
@@ -59,6 +59,8 @@
|
||||
|
||||
#include <memory>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Android {
|
||||
using namespace Internal;
|
||||
|
||||
@@ -68,6 +70,20 @@ const char BuildTargetSdkKey[] = "BuildTargetSdk";
|
||||
const char VerboseOutputKey[] = "VerboseOutput";
|
||||
const char UseMinistroKey[] = "UseMinistro";
|
||||
|
||||
static void setupProcessParameters(ProcessParameters *pp,
|
||||
BuildConfiguration *bc,
|
||||
const QStringList &arguments,
|
||||
const QString &command)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
class PasswordInputDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -158,10 +174,77 @@ bool AndroidBuildApkStep::init(QList<const BuildStep *> &earlierSteps)
|
||||
m_openPackageLocationForRun = m_openPackageLocation;
|
||||
m_apkPath = qtSupport->apkPath(target()).toString();
|
||||
|
||||
bool result = AbstractProcessStep::init(earlierSteps);
|
||||
if (!result)
|
||||
if (!AbstractProcessStep::init(earlierSteps))
|
||||
return false;
|
||||
|
||||
QString command = version->qmakeProperty("QT_HOST_BINS");
|
||||
if (!command.endsWith('/'))
|
||||
command += '/';
|
||||
command += "androiddeployqt";
|
||||
if (Utils::HostOsInfo::isWindowsHost())
|
||||
command += ".exe";
|
||||
|
||||
QString outputDir = bc->buildDirectory().appendPath(Constants::ANDROID_BUILDDIRECTORY).toString();
|
||||
|
||||
QString inputFile = AndroidManager::androidQtSupport(target())
|
||||
->targetDataItem(Constants::AndroidDeploySettingsFile, target());
|
||||
if (inputFile.isEmpty()) {
|
||||
m_skipBuilding = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
QString buildTargetSdk = AndroidManager::buildTargetSDK(target());
|
||||
if (buildTargetSdk.isEmpty()) {
|
||||
emit addOutput(tr("Android build SDK not defined. Check Android settings."),
|
||||
OutputFormat::Stderr);
|
||||
return false;
|
||||
}
|
||||
|
||||
QStringList arguments = {"--input", inputFile,
|
||||
"--output", outputDir,
|
||||
"--android-platform", AndroidManager::buildTargetSDK(target()),
|
||||
"--jdk", AndroidConfigurations::currentConfig().openJDKLocation().toString()};
|
||||
|
||||
if (m_verbose)
|
||||
arguments << "--verbose";
|
||||
|
||||
arguments << "--gradle";
|
||||
|
||||
if (m_useMinistro)
|
||||
arguments << "--deployment" << "ministro";
|
||||
|
||||
QStringList argumentsPasswordConcealed = arguments;
|
||||
|
||||
if (m_signPackage) {
|
||||
arguments << "--sign" << m_keystorePath.toString() << m_certificateAlias
|
||||
<< "--storepass" << m_keystorePasswd;
|
||||
argumentsPasswordConcealed << "--sign" << "******"
|
||||
<< "--storepass" << "******";
|
||||
if (!m_certificatePasswd.isEmpty()) {
|
||||
arguments << "--keypass" << m_certificatePasswd;
|
||||
argumentsPasswordConcealed << "--keypass" << "******";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Must be the last option, otherwise androiddeployqt might use the other
|
||||
// params (e.g. --sign) to choose not to add gdbserver
|
||||
if (version->qtVersion() >= QtSupport::QtVersionNumber(5, 6, 0)) {
|
||||
if (m_addDebugger || bc->buildType() == ProjectExplorer::BuildConfiguration::Debug)
|
||||
arguments << "--gdbserver";
|
||||
else
|
||||
arguments << "--no-gdbserver";
|
||||
}
|
||||
|
||||
ProjectExplorer::ProcessParameters *pp = processParameters();
|
||||
setupProcessParameters(pp, bc, arguments, command);
|
||||
|
||||
// Generate arguments with keystore password concealed
|
||||
ProjectExplorer::ProcessParameters pp2;
|
||||
setupProcessParameters(&pp2, bc, argumentsPasswordConcealed, command);
|
||||
m_command = pp2.effectiveCommand();
|
||||
m_argumentsPasswordConcealed = pp2.prettyArguments();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -226,6 +309,24 @@ bool AndroidBuildApkStep::verifyCertificatePassword()
|
||||
return success;
|
||||
}
|
||||
|
||||
void AndroidBuildApkStep::run(QFutureInterface<bool> &fi)
|
||||
{
|
||||
if (m_skipBuilding) {
|
||||
emit addOutput(tr("No application .pro file found, not building an APK."), BuildStep::OutputFormat::ErrorMessage);
|
||||
reportRunResult(fi, true);
|
||||
return;
|
||||
}
|
||||
AbstractProcessStep::run(fi);
|
||||
}
|
||||
|
||||
void AndroidBuildApkStep::processStarted()
|
||||
{
|
||||
emit addOutput(tr("Starting: \"%1\" %2")
|
||||
.arg(QDir::toNativeSeparators(m_command),
|
||||
m_argumentsPasswordConcealed),
|
||||
BuildStep::OutputFormat::NormalMessage);
|
||||
}
|
||||
|
||||
bool AndroidBuildApkStep::fromMap(const QVariantMap &map)
|
||||
{
|
||||
m_keystorePath = Utils::FileName::fromString(map.value(KeystoreLocationKey).toString());
|
||||
|
||||
Reference in New Issue
Block a user