forked from qt-creator/qt-creator
Fix that clang static analyzer did not find built-in headers
Clang expects these to lie in "../lib/clang" relative to the clang executable. Change-Id: I216860876591dca1fd728e4b1e79b4b07c965620 Reviewed-by: Eike Ziller <eike.ziller@qt.io> Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -200,28 +200,36 @@ def copyPreservingLinks(source, destination):
|
||||
def deploy_libclang(install_dir, llvm_install_dir, chrpath_bin):
|
||||
# contains pairs of (source, target directory)
|
||||
deployinfo = []
|
||||
resourcesource = os.path.join(llvm_install_dir, 'lib', 'clang')
|
||||
if common.is_windows_platform():
|
||||
clangbindirtarget = os.path.join(install_dir, 'bin', 'clang', 'bin')
|
||||
if not os.path.exists(clangbindirtarget):
|
||||
os.makedirs(clangbindirtarget)
|
||||
clanglibdirtarget = os.path.join(install_dir, 'bin', 'clang', 'lib')
|
||||
if not os.path.exists(clanglibdirtarget):
|
||||
os.makedirs(clanglibdirtarget)
|
||||
deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'libclang.dll'),
|
||||
os.path.join(install_dir, 'bin')))
|
||||
deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'clang.exe'),
|
||||
os.path.join(install_dir, 'bin')))
|
||||
clangbindirtarget))
|
||||
deployinfo.append((os.path.join(llvm_install_dir, 'bin', 'clang-cl.exe'),
|
||||
os.path.join(install_dir, 'bin')))
|
||||
clangbindirtarget))
|
||||
resourcetarget = os.path.join(clanglibdirtarget, 'clang')
|
||||
else:
|
||||
libsources = glob(os.path.join(llvm_install_dir, 'lib', 'libclang.so*'))
|
||||
for libsource in libsources:
|
||||
deployinfo.append((libsource, os.path.join(install_dir, 'lib', 'qtcreator')))
|
||||
clangbinary = os.path.join(llvm_install_dir, 'bin', 'clang')
|
||||
clangbinary_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator')
|
||||
clangbinary_targetdir = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'bin')
|
||||
if not os.path.exists(clangbinary_targetdir):
|
||||
os.makedirs(clangbinary_targetdir)
|
||||
deployinfo.append((clangbinary, clangbinary_targetdir))
|
||||
# copy link target if clang is actually a symlink
|
||||
if os.path.islink(clangbinary):
|
||||
linktarget = os.readlink(clangbinary)
|
||||
deployinfo.append((os.path.join(os.path.dirname(clangbinary), linktarget),
|
||||
os.path.join(clangbinary_targetdir, linktarget)))
|
||||
|
||||
resourcesource = os.path.join(llvm_install_dir, 'lib', 'clang')
|
||||
resourcetarget = os.path.join(install_dir, 'share', 'qtcreator', 'cplusplus', 'clang')
|
||||
resourcetarget = os.path.join(install_dir, 'libexec', 'qtcreator', 'clang', 'lib', 'clang')
|
||||
|
||||
print "copying libclang..."
|
||||
for source, target in deployinfo:
|
||||
|
@@ -91,13 +91,15 @@ if [ $LLVM_INSTALL_DIR ]; then
|
||||
echo "- Copying libclang"
|
||||
mkdir -p "$1/Contents/Frameworks" || exit 1
|
||||
# use recursive copy to make it copy symlinks as symlinks
|
||||
mkdir -p "$1/Contents/Resources/clang/bin"
|
||||
mkdir -p "$1/Contents/Resources/clang/lib"
|
||||
cp -Rf "$LLVM_INSTALL_DIR"/lib/libclang.*dylib "$1/Contents/Frameworks/" || exit 1
|
||||
cp -Rf "$LLVM_INSTALL_DIR"/lib/clang "$1/Contents/Resources/cplusplus/" || exit 1
|
||||
cp -Rf "$LLVM_INSTALL_DIR"/lib/clang "$1/Contents/Resources/clang/lib/" || exit 1
|
||||
clangsource="$LLVM_INSTALL_DIR"/bin/clang
|
||||
clanglinktarget="$(readlink "$clangsource")"
|
||||
cp -Rf "$clangsource" "$1/Contents/Resources/" || exit 1
|
||||
cp -Rf "$clangsource" "$1/Contents/Resources/clang/bin/" || exit 1
|
||||
if [ $clanglinktarget ]; then
|
||||
cp -Rf "$(dirname "$clangsource")/$clanglinktarget" "$1/Contents/Resources/$clanglinktarget" || exit 1
|
||||
cp -Rf "$(dirname "$clangsource")/$clanglinktarget" "$1/Contents/Resources/clang/bin/$clanglinktarget" || exit 1
|
||||
fi
|
||||
fi
|
||||
_CLANG_CODEMODEL_LIB="$1/Contents/PlugIns/libClangCodeModel_debug.dylib"
|
||||
|
@@ -71,8 +71,10 @@ QStringList createClangOptions(const ProjectPart::Ptr &pPart, const QString &fil
|
||||
|
||||
static QString getResourceDir()
|
||||
{
|
||||
QDir dir(ICore::instance()->resourcePath() + QLatin1String("/cplusplus/clang/") +
|
||||
QLatin1String(CLANG_VERSION) + QLatin1String("/include"));
|
||||
QDir dir(ICore::libexecPath()
|
||||
+ QLatin1String("/clang/lib/clang/")
|
||||
+ QLatin1String(CLANG_VERSION)
|
||||
+ QLatin1String("/include"));
|
||||
if (!dir.exists() || !QFileInfo(dir, QLatin1String("stdint.h")).exists())
|
||||
dir = QDir(QLatin1String(CLANG_RESOURCE_DIR));
|
||||
return dir.canonicalPath();
|
||||
|
@@ -60,7 +60,8 @@ static QString clangExecutableFileName()
|
||||
|
||||
QString ClangStaticAnalyzerSettings::defaultClangExecutable() const
|
||||
{
|
||||
const QString shippedBinary = Core::ICore::libexecPath() + QLatin1Char('/')
|
||||
const QString shippedBinary = Core::ICore::libexecPath()
|
||||
+ QLatin1String("/clang/bin/")
|
||||
+ clangExecutableFileName();
|
||||
if (QFileInfo(shippedBinary).isExecutable())
|
||||
return shippedBinary;
|
||||
|
Reference in New Issue
Block a user