Android: Force reset/update of pre-existing toolchains

Toolchains are only (re-)created if the NDK changes. And till now, the
environment for the toolchain was only set during its creation.

However, if the user only changes the JDK location, we don't want to
recreate the toolchain but to still update the JAVA_HOME variable for
the environment.

This change does so that resetToolChain() is called also for pre-
existing toolchains (not just the newly created ones). That triggers a
call of addToEnvironment(), which sets the potentially updated JAVA_HOME
variable.

Fixes: QTCREATORBUG-28827
Change-Id: Id55f59f3ef3c8bfbb2b811052e0f60f495843dc3
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
This commit is contained in:
Alessandro Portale
2023-03-30 18:31:09 +02:00
parent 031f51794a
commit 06427a038b

View File

@@ -230,9 +230,14 @@ ToolChainList AndroidToolChainFactory::autodetectToolChainsFromNdks(
atc->setPlatformCodeGenFlags({"-target", target});
atc->setPlatformLinkerFlags({"-target", target});
atc->setDisplayName(displayName);
atc->resetToolChain(compilerCommand);
tc = atc;
}
// Do not only reset newly created toolchains. This triggers call to
// addToEnvironment, so that e.g. JAVA_HOME gets updated.
if (auto gccTc = dynamic_cast<GccToolChain*>(tc))
gccTc->resetToolChain(compilerCommand);
tc->setDetection(ToolChain::AutoDetection);
result << tc;
++targetItr;