diff options
Diffstat (limited to 'qmake')
-rw-r--r-- | qmake/generators/makefile.cpp | 47 | ||||
-rw-r--r-- | qmake/generators/unix/unixmake.cpp | 8 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 2 | ||||
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 4 | ||||
-rw-r--r-- | qmake/library/ioutils.cpp | 35 | ||||
-rw-r--r-- | qmake/library/ioutils.h | 3 | ||||
-rw-r--r-- | qmake/main.cpp | 77 |
7 files changed, 122 insertions, 54 deletions
diff --git a/qmake/generators/makefile.cpp b/qmake/generators/makefile.cpp index 4568f1d4f2..d3221b7a25 100644 --- a/qmake/generators/makefile.cpp +++ b/qmake/generators/makefile.cpp @@ -1283,18 +1283,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) if(is_target || exists(wild)) { //real file or target QFileInfo fi(fileInfo(wild)); QString dst_file = filePrefixRoot(root, dst_dir); - if(fi.isDir() && project->isActiveConfig("copy_dir_files")) { - if(!dst_file.endsWith(Option::dir_sep)) - dst_file += Option::dir_sep; - dst_file += fi.fileName(); - } + if (!dst_file.endsWith(Option::dir_sep)) + dst_file += Option::dir_sep; + dst_file += fi.fileName(); QString cmd; - if (fi.isDir()) - cmd = "-$(INSTALL_DIR)"; - else if (is_target || fi.isExecutable()) - cmd = "-$(QINSTALL_PROGRAM)"; + if (is_target || (!fi.isDir() && fi.isExecutable())) + cmd = QLatin1String("-$(QINSTALL_PROGRAM)"); else - cmd = "-$(QINSTALL_FILE)"; + cmd = QLatin1String("-$(QINSTALL)"); cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file); inst << cmd; if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") && @@ -1309,19 +1305,14 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) QDir::NoDotAndDotDot | QDir::AllEntries); if (installConfigValues.contains("no_check_exist") && files.isEmpty()) { QString dst_file = filePrefixRoot(root, dst_dir); + if (!dst_file.endsWith(Option::dir_sep)) + dst_file += Option::dir_sep; + dst_file += filestr; QString cmd; - if (installConfigValues.contains("directory")) { - cmd = QLatin1String("-$(INSTALL_DIR)"); - if (project->isActiveConfig("copy_dir_files")) { - if (!dst_file.endsWith(Option::dir_sep)) - dst_file += Option::dir_sep; - dst_file += filestr; - } - } else if (installConfigValues.contains("executable")) { + if (installConfigValues.contains("executable")) cmd = QLatin1String("-$(QINSTALL_PROGRAM)"); - } else { - cmd = QLatin1String("-$(QINSTALL_FILE)"); - } + else + cmd = QLatin1String("-$(QINSTALL)"); cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file); inst << cmd; uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false)))); @@ -1331,12 +1322,10 @@ MakefileGenerator::writeInstalls(QTextStream &t, bool noBuild) uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false)))); QFileInfo fi(fileInfo(dirstr + file)); QString dst_file = filePrefixRoot(root, fileFixify(dst_dir, FileFixifyAbsolute, false)); - if(fi.isDir() && project->isActiveConfig("copy_dir_files")) { - if(!dst_file.endsWith(Option::dir_sep)) - dst_file += Option::dir_sep; - dst_file += fi.fileName(); - } - QString cmd = QString(fi.isDir() ? "-$(INSTALL_DIR)" : "-$(QINSTALL_FILE)") + " " + + if (!dst_file.endsWith(Option::dir_sep)) + dst_file += Option::dir_sep; + dst_file += fi.fileName(); + QString cmd = QLatin1String("-$(QINSTALL) ") + escapeFilePath(dirstr + file) + " " + escapeFilePath(dst_file); inst << cmd; if (!project->isActiveConfig("debug_info") && !project->isActiveConfig("nostrip") && @@ -2248,8 +2237,8 @@ MakefileGenerator::writeDefaultVariables(QTextStream &t) t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl; t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl; t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; - t << "QINSTALL_FILE = " << var("QMAKE_QMAKE") << " -install qinstall file" << endl; - t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall program" << endl; + t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl; + t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl; t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; t << "SYMLINK = " << var("QMAKE_SYMBOLIC_LINK") << endl; t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; diff --git a/qmake/generators/unix/unixmake.cpp b/qmake/generators/unix/unixmake.cpp index 1073386a82..b86594d191 100644 --- a/qmake/generators/unix/unixmake.cpp +++ b/qmake/generators/unix/unixmake.cpp @@ -600,7 +600,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) dst = escapeFilePath(filePrefixRoot(root, targetdir + src.section('/', -1))); if(!ret.isEmpty()) ret += "\n\t"; - ret += "-$(QINSTALL_FILE) " + escapeFilePath(Option::fixPathToTargetOS(src, false)) + ' ' + dst; + ret += "-$(QINSTALL) " + escapeFilePath(Option::fixPathToTargetOS(src, false)) + ' ' + dst; if(!uninst.isEmpty()) uninst.append("\n\t"); uninst.append("-$(DEL_FILE) " + dst); @@ -636,9 +636,9 @@ UnixMakefileGenerator::defaultInstall(const QString &t) QString copy_cmd; if (bundle == SolidBundle) { - copy_cmd += "-$(INSTALL_DIR) " + src_targ + ' ' + plain_targ; + copy_cmd += "-$(QINSTALL) " + src_targ + ' ' + plain_targ; } else if (project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) { - copy_cmd += "-$(QINSTALL_FILE) " + src_targ + ' ' + dst_targ; + copy_cmd += "-$(QINSTALL) " + src_targ + ' ' + dst_targ; } else if (!isAux) { if (bundle == SlicedBundle) { if (!ret.isEmpty()) @@ -698,7 +698,7 @@ UnixMakefileGenerator::defaultInstall(const QString &t) ret += "\n\t"; ret += mkdir_p_asstring("\"`dirname " + dst + "`\"", false) + "\n\t"; ret += "-$(DEL_FILE) " + dst + "\n\t"; // Can't overwrite symlinks to directories - ret += "-$(INSTALL_DIR) " + escapeFilePath(src) + " " + dst; // Use cp -R to copy symlinks + ret += "-$(QINSTALL) " + escapeFilePath(src) + " " + dst; if (!uninst.isEmpty()) uninst.append("\n\t"); uninst.append("-$(DEL_FILE) " + dst); diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp index 8ac462da6b..ef1eaf095e 100644 --- a/qmake/generators/win32/msvc_nmake.cpp +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -94,8 +94,8 @@ NmakeMakefileGenerator::writeMakefile(QTextStream &t) compiler += QStringLiteral("x64"); compilerArch = QStringLiteral("amd64"); } else { + arch = QStringLiteral("x86"); compiler += QStringLiteral("x86"); - compilerArch = QStringLiteral("amd64"); } } else { if (arch == QLatin1String("arm")) { diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp index 86d388354a..6f2f43c03c 100644 --- a/qmake/generators/win32/winmakefile.cpp +++ b/qmake/generators/win32/winmakefile.cpp @@ -530,8 +530,8 @@ void Win32MakefileGenerator::writeStandardParts(QTextStream &t) t << "INSTALL_FILE = " << var("QMAKE_INSTALL_FILE") << endl; t << "INSTALL_PROGRAM = " << var("QMAKE_INSTALL_PROGRAM") << endl; t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; - t << "QINSTALL_FILE = " << var("QMAKE_QMAKE") << " -install qinstall file" << endl; - t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall program" << endl; + t << "QINSTALL = " << var("QMAKE_QMAKE") << " -install qinstall" << endl; + t << "QINSTALL_PROGRAM = " << var("QMAKE_QMAKE") << " -install qinstall -exe" << endl; t << endl; t << "####### Output directory\n\n"; diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp index 39264952c6..684bcb9a37 100644 --- a/qmake/library/ioutils.cpp +++ b/qmake/library/ioutils.cpp @@ -253,4 +253,39 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF } #endif +#ifdef Q_OS_UNIX +bool IoUtils::readLinkTarget(const QString &symlinkPath, QString *target) +{ + const QByteArray localSymlinkPath = QFile::encodeName(symlinkPath); +# if defined(__GLIBC__) && !defined(PATH_MAX) +# define PATH_CHUNK_SIZE 256 + char *s = 0; + int len = -1; + int size = PATH_CHUNK_SIZE; + + forever { + s = (char *)::realloc(s, size); + len = ::readlink(localSymlinkPath.constData(), s, size); + if (len < 0) { + ::free(s); + break; + } + if (len < size) + break; + size *= 2; + } +# else + char s[PATH_MAX+1]; + int len = readlink(localSymlinkPath.constData(), s, PATH_MAX); +# endif + if (len <= 0) + return false; + *target = QFile::decodeName(QByteArray(s, len)); +# if defined(__GLIBC__) && !defined(PATH_MAX) + ::free(s); +# endif + return true; +} +#endif + QT_END_NAMESPACE diff --git a/qmake/library/ioutils.h b/qmake/library/ioutils.h index 905974b7cb..ad379404f3 100644 --- a/qmake/library/ioutils.h +++ b/qmake/library/ioutils.h @@ -65,6 +65,9 @@ public: #if defined(PROEVALUATOR_FULL) static bool touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString); #endif +#ifdef Q_OS_UNIX + static bool readLinkTarget(const QString &symlinkPath, QString *target); +#endif }; } // namespace ProFileEvaluatorInternal diff --git a/qmake/main.cpp b/qmake/main.cpp index 2bdb5370df..13b18d018a 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp @@ -36,6 +36,7 @@ #include <qdebug.h> #include <qregexp.h> #include <qdir.h> +#include <qdiriterator.h> #include <stdio.h> #include <stdlib.h> #include <ctype.h> @@ -43,6 +44,11 @@ #include <sys/types.h> #include <sys/stat.h> +#if defined(Q_OS_UNIX) +#include <errno.h> +#include <unistd.h> +#endif + #ifdef Q_OS_WIN # include <qt_windows.h> #endif @@ -236,17 +242,11 @@ static int doLink(int argc, char **argv) #endif -static int installFile(const QString &source, const QString &targetFileOrDirectory, bool exe = false) +static int installFile(const QString &source, const QString &target, bool exe = false) { QFile sourceFile(source); - QString target(targetFileOrDirectory); - if (QFileInfo(target).isDir()) - target += QDir::separator() + QFileInfo(sourceFile.fileName()).fileName(); - - if (QFile::exists(target)) - QFile::remove(target); - + QFile::remove(target); QDir::root().mkpath(QFileInfo(target).absolutePath()); if (!sourceFile.copy(target)) { @@ -273,23 +273,64 @@ static int installFile(const QString &source, const QString &targetFileOrDirecto return 0; } +static int installFileOrDirectory(const QString &source, const QString &target) +{ + QFileInfo fi(source); + if (false) { +#if defined(Q_OS_UNIX) + } else if (fi.isSymLink()) { + QString linkTarget; + if (!IoUtils::readLinkTarget(fi.absoluteFilePath(), &linkTarget)) { + fprintf(stderr, "Could not read link %s: %s\n", qPrintable(fi.absoluteFilePath()), strerror(errno)); + return 3; + } + QFile::remove(target); + if (::symlink(linkTarget.toLocal8Bit().constData(), target.toLocal8Bit().constData()) < 0) { + fprintf(stderr, "Could not create link: %s\n", strerror(errno)); + return 3; + } +#endif + } else if (fi.isDir()) { + QDir::current().mkpath(target); + + QDirIterator it(source, QDir::AllEntries | QDir::NoDotAndDotDot); + while (it.hasNext()) { + it.next(); + const QFileInfo &entry = it.fileInfo(); + const QString &entryTarget = target + QDir::separator() + entry.fileName(); + + const int recursionResult = installFileOrDirectory(entry.filePath(), entryTarget); + if (recursionResult != 0) + return recursionResult; + } + } else { + const int fileCopyResult = installFile(source, target); + if (fileCopyResult != 0) + return fileCopyResult; + } + return 0; +} + static int doQInstall(int argc, char **argv) { - if (argc != 3) { - fprintf(stderr, "Error: this qinstall command requires exactly three arguments (type, source, destination)\n"); + bool installExecutable = false; + if (argc == 3 && !strcmp(argv[0], "-exe")) { + installExecutable = true; + --argc; + ++argv; + } + + if (argc != 2 && !installExecutable) { + fprintf(stderr, "Error: usage: [-exe] source target\n"); return 3; } - const QString source = QString::fromLocal8Bit(argv[1]); - const QString target = QString::fromLocal8Bit(argv[2]); + const QString source = QString::fromLocal8Bit(argv[0]); + const QString target = QString::fromLocal8Bit(argv[1]); - if (!strcmp(argv[0], "file")) - return installFile(source, target); - if (!strcmp(argv[0], "program")) + if (installExecutable) return installFile(source, target, /*exe=*/true); - - fprintf(stderr, "Error: Unsupported qinstall command type %s\n", argv[0]); - return 3; + return installFileOrDirectory(source, target); } |