45 #include <sys/types.h>
48 #if defined(Q_OS_UNIX)
69 static int doSed(
int argc,
char **argv)
73 for (
int i = 0;
i < argc;
i++) {
74 if (!
strcmp(argv[i],
"-e")) {
76 fprintf(stderr,
"Error: sed option -e requires an argument\n");
85 fprintf(stderr,
"Error: unrecognized sed command '%c'\n",
c.toLatin1());
124 fprintf(stderr,
"Error: unterminated escape sequence in sed s command\n");
128 fprintf(stderr,
"Error: sed s command requires three arguments (%d, %c, %s)\n", phase, sep.
toLatin1(), qPrintable(curr));
136 fprintf(stderr,
"Error: sed s command supports only g & i options; g is required\n");
141 subst.to = phases.at(1);
145 }
else if (argv[i][0] ==
'-' && argv[i][1] != 0) {
146 fprintf(stderr,
"Error: unrecognized sed option '%s'\n", argv[i]);
154 for (
const char *inFile : qAsConst(inFiles)) {
156 if (!
strcmp(inFile,
"-")) {
158 }
else if (!(
f = fopen(inFile,
"rb"))) {
163 while (!is.atEnd()) {
165 for (
int i = 0;
i < substs.
size();
i++)
167 puts(qPrintable(
line));
175 static int doLink(
int argc,
char **argv)
177 bool isSymlink =
false;
180 for (
int i = 0;
i < argc;
i++) {
181 if (!
strcmp(argv[i],
"-s")) {
183 }
else if (!
strcmp(argv[i],
"-f")) {
185 }
else if (argv[i][0] ==
'-') {
186 fprintf(stderr,
"Error: unrecognized ln option '%s'\n", argv[i]);
192 if (inFiles.
size() != 2) {
193 fprintf(stderr,
"Error: this ln requires exactly two file arguments\n");
197 fprintf(stderr,
"Error: this ln supports faking symlinks only\n");
208 lfi.setFile(destdir, tfi.fileName());
213 fprintf(stderr,
"Error: destination directory %s does not exist\n", qPrintable(destdir.
path()));
218 fprintf(stderr,
"Error: this ln does not support symlinking non-existing targets\n");
222 fprintf(stderr,
"Error: this ln does not support symlinking directories\n");
227 fprintf(stderr,
"Error: %s exists\n", qPrintable(lfi.filePath()));
231 fprintf(stderr,
"Error: cannot overwrite %s\n", qPrintable(lfi.filePath()));
235 if (!
QFile::copy(tfi.filePath(), lfi.filePath())) {
236 fprintf(stderr,
"Error: cannot copy %s to %s\n",
237 qPrintable(tfi.filePath()), qPrintable(lfi.filePath()));
246 static bool setFilePermissions(
QFile &
file, QFileDevice::Permissions permissions)
250 fprintf(stderr,
"Error setting permissions on %s: %s\n",
255 static bool copyFileTimes(
QFile &targetFile,
const QString &sourceFilePath,
256 bool mustEnsureWritability,
QString *errorString)
259 bool mustRestorePermissions =
false;
260 QFileDevice::Permissions targetPermissions;
261 if (mustEnsureWritability) {
264 mustRestorePermissions =
true;
272 if (!IoUtils::touchFile(targetFile.
fileName(), sourceFilePath, errorString))
275 if (mustRestorePermissions && !setFilePermissions(targetFile, targetPermissions))
282 bool preservePermissions =
false)
286 if (targetFile.
exists()) {
295 if (!sourceFile.copy(
target)) {
296 fprintf(stderr,
"Error copying %s to %s: %s\n",
source.toLatin1().constData(), qPrintable(
target), qPrintable(sourceFile.errorString()));
300 QFileDevice::Permissions targetPermissions = preservePermissions
301 ? sourceFile.permissions()
309 if (!setFilePermissions(targetFile, targetPermissions))
313 if (!copyFileTimes(targetFile, sourceFile.fileName(), preservePermissions, &
error)) {
314 fprintf(stderr,
"%s", qPrintable(
error));
322 bool preservePermissions =
false)
326 #if defined(Q_OS_UNIX)
330 fprintf(stderr,
"Could not read link %s: %s\n", qPrintable(
fi.
absoluteFilePath()), strerror(errno));
335 fprintf(stderr,
"Could not create link: %s\n", strerror(errno));
343 while (
it.hasNext()) {
347 const int recursionResult = installFileOrDirectory(
entry.filePath(), entryTarget,
true);
348 if (recursionResult != 0)
349 return recursionResult;
352 const int fileCopyResult = installFile(
source,
target,
false, preservePermissions);
353 if (fileCopyResult != 0)
354 return fileCopyResult;
359 static int doQInstall(
int argc,
char **argv)
361 bool installExecutable =
false;
362 if (argc == 3 && !
strcmp(argv[0],
"-exe")) {
363 installExecutable =
true;
368 if (argc != 2 && !installExecutable) {
369 fprintf(stderr,
"Error: usage: [-exe] source target\n");
376 if (installExecutable)
382 static int doInstall(
int argc,
char **argv)
385 fprintf(stderr,
"Error: -install requires further arguments\n");
389 if (!
strcmp(argv[0],
"sed"))
390 return doSed(argc - 1, argv + 1);
391 if (!
strcmp(argv[0],
"ln"))
392 return doLink(argc - 1, argv + 1);
394 if (!
strcmp(argv[0],
"qinstall"))
395 return doQInstall(argc - 1, argv + 1);
396 fprintf(stderr,
"Error: unrecognized -install subcommand '%s'\n", argv[0]);
403 static int dumpMacros(
const wchar_t *cmdline)
407 wchar_t **argv = CommandLineToArgvW(cmdline, &argc);
410 for (
int i = 0;
i < argc; ++
i) {
411 if (argv[i][0] !=
L'-' || argv[i][1] !=
'D')
414 wchar_t *
value = wcschr(argv[i],
L'=');
420 value = argv[
i] + wcslen(argv[i]);
422 wprintf(
L"#define %Ls %Ls\n", argv[i] + 2,
value);
451 qSetGlobalQHashSeed(0);
457 setvbuf(stdout, (
char *)
NULL, _IONBF, 0);
460 if (argc >= 4 && !
strcmp(argv[1],
"-qtconf") && !
strcmp(argv[3],
"-install"))
461 return doInstall(argc - 4, argv + 4);
462 if (argc >= 2 && !
strcmp(argv[1],
"-install"))
463 return doInstall(argc - 2, argv + 2);
468 const wchar_t *cmdline = _wgetenv(
L"MSC_CMD_FLAGS");
469 if (!cmdline || !*cmdline)
470 cmdline = _wgetenv(
L"MSC_IDE_FLAGS");
471 if (cmdline && *cmdline)
472 return dumpMacros(cmdline);
523 globals.setQMakeProperty(&prop);
542 fprintf(stderr,
"Cannot find file: %s.\n",
557 fprintf(stderr,
"Cannot find directory: %s\n",
559 fn =
fn.right(
fn.length() - di - 1);
566 fprintf(stderr,
"Error processing project file: %s\n",
582 if (mkfile && !mkfile->
write()) {
584 fprintf(stderr,
"Unable to generate project file.\n");
586 fprintf(stderr,
"Unable to generate makefile for: %s\n",
599 int main(
int argc,
char **argv)
small capitals from c petite p scientific i
[1]
const char * constData() const noexcept
The QChar class provides a 16-bit Unicode character.
constexpr char toLatin1() const noexcept
The QDir class provides access to directory structures and their contents.
static bool setCurrent(const QString &path)
bool mkpath(const QString &dirPath) const
static QString cleanPath(const QString &path)
void setPath(const QString &path)
static QString toNativeSeparators(const QString &pathName)
QString absoluteFilePath(const QString &fileName) const
static QString currentPath()
The QDirIterator class provides an iterator for directory entrylists.
The QFile class provides an interface for reading from and writing to files.
bool setPermissions(Permissions permissionSpec) override
bool copy(const QString &newName)
void setFileName(const QString &name)
QString fileName() const override
Permissions permissions() const override
The QFileInfo class provides system-independent file information.
QString absoluteFilePath() const
QString absolutePath() const
QString errorString() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
qsizetype size() const noexcept
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
bool read(const QString &project, LoadFlags what=LoadAll)
int queryProperty(const QStringList &optionProperties=QStringList(), const PropertyPrinter &printer=qmakePropertyPrinter)
int setProperty(const QStringList &optionProperties)
void unsetProperty(const QStringList &optionProperties)
The QRegularExpression class provides pattern matching using regular expressions.
The QString class provides a Unicode character string.
QByteArray toLatin1() const &
QString & replace(qsizetype i, qsizetype len, QChar after)
static QString fromLocal8Bit(QByteArrayView ba)
QString mid(qsizetype position, qsizetype n=-1) const
const QChar at(qsizetype i) const
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QByteArray toLocal8Bit() const &
bool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
QString & remove(qsizetype i, qsizetype len)
The QStringList class provides a list of strings.
The QTextStream class provides a convenient interface for reading and writing text.
int main(int argc, char **argv)
int PRIV() strcmp(PCRE2_SPTR str1, PCRE2_SPTR str2)
EGLOutputLayerEXT EGLint EGLAttrib value
bool qmake_setpwd(const QString &p)
int runQMake(int argc, char **argv)
GLsizei GLsizei GLchar * source
int QT_PREPEND_NAMESPACE(QSharedMemoryPrivate)
#define Q_DECLARE_TYPEINFO(TYPE, FLAGS)
void error(const char *msg="Invalid argument")
QFileInfo fi("c:/temp/foo")
[newstuff]
QApplication app(argc, argv)
[0]
static QStringList project_files
static bool do_preprocess
static QStringList properties
static EvalHandler evalHandler
static QMakeGlobals * globals
static void prepareProject(const QString &pfile)
static ProFileCache * proFileCache
static QMAKE_MODE qmake_mode
static int init(int argc=0, char **argv=nullptr)
static QMakeParser * parser
@ QMAKE_GENERATE_MAKEFILE
static QString output_dir
static QString normalizePath(const QString &in, bool fix_env=true, bool canonical=true)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.