Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
utils.h File Reference
#include <QStringList>
#include <QMap>
#include <QtCore/QFile>
#include <QtCore/QDir>
#include <QtCore/QDateTime>
#include <QtCore/QJsonArray>
#include <QtCore/QJsonObject>
#include <QtCore/QJsonDocument>
#include <iostream>
+ Include dependency graph for utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  JsonOutput
 
class  NameFilterFileEntryFunction
 

Enumerations

enum  PlatformFlag {
  WindowsBased = 0x00001 , UnixBased = 0x00002 , IntelBased = 0x00010 , ArmBased = 0x00020 ,
  Msvc = 0x00100 , MinGW = 0x00200 , ClangMsvc = 0x00400 , ClangMinGW = 0x00800 ,
  WindowsDesktopMsvc = WindowsBased + IntelBased + Msvc , WindowsDesktopMinGW = WindowsBased + IntelBased + MinGW , WindowsDesktopClangMsvc = WindowsBased + IntelBased + ClangMsvc , WindowsDesktopClangMinGW = WindowsBased + IntelBased + ClangMinGW ,
  Unix = UnixBased , UnknownPlatform
}
 
enum  ListOption {
  ListNone = 0 , ListSource , ListTarget , ListRelative ,
  ListMapping
}
 
enum  DebugMatchMode { MatchDebug , MatchRelease , MatchDebugOrRelease }
 
enum  UpdateFileFlag { ForceUpdateFile = 0x1 , SkipUpdateFile = 0x2 , RemoveEmptyQmlDirectories = 0x4 , SkipQmlDesignerSpecificsDirectories = 0x8 }
 

Functions

bool platformHasDebugSuffix (Platform p)
 
std::wostream & operator<< (std::wostream &str, const QString &s)
 
QString normalizeFileName (const QString &name)
 
QString sharedLibrarySuffix (Platform platform)
 
bool isBuildDirectory (Platform platform, const QString &dirName)
 
bool createSymbolicLink (const QFileInfo &source, const QString &target, QString *errorMessage)
 
bool createDirectory (const QString &directory, QString *errorMessage, bool dryRun)
 
QString findInPath (const QString &file)
 
QMap< QString, QStringqueryQtPaths (const QString &qmakeBinary, QString *errorMessage)
 
QStringList findSharedLibraries (const QDir &directory, Platform platform, DebugMatchMode debugMatchMode, const QString &prefix=QString())
 
