Android: JavaParser, adjust paths from build to source directory

Since we copy the java files to the build directory, we need to adjust
the path that the java compiler emits for error messages.

For that the JavaParser needs to know the source directory, which is
the android package source dir and the build directory. The
AndroidDeployQtStep thus needs more information then just the
input json file and now stores the path to the .pro file to both
retrieve the input file and the android package source directory.

Task-number: QTCREATORBUG-10904
Change-Id: Ib5141b35b610bc2eee568a096fc5e930f9eb2e47
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@digia.com>
This commit is contained in:
Daniel Teske
2014-01-08 09:33:21 +01:00
parent 02314e24f0
commit 498d198104
5 changed files with 70 additions and 37 deletions

View File

@@ -61,6 +61,7 @@ const QLatin1String SignPackageKey("SignPackage");
const QLatin1String BuildTargetSdkKey("BuildTargetSdk");
const QLatin1String VerboseOutputKey("VerboseOutput");
const QLatin1String InputFile("InputFile");
const QLatin1String ProFilePathForInputFile("ProFilePathForInputFile");
const Core::Id AndroidDeployQtStep::Id("Qt4ProjectManager.AndroidDeployQtStep");
//////////////////
@@ -213,9 +214,9 @@ bool AndroidDeployQtStep::init()
if (!version)
return false;
ProjectExplorer::Project *project = target()->project();
QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project());
JavaParser *parser = new JavaParser;
parser->setProjectFileList(project->files(ProjectExplorer::Project::AllFiles));
parser->setProjectFileList(pro->files(ProjectExplorer::Project::AllFiles));
setOutputParser(parser);
QString command = version->qmakeProperty("QT_HOST_BINS");
@@ -234,10 +235,21 @@ bool AndroidDeployQtStep::init()
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")
<< m_inputFile
<< inputFile
<< QLatin1String("--output")
<< outputDir
<< QLatin1String("--deployment")
@@ -250,6 +262,9 @@ bool AndroidDeployQtStep::init()
<< QLatin1String("--jdk")
<< AndroidConfigurations::instance().openJDKPath().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())
@@ -347,17 +362,12 @@ void AndroidDeployQtStep::updateInputFile()
QmakeProjectManager::QmakeProject *pro = static_cast<QmakeProjectManager::QmakeProject *>(project());
QList<QmakeProjectManager::QmakeProFileNode *> nodes = pro->applicationProFiles();
QStringList inputFiles;
foreach (QmakeProjectManager::QmakeProFileNode *node, nodes)
inputFiles << node->singleVariableValue(QmakeProjectManager::AndroidDeploySettingsFile);
if (!inputFiles.contains(m_inputFile))
m_inputFile.clear();
if (m_inputFile.isEmpty()) {
// not yet selected one or no longer exists
if (!inputFiles.isEmpty())
m_inputFile = inputFiles.first();
const QmakeProjectManager::QmakeProFileNode *node = pro->rootQmakeProjectNode()->findProFileFor(m_proFilePathForInputFile);
if (!nodes.contains(const_cast<QmakeProjectManager::QmakeProFileNode *>(node))) {
if (!nodes.isEmpty())
m_proFilePathForInputFile = nodes.first()->path();
else
m_proFilePathForInputFile.clear();
}
emit inputFileChanged();
@@ -388,7 +398,7 @@ bool AndroidDeployQtStep::fromMap(const QVariantMap &map)
m_signPackage = false; // don't restore this
m_buildTargetSdk = map.value(BuildTargetSdkKey).toString();
m_verbose = map.value(VerboseOutputKey).toBool();
m_inputFile = map.value(InputFile).toString();
m_proFilePathForInputFile = map.value(ProFilePathForInputFile).toString();
return ProjectExplorer::BuildStep::fromMap(map);
}
@@ -400,7 +410,7 @@ QVariantMap AndroidDeployQtStep::toMap() const
map.insert(SignPackageKey, m_signPackage);
map.insert(BuildTargetSdkKey, m_buildTargetSdk);
map.insert(VerboseOutputKey, m_verbose);
map.insert(InputFile, m_inputFile);
map.insert(ProFilePathForInputFile, m_proFilePathForInputFile);
return map;
}
@@ -481,14 +491,14 @@ void AndroidDeployQtStep::setVerboseOutput(bool verbose)
m_verbose = verbose;
}
QString AndroidDeployQtStep::inputFile() const
QString AndroidDeployQtStep::proFilePathForInputFile() const
{
return m_inputFile;
return m_proFilePathForInputFile;
}
void AndroidDeployQtStep::setInputFile(const QString &file)
void AndroidDeployQtStep::setProFilePathForInputFile(const QString &path)
{
m_inputFile = file;
m_proFilePathForInputFile = path;
}
bool AndroidDeployQtStep::runInGuiThread() const