I got it working, with a small patch to qmake. I've submitted it as a bug, since the option QMAKE_DEL_DIR exists but is never used.
For windows, it's in the file {QTDIR}\qmake\generators\win32\winmakefile.cpp
For version 4.3.1 it's at line 490, replace the distclean block with this one :
t << "distclean: clean";
{
const char *clean_targets[] = { "QMAKE_DISTCLEAN", 0 };
for(int i = 0; clean_targets[i]; ++i) {
const QStringList &list
= project
->values
(clean_targets
[i
]);
const QString del_statement
("-$(DEL_FILE)");
const QString del_dir_statement
("-$(DEL_DIR)");
if(project->isActiveConfig("no_delete_multiple_files")) {
for(QStringList::ConstIterator it
= list.
begin(); it
!= list.
end();
++it
) t << "\n\t" << del_statement << " " << escapeFilePath((*it));
} else {
const int commandlineLimit = 2047; // NT limit, expanded
for(QStringList::ConstIterator it
= list.
begin(); it
!= list.
end();
++it
) { if ( (*it).endsWith("/") )
{
dirs += escapeFilePath(s.remove(s.size()-1, 1));
}
else
{
file = " " + escapeFilePath((*it));
if(del_statement.length() + files.length() +
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
t << "\n\t" << del_statement << files;
files.clear();
}
files += file;
}
}
if(!files.isEmpty())
t << "\n\t" << del_statement << files;
if(!dirs.isEmpty())
t << "\n\t" << del_dir_statement << " " << dir;
}
}
}
t << "distclean: clean";
{
const char *clean_targets[] = { "QMAKE_DISTCLEAN", 0 };
for(int i = 0; clean_targets[i]; ++i) {
const QStringList &list = project->values(clean_targets[i]);
const QString del_statement("-$(DEL_FILE)");
const QString del_dir_statement("-$(DEL_DIR)");
if(project->isActiveConfig("no_delete_multiple_files")) {
for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it)
t << "\n\t" << del_statement << " " << escapeFilePath((*it));
} else {
QString files, file;
QStringList dirs;
const int commandlineLimit = 2047; // NT limit, expanded
for(QStringList::ConstIterator it = list.begin(); it != list.end(); ++it) {
if ( (*it).endsWith("/") )
{
QString s = (*it);
dirs += escapeFilePath(s.remove(s.size()-1, 1));
}
else
{
file = " " + escapeFilePath((*it));
if(del_statement.length() + files.length() +
qMax(fixEnvVariables(file).length(), file.length()) > commandlineLimit) {
t << "\n\t" << del_statement << files;
files.clear();
}
files += file;
}
}
if(!files.isEmpty())
t << "\n\t" << del_statement << files;
if(!dirs.isEmpty())
foreach(QString dir, dirs)
t << "\n\t" << del_dir_statement << " " << dir;
}
}
}
To copy to clipboard, switch view to plain text mode
This allows the following to work in a .pro file (as I expect it to) :
QMAKE_DISTCLEAN += object_script.* bin/ build/
win32:QMAKE_DEL_FILE = del /q
win32:QMAKE_DEL_DIR = rmdir /s /q
QMAKE_DISTCLEAN += object_script.* bin/ build/
win32:QMAKE_DEL_FILE = del /q
win32:QMAKE_DEL_DIR = rmdir /s /q
To copy to clipboard, switch view to plain text mode
Any file listed in QMAKE_DISTCLEAN that ends with a "/" will be get the QMAKE_DEL_DIR command, while anything without a "/" at the end gets the QMAKE_DEL_FILE command as it previously did.
Bookmarks