bool updateFile (const QString &sourceFileName, const QStringList &nameFilters, const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
 
bool runProcess (const QString &binary, const QStringList &args, const QString &workingDirectory=QString(), unsigned long *exitCode=0, QByteArray *stdOut=0, QByteArray *stdErr=0, QString *errorMessage=0)
 
bool readPeExecutable (const QString &peExecutableFileName, QString *errorMessage, QStringList *dependentLibraries=0, unsigned *wordSize=0, bool *isDebug=0, bool isMinGW=false, unsigned short *machineArch=nullptr)
 
bool readElfExecutable (const QString &elfExecutableFileName, QString *errorMessage, QStringList *dependentLibraries=0, unsigned *wordSize=0, bool *isDebug=0)
 
bool readExecutable (const QString &executableFileName, Platform platform, QString *errorMessage, QStringList *dependentLibraries=0, unsigned *wordSize=0, bool *isDebug=0, unsigned short *machineArch=nullptr)
 
QStringList findDependentLibraries (const QString &executableFileName, Platform platform, QString *errorMessage)
 
QString findD3dCompiler (Platform platform, const QString &qtBinDir, unsigned wordSize)
 
QStringList findDxc (Platform platform, const QString &qtBinDir, unsigned wordSize)
 
bool patchQtCore (const QString &path, QString *errorMessage)
 
template<class DirectoryFileEntryFunction >
bool updateFile (const QString &sourceFileName, DirectoryFileEntryFunction directoryFileEntryFunction, const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
 
bool updateFile (const QString &sourceFileName, const QString &targetDirectory, unsigned flags, JsonOutput *json, QString *errorMessage)
 

Variables

static const char windowsSharedLibrarySuffix [] = ".dll"
 
static const char unixSharedLibrarySuffix [] = ".so"
 
const char * qmakeInfixKey
 
int optVerboseLevel
 

Enumeration Type Documentation

◆ DebugMatchMode

Enumerator
MatchDebug 
MatchRelease 
MatchDebugOrRelease 

Definition at line 153 of file utils.h.

◆ ListOption

enum ListOption
Enumerator
ListNone 
ListSource 
ListTarget 
ListRelative 
ListMapping 

Definition at line 50 of file utils.h.

◆ PlatformFlag

Enumerator
WindowsBased 
UnixBased 
IntelBased 
ArmBased 
Msvc 
MinGW 
ClangMsvc 
ClangMinGW 
WindowsDesktopMsvc 
WindowsDesktopMinGW 
WindowsDesktopClangMsvc 
WindowsDesktopClangMinGW 
Unix 
UnknownPlatform 

Definition at line 20 of file utils.h.

◆ UpdateFileFlag

Enumerator
ForceUpdateFile 
SkipUpdateFile 
RemoveEmptyQmlDirectories 
SkipQmlDesignerSpecificsDirectories 

Definition at line 212 of file utils.h.

Function Documentation

◆ createDirectory()

bool createDirectory ( const QString directory,
QString errorMessage,
bool  dryRun 
)

Definition at line 65 of file utils.cpp.

References QString::arg(), arg, dir, directory, errorMessage(), QFileInfo::exists(), fi, QString::fromLatin1(), QFileInfo::isDir(), optVerboseLevel, and QDir::toNativeSeparators().

Referenced by deploy(), deployWebEngineCore(), and main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createSymbolicLink()

bool createSymbolicLink ( const QFileInfo source,
const QString target,
QString errorMessage 
)

Definition at line 46 of file utils.cpp.

References QString::arg(), QDir::currentPath(), errorMessage(), QIODevice::errorString(), file, QString::fromLatin1(), QFile::link(), QStringLiteral, QDir::setCurrent(), and QDir::toNativeSeparators().

Referenced by updateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findD3dCompiler()

QString findD3dCompiler ( Platform  platform,
const QString qtBinDir,
unsigned  wordSize 
)

Definition at line 955 of file utils.cpp.

Referenced by deploy().

+ Here is the caller graph for this function:

◆ findDependentLibraries()

QStringList findDependentLibraries ( const QString executableFileName,
Platform  platform,
QString errorMessage 
)
inline

Definition at line 196 of file utils.h.

References errorMessage(), platform(), and readExecutable().

Referenced by deploy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findDxc()

QStringList findDxc ( Platform  platform,
const QString qtBinDir,
unsigned  wordSize 
)

Definition at line 960 of file utils.cpp.

Referenced by deploy().

+ Here is the caller graph for this function:

◆ findInPath()

QString findInPath ( const QString file)

Definition at line 2597 of file main.cpp.

References QDir::cleanPath(), QFileInfo::exists(), file, fileName, QStandardPaths::findExecutable(), QString::fromLocal8Bit(), QString::fromWCharArray(), QFileInfo::isExecutable(), QFileInfo::isFile(), MAX_PATH, qgetenv(), and QFile::size().

Referenced by deploy(), findMinGWRuntimePaths(), and signAAB().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ findSharedLibraries()

QStringList findSharedLibraries ( const QDir directory,
Platform  platform,
DebugMatchMode  debugMatchMode,
const QString prefix = QString() 
)

Definition at line 89 of file utils.cpp.

References directory, errorMessage(), QDir::Files, QString::isEmpty(), MatchDebug, MatchDebugOrRelease, matches(), platform(), platformHasDebugSuffix(), readPeExecutable(), sharedLibrarySuffix(), QDir::toNativeSeparators(), WindowsBased, and WindowsDesktopMinGW.

Referenced by findFileRecursion(), findQtPlugins(), DllDirectoryFileEntryFunction::operator()(), and parseArguments().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBuildDirectory()

bool isBuildDirectory ( Platform  platform,
const QString dirName 
)

Definition at line 38 of file utils.cpp.

References ClangMsvc, Msvc, and platform().

Referenced by findQmlDirectory(), and qmlDirectoryRecursion().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ normalizeFileName()

QString normalizeFileName ( const QString name)
inline

Definition at line 136 of file utils.h.

Referenced by findDependentQtLibraries().

+ Here is the caller graph for this function:

◆ operator<<()

std::wostream & operator<< ( std::wostream &  str,
const QString s 
)
inline

Definition at line 58 of file utils.h.

References str, and QString::toStdWString().

+ Here is the call graph for this function:

◆ patchQtCore()

bool patchQtCore ( const QString path,
QString errorMessage 
)

Definition at line 968 of file utils.cpp.

References QString::arg(), QFileDevice::close(), errorMessage(), QIODevice::errorString(), file, QFileInfo::fileName(), QString::fromLatin1(), QByteArray::indexOf(), QByteArray::isEmpty(), QByteArray::length(), QFile::open(), optVerboseLevel, QIODevice::readAll(), QIODeviceBase::ReadOnly, QByteArray::replace(), QByteArray::size(), QDir::toNativeSeparators(), QIODevice::write(), and QIODeviceBase::WriteOnly.

Referenced by deploy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ platformHasDebugSuffix()

bool platformHasDebugSuffix ( Platform  p)
inline

Definition at line 45 of file utils.h.

References ClangMsvc, and Msvc.

Referenced by deployWebEngineCore(), findSharedLibraries(), and libraryPath().

+ Here is the caller graph for this function:

◆ queryQtPaths()

QMap< QString, QString > queryQtPaths ( const QString qmakeBinary,
QString errorMessage 
)

Definition at line 424 of file utils.cpp.

References errorMessage(), QIODevice::errorString(), QFile::fileName(), QString::fromLocal8Bit(), QString::fromUtf8(), QString::indexOf(), QString::isEmpty(), line, QString::number(), QFile::open(), output, pos, qmakeInfixKey, QStringLiteral, QIODevice::readLine(), QIODeviceBase::ReadOnly, QString::remove(), QString::right(), runProcess(), QString::size(), QString::startsWith(), QIODeviceBase::Text, QDir::toNativeSeparators(), and QString::trimmed().

Referenced by main().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readElfExecutable()

bool readElfExecutable ( const QString elfExecutableFileName,
QString errorMessage,
QStringList dependentLibraries = 0,
unsigned *  wordSize = 0,
bool *  isDebug = 0 
)

Definition at line 556 of file utils.cpp.

References ElfReader::dependencies(), Elf_ELFCLASS64, errorMessage(), ElfReader::errorString(), QString::fromLocal8Bit(), QList< T >::isEmpty(), NoSymbols, QStringLiteral, ElfReader::readHeaders(), QDir::toNativeSeparators(), and UnknownSymbols.

Referenced by readExecutable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readExecutable()

bool readExecutable ( const QString executableFileName,
Platform  platform,
QString errorMessage,
QStringList dependentLibraries = 0,
unsigned *  wordSize = 0,
bool *  isDebug = 0,
unsigned short *  machineArch = nullptr 
)
inline

Definition at line 177 of file utils.h.

References errorMessage(), platform(), readElfExecutable(), readPeExecutable(), Unix, and WindowsDesktopMinGW.

Referenced by findDependentLibraries(), and findDependentQtLibraries().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readPeExecutable()

bool readPeExecutable ( const QString peExecutableFileName,
QString errorMessage,
QStringList dependentLibraries = 0,
unsigned *  wordSize = 0,
bool *  isDebug = 0,
bool  isMinGW = false,
unsigned short *  machineArch = nullptr 
)

Definition at line 948 of file utils.cpp.

References errorMessage(), and QStringLiteral.

Referenced by findSharedLibraries(), and readExecutable().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ runProcess()

bool runProcess ( const QString binary,
const QStringList args,
const QString workingDirectory = QString(),
unsigned long *  exitCode = 0,
QByteArray stdOut = 0,
QByteArray stdErr = 0,
QString errorMessage = 0 
)

Definition at line 312 of file utils.cpp.

References args, QScopedPointer< T, Cleanup >::data(), encodeFileName(), errorMessage(), QString::fromLocal8Bit(), QString::isEmpty(), QStringLiteral, readOutRedirectFile(), QScopedPointer< T, Cleanup >::reset(), QDir::setCurrent(), QList< T >::size(), and tempFilePattern().

Referenced by deployTranslations(), queryQtPaths(), and runQmlImportScanner().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sharedLibrarySuffix()

QString sharedLibrarySuffix ( Platform  platform)
inline

Definition at line 142 of file utils.h.

References platform(), unixSharedLibrarySuffix, WindowsBased, and windowsSharedLibrarySuffix.

Referenced by findMinGWRuntimePaths(), findSharedLibraries(), and libraryPath().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFile() [1/3]

bool updateFile ( const QString sourceFileName,
const QString targetDirectory,
unsigned  flags,
JsonOutput json,
QString errorMessage 
)
inline

Definition at line 373 of file utils.h.

References errorMessage(), and updateFile().

+ Here is the call graph for this function:

◆ updateFile() [2/3]

bool updateFile ( const QString sourceFileName,
const QStringList nameFilters,
const QString targetDirectory,
unsigned  flags,
JsonOutput json,
QString errorMessage 
)

Definition at line 476 of file utils.cpp.

References JsonOutput::addFile(), QString::arg(), QFile::copy(), d, dir, QDir::Dirs, errorMessage(), QIODevice::errorString(), QFileInfo::exists(), file, QFileInfo::fileName(), QDir::Files, ForceUpdateFile, QString::fromLatin1(), QFileInfo::isDir(), QFileInfo::isSymLink(), QFileInfo::lastModified(), QDir::NoDotAndDotDot, optVerboseLevel, QFile::remove(), SkipUpdateFile, QDir::toNativeSeparators(), and updateFile().

Referenced by updateFile(), updateFile(), and updateFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ updateFile() [3/3]

template<class DirectoryFileEntryFunction >
bool updateFile ( const QString sourceFileName,
DirectoryFileEntryFunction  directoryFileEntryFunction,
const QString targetDirectory,
unsigned  flags,
JsonOutput json,
QString errorMessage 
)

Variable Documentation

◆ optVerboseLevel

◆ qmakeInfixKey

const char* qmakeInfixKey
extern

Definition at line 422 of file utils.cpp.

Referenced by deploy(), and queryQtPaths().

◆ unixSharedLibrarySuffix

const char unixSharedLibrarySuffix[] = ".so"
static

Definition at line 140 of file utils.h.

Referenced by sharedLibrarySuffix().

◆ windowsSharedLibrarySuffix

const char windowsSharedLibrarySuffix[] = ".dll"
static

Definition at line 139 of file utils.h.

Referenced by deploy(), and sharedLibrarySuffix().