summaryrefslogtreecommitdiffstats
path: root/qmake
diff options
context:
space:
mode:
Diffstat (limited to 'qmake')
-rw-r--r--qmake/generators/unix/unixmake.cpp2
-rw-r--r--qmake/generators/win32/winmakefile.cpp9
-rw-r--r--qmake/main.cpp71
3 files changed, 78 insertions, 4 deletions
diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp
index 723eea80d3..c4750cb8a4 100644
--- a/qmake/generators/unix/unixmake.cpp
+++ b/qmake/generators/unix/unixmake.cpp
@@ -612,7 +612,7 @@ UnixMakefileGenerator::processPrlFiles()
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
if(!prl_libs.isEmpty()) {
for(int prl = 0; prl < prl_libs.size(); ++prl)
- l.insert(lit+prl+1, prl_libs.at(prl).toQString());
+ l.insert(++lit, prl_libs.at(prl));
prl_libs.clear();
}
}
diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp
index 8a60c44032..386e2865fa 100644
--- a/qmake/generators/win32/winmakefile.cpp
+++ b/qmake/generators/win32/winmakefile.cpp
@@ -100,10 +100,13 @@ ProString Win32MakefileGenerator::fixLibFlag(const ProString &lib)
{
if (lib.startsWith('/')) {
if (lib.startsWith("/LIBPATH:"))
- return QStringLiteral("/LIBPATH:") + escapeFilePath(lib.mid(9));
+ return QLatin1String("/LIBPATH:")
+ + escapeFilePath(Option::fixPathToTargetOS(lib.mid(9).toQString(), false));
+ // This appears to be a user-supplied flag. Assume sufficient quoting.
return lib;
}
- return escapeFilePath(lib);
+ // This must be a fully resolved library path.
+ return escapeFilePath(Option::fixPathToTargetOS(lib.toQString(), false));
}
bool
@@ -231,7 +234,7 @@ Win32MakefileGenerator::processPrlFiles()
}
ProStringList &prl_libs = project->values("QMAKE_CURRENT_PRL_LIBS");
for (int prl = 0; prl < prl_libs.size(); ++prl)
- l.insert(lit + prl + 1, prl_libs.at(prl));
+ l.insert(++lit, prl_libs.at(prl));
prl_libs.clear();
}
diff --git a/qmake/main.cpp b/qmake/main.cpp
index 27969932bc..bde537dcca 100644
--- a/qmake/main.cpp
+++ b/qmake/main.cpp
@@ -163,6 +163,75 @@ static int doSed(int argc, char **argv)
return 0;
}
+static int doLink(int argc, char **argv)
+{
+ bool isSymlink = false;
+ bool force = false;
+ QList<const char *> inFiles;
+ for (int i = 0; i < argc; i++) {
+ if (!strcmp(argv[i], "-s")) {
+ isSymlink = true;
+ } else if (!strcmp(argv[i], "-f")) {
+ force = true;
+ } else if (argv[i][0] == '-') {
+ fprintf(stderr, "Error: unrecognized ln option '%s'\n", argv[i]);
+ return 3;
+ } else {
+ inFiles << argv[i];
+ }
+ }
+ if (inFiles.size() != 2) {
+ fprintf(stderr, "Error: this ln requires exactly two file arguments\n");
+ return 3;
+ }
+ if (!isSymlink) {
+ fprintf(stderr, "Error: this ln supports faking symlinks only\n");
+ return 3;
+ }
+ QString target = QString::fromLocal8Bit(inFiles[0]);
+ QString linkname = QString::fromLocal8Bit(inFiles[1]);
+
+ QDir destdir;
+ QFileInfo tfi(target);
+ QFileInfo lfi(linkname);
+ if (lfi.isDir()) {
+ destdir.setPath(linkname);
+ lfi.setFile(destdir, tfi.fileName());
+ } else {
+ destdir.setPath(lfi.path());
+ }
+ if (!destdir.exists()) {
+ fprintf(stderr, "Error: destination directory %s does not exist\n", qPrintable(destdir.path()));
+ return 1;
+ }
+ tfi.setFile(destdir.absoluteFilePath(tfi.filePath()));
+ if (!tfi.exists()) {
+ fprintf(stderr, "Error: this ln does not support symlinking non-existing targets\n");
+ return 3;
+ }
+ if (tfi.isDir()) {
+ fprintf(stderr, "Error: this ln does not support symlinking directories\n");
+ return 3;
+ }
+ if (lfi.exists()) {
+ if (!force) {
+ fprintf(stderr, "Error: %s exists\n", qPrintable(lfi.filePath()));
+ return 1;
+ }
+ if (!QFile::remove(lfi.filePath())) {
+ fprintf(stderr, "Error: cannot overwrite %s\n", qPrintable(lfi.filePath()));
+ return 1;
+ }
+ }
+ if (!QFile::copy(tfi.filePath(), lfi.filePath())) {
+ fprintf(stderr, "Error: cannot copy %s to %s\n",
+ qPrintable(tfi.filePath()), qPrintable(lfi.filePath()));
+ return 1;
+ }
+
+ return 0;
+}
+
static int doInstall(int argc, char **argv)
{
if (!argc) {
@@ -171,6 +240,8 @@ static int doInstall(int argc, char **argv)
}
if (!strcmp(argv[0], "sed"))
return doSed(argc - 1, argv + 1);
+ if (!strcmp(argv[0], "ln"))
+ return doLink(argc - 1, argv + 1);
fprintf(stderr, "Error: unrecognized -install subcommand '%s'\n", argv[0]);
return 3;
}