support installs with target dir
this adds a .base "member" to the install "structure". if specified, only this much is stripped from the front of each element of .files, rather than the entire path, to obtain the target filename. Change-Id: Ic39fcf71c4ad874ffabbbad113be9cdc6e3f7260 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
This commit is contained in:
parent
ff192b3c62
commit
f8ff2ae69e
@ -1182,6 +1182,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
rm_dir_contents = "-$(DEL_FILE) -r";
|
rm_dir_contents = "-$(DEL_FILE) -r";
|
||||||
|
|
||||||
QString all_installs, all_uninstalls;
|
QString all_installs, all_uninstalls;
|
||||||
|
QSet<QString> made_dirs, removed_dirs;
|
||||||
const QStringList &l = project->values(installs);
|
const QStringList &l = project->values(installs);
|
||||||
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
for (QStringList::ConstIterator it = l.begin(); it != l.end(); ++it) {
|
||||||
QString pvar = (*it) + ".path";
|
QString pvar = (*it) + ".path";
|
||||||
@ -1216,6 +1217,12 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
tmp = fileFixify(tmp, FileFixifyAbsolute);
|
tmp = fileFixify(tmp, FileFixifyAbsolute);
|
||||||
if(!tmp.isEmpty()) {
|
if(!tmp.isEmpty()) {
|
||||||
do_default = false;
|
do_default = false;
|
||||||
|
QString base_path = project->first((*it) + ".base");
|
||||||
|
if (!base_path.isEmpty()) {
|
||||||
|
base_path = Option::fixPathToTargetOS(base_path, false, true);
|
||||||
|
if (!base_path.endsWith(Option::dir_sep))
|
||||||
|
base_path += Option::dir_sep;
|
||||||
|
}
|
||||||
for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) {
|
for(QStringList::Iterator wild_it = tmp.begin(); wild_it != tmp.end(); ++wild_it) {
|
||||||
QString wild = Option::fixPathToTargetOS((*wild_it), false, false);
|
QString wild = Option::fixPathToTargetOS((*wild_it), false, false);
|
||||||
QString dirstr = qmake_getpwd(), filestr = wild;
|
QString dirstr = qmake_getpwd(), filestr = wild;
|
||||||
@ -1226,11 +1233,38 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
}
|
}
|
||||||
if(!dirstr.endsWith(Option::dir_sep))
|
if(!dirstr.endsWith(Option::dir_sep))
|
||||||
dirstr += Option::dir_sep;
|
dirstr += Option::dir_sep;
|
||||||
|
QString dst_dir = dst;
|
||||||
|
if (!base_path.isEmpty()) {
|
||||||
|
if (!dirstr.startsWith(base_path)) {
|
||||||
|
warn_msg(WarnLogic, "File %s in install rule %s does not start with base %s",
|
||||||
|
qPrintable(wild), qPrintable(*it), qPrintable(base_path));
|
||||||
|
} else {
|
||||||
|
QString dir_sfx = dirstr.mid(base_path.length());
|
||||||
|
dst_dir += dir_sfx;
|
||||||
|
if (!dir_sfx.isEmpty() && !made_dirs.contains(dir_sfx)) {
|
||||||
|
made_dirs.insert(dir_sfx);
|
||||||
|
QString tmp_dst = fileFixify(dst_dir, FileFixifyAbsolute, false);
|
||||||
|
tmp_dst.chop(1);
|
||||||
|
inst << mkdir_p_asstring(filePrefixRoot(root, tmp_dst));
|
||||||
|
for (int i = dst.length(); i < dst_dir.length(); i++) {
|
||||||
|
if (dst_dir.at(i) == Option::dir_sep) {
|
||||||
|
QString subd = dst_dir.left(i);
|
||||||
|
if (!removed_dirs.contains(subd)) {
|
||||||
|
removed_dirs.insert(subd);
|
||||||
|
tmp_dst = fileFixify(subd, FileFixifyAbsolute, false);
|
||||||
|
uninst << "-$(DEL_DIR) "
|
||||||
|
+ escapeFilePath(filePrefixRoot(root, tmp_dst));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
bool is_target = (wild == fileFixify(var("TARGET"), FileFixifyAbsolute));
|
bool is_target = (wild == fileFixify(var("TARGET"), FileFixifyAbsolute));
|
||||||
if(is_target || exists(wild)) { //real file or target
|
if(is_target || exists(wild)) { //real file or target
|
||||||
QString file = wild;
|
QString file = wild;
|
||||||
QFileInfo fi(fileInfo(wild));
|
QFileInfo fi(fileInfo(wild));
|
||||||
QString dst_file = filePrefixRoot(root, dst);
|
QString dst_file = filePrefixRoot(root, dst_dir);
|
||||||
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
||||||
if(!dst_file.endsWith(Option::dir_sep))
|
if(!dst_file.endsWith(Option::dir_sep))
|
||||||
dst_file += Option::dir_sep;
|
dst_file += Option::dir_sep;
|
||||||
@ -1248,15 +1282,15 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
if(!project->isActiveConfig("debug") && !project->isActiveConfig("nostrip") &&
|
if(!project->isActiveConfig("debug") && !project->isActiveConfig("nostrip") &&
|
||||||
!fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
!fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
||||||
inst << QString("-") + var("QMAKE_STRIP") + " " +
|
inst << QString("-") + var("QMAKE_STRIP") + " " +
|
||||||
escapeFilePath(filePrefixRoot(root, fileFixify(dst + filestr, FileFixifyAbsolute, false)));
|
escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false)));
|
||||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst + filestr, FileFixifyAbsolute, false))));
|
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false))));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
QString local_dirstr = Option::fixPathToLocalOS(dirstr, true);
|
QString local_dirstr = Option::fixPathToLocalOS(dirstr, true);
|
||||||
QStringList files = QDir(local_dirstr).entryList(QStringList(filestr));
|
QStringList files = QDir(local_dirstr).entryList(QStringList(filestr));
|
||||||
const QStringList &installConfigValues = project->values((*it) + ".CONFIG");
|
const QStringList &installConfigValues = project->values((*it) + ".CONFIG");
|
||||||
if (installConfigValues.contains("no_check_exist") && files.isEmpty()) {
|
if (installConfigValues.contains("no_check_exist") && files.isEmpty()) {
|
||||||
QString dst_file = filePrefixRoot(root, dst);
|
QString dst_file = filePrefixRoot(root, dst_dir);
|
||||||
QString cmd;
|
QString cmd;
|
||||||
if (installConfigValues.contains("directory")) {
|
if (installConfigValues.contains("directory")) {
|
||||||
cmd = QLatin1String("-$(INSTALL_DIR)");
|
cmd = QLatin1String("-$(INSTALL_DIR)");
|
||||||
@ -1272,15 +1306,15 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
}
|
}
|
||||||
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
|
cmd += " " + escapeFilePath(wild) + " " + escapeFilePath(dst_file);
|
||||||
inst << cmd;
|
inst << cmd;
|
||||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst + filestr, FileFixifyAbsolute, false))));
|
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + filestr, FileFixifyAbsolute, false))));
|
||||||
}
|
}
|
||||||
for(int x = 0; x < files.count(); x++) {
|
for(int x = 0; x < files.count(); x++) {
|
||||||
QString file = files[x];
|
QString file = files[x];
|
||||||
if(file == "." || file == "..") //blah
|
if(file == "." || file == "..") //blah
|
||||||
continue;
|
continue;
|
||||||
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst + file, FileFixifyAbsolute, false))));
|
uninst.append(rm_dir_contents + " " + escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false))));
|
||||||
QFileInfo fi(fileInfo(dirstr + file));
|
QFileInfo fi(fileInfo(dirstr + file));
|
||||||
QString dst_file = filePrefixRoot(root, fileFixify(dst, FileFixifyAbsolute, false));
|
QString dst_file = filePrefixRoot(root, fileFixify(dst_dir, FileFixifyAbsolute, false));
|
||||||
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
if(fi.isDir() && project->isActiveConfig("copy_dir_files")) {
|
||||||
if(!dst_file.endsWith(Option::dir_sep))
|
if(!dst_file.endsWith(Option::dir_sep))
|
||||||
dst_file += Option::dir_sep;
|
dst_file += Option::dir_sep;
|
||||||
@ -1292,7 +1326,7 @@ MakefileGenerator::writeInstalls(QTextStream &t, const QString &installs, bool n
|
|||||||
if(!project->isActiveConfig("debug") && !project->isActiveConfig("nostrip") &&
|
if(!project->isActiveConfig("debug") && !project->isActiveConfig("nostrip") &&
|
||||||
!fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
!fi.isDir() && fi.isExecutable() && !project->isEmpty("QMAKE_STRIP"))
|
||||||
inst << QString("-") + var("QMAKE_STRIP") + " " +
|
inst << QString("-") + var("QMAKE_STRIP") + " " +
|
||||||
escapeFilePath(filePrefixRoot(root, fileFixify(dst + file, FileFixifyAbsolute, false)));
|
escapeFilePath(filePrefixRoot(root, fileFixify(dst_dir + file, FileFixifyAbsolute, false)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user