author | kergoth <kergoth> | 2002-11-01 16:20:04 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-01 16:20:04 (UTC) |
commit | 4c9df59925da5a67d884f8ffb37a263d85948951 (patch) (side-by-side diff) | |
tree | 278796d7d27a06243e584a05f443dbb23eaf028c /qmake/project.cpp | |
parent | ebd6adcd2f72935f0ee7af7485c75c34ac3389a3 (diff) | |
download | opie-4c9df59925da5a67d884f8ffb37a263d85948951.zip opie-4c9df59925da5a67d884f8ffb37a263d85948951.tar.gz opie-4c9df59925da5a67d884f8ffb37a263d85948951.tar.bz2 |
Make qmake obey QMAKESPECSDIR if set.
-rw-r--r-- | qmake/project.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/qmake/project.cpp b/qmake/project.cpp index ae24193..96cdad8 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -348,214 +348,221 @@ QMakeProject::parse(QString t, QMap<QString, QStringList> &place) varlist.remove((*valit)); } } if(var == "REQUIRES") /* special case to get communicated to backends! */ doProjectCheckReqs(vallist, place); return TRUE; } bool QMakeProject::read(QString file, QMap<QString, QStringList> &place) { parser_info pi = parser; /* scope blocks start at true */ test_status = TestNone; scope_flag = 0x01; scope_block = 0; file = Option::fixPathToLocalOS(file); doVariableReplace(file, place); bool ret = FALSE, using_stdin = FALSE; QFile qfile; if(!strcmp(file, "-")) { qfile.setName(""); ret = qfile.open(IO_ReadOnly, stdin); using_stdin = TRUE; } else { qfile.setName(file); ret = qfile.open(IO_ReadOnly); } if ( ret ) { QTextStream t( &qfile ); QString s, line; parser.file = file; parser.line_no = 0; while ( !t.eof() ) { parser.line_no++; line = t.readLine().stripWhiteSpace(); int prelen = line.length(); line.replace(QRegExp("#.*$"), ""); // bye comments if(!line.isEmpty() && line.right(1) == "\\") { line.truncate(line.length() - 1); s += line + " "; } else if(!line.isEmpty() || (line.isEmpty() && !prelen)) { if(s.isEmpty() && line.isEmpty()) continue; if(!line.isEmpty()) s += line; if(!s.isEmpty()) { if(!(ret = parse(s, place))) break; s = ""; } } } if(!using_stdin) qfile.close(); } parser = pi; return ret; } bool QMakeProject::read(QString project, QString) { if(cfile.isEmpty()) { // hack to get the Option stuff in there base_vars["QMAKE_EXT_CPP"] = Option::cpp_ext; base_vars["QMAKE_EXT_H"] = Option::h_ext; /* parse the cache */ if(Option::mkfile::do_cache) { if(Option::mkfile::cachefile.isEmpty()) { //find it as it has not been specified QString dir = QDir::convertSeparators(Option::output_dir); while(!QFile::exists((Option::mkfile::cachefile = dir + QDir::separator() + ".qmake.cache"))) { dir = dir.left(dir.findRev(QDir::separator())); if(dir.isEmpty() || dir.find(QDir::separator()) == -1) { Option::mkfile::cachefile = ""; break; } if(Option::mkfile::cachefile_depth == -1) Option::mkfile::cachefile_depth = 1; else Option::mkfile::cachefile_depth++; } } if(!Option::mkfile::cachefile.isEmpty()) { read(Option::mkfile::cachefile, cache); if(Option::mkfile::qmakespec.isEmpty() && !cache["QMAKESPEC"].isEmpty()) Option::mkfile::qmakespec = cache["QMAKESPEC"].first(); } } /* parse mkspec */ QStringList mkspec_roots; /* prefer $QTDIR if it is set */ - /* minor hack here, prefer QMAKESPECDIR -cl */ + /* prefer QMAKESPECSDIR -cl */ - if (getenv("QMAKESPECDIR")){ - mkspec_roots << getenv("QMAKESPECDIR"); - } else if (getenv("QTDIR")) { + if (getenv("QTDIR")) { mkspec_roots << getenv("QTDIR"); } mkspec_roots << qInstallPathData(); + + if (getenv("QMAKESPECSDIR")){ + QString mkspec = QString(getenv("QMAKESPECSDIR")) + QDir::separator() + + QDir::separator() + "default"; + if(QFile::exists(mkspec)) + Option::mkfile::qmakespec = mkspec; + } + if(Option::mkfile::qmakespec.isEmpty()) { for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) { QString mkspec = (*it) + QDir::separator() + QString("mkspecs") + QDir::separator() + "default"; if(QFile::exists(mkspec)) { Option::mkfile::qmakespec = mkspec; break; } } + } + if(Option::mkfile::qmakespec.isEmpty()) { fprintf(stderr, "QMAKESPEC has not been set, so configuration cannot be deduced.\n"); return FALSE; } - } if(QDir::isRelativePath(Option::mkfile::qmakespec)) { bool found_mkspec = FALSE; for(QStringList::Iterator it = mkspec_roots.begin(); it != mkspec_roots.end(); ++it) { QString mkspec = (*it) + QDir::separator() + QString("mkspecs") + QDir::separator() + Option::mkfile::qmakespec; if(QFile::exists(mkspec)) { found_mkspec = TRUE; Option::mkfile::qmakespec = mkspec; break; } } if(!found_mkspec) { fprintf(stderr, "Could not find mkspecs for your QMAKESPEC after trying:\n\t%s\n", mkspec_roots.join("\n\t").latin1()); return FALSE; } } /* parse qmake configuration */ QString spec = Option::mkfile::qmakespec + QDir::separator() + "qmake.conf"; debug_msg(1, "QMAKESPEC conf: reading %s", spec.latin1()); if(!read(spec, base_vars)) { fprintf(stderr, "Failure to read QMAKESPEC conf file %s.\n", spec.latin1()); return FALSE; } if(Option::mkfile::do_cache && !Option::mkfile::cachefile.isEmpty()) { debug_msg(1, "QMAKECACHE file: reading %s", Option::mkfile::cachefile.latin1()); read(Option::mkfile::cachefile, base_vars); } /* commandline */ cfile = project; parser.line_no = 1; //really arg count now.. duh parser.file = "(internal)"; for(QStringList::Iterator it = Option::before_user_vars.begin(); it != Option::before_user_vars.end(); ++it) { if(!parse((*it), base_vars)) { fprintf(stderr, "Argument failed to parse: %s\n", (*it).latin1()); return FALSE; } parser.line_no++; } } /* parse project file */ debug_msg(1, "Project file: reading %s", project.latin1()); vars = base_vars; /* start with the base */ pfile = project; if(pfile != "-" && !QFile::exists(pfile) && pfile.right(4) != ".pro") pfile += ".pro"; if(!read(pfile, vars)) return FALSE; parser.line_no = 1; //really arg count now.. duh parser.file = "(internal)"; for(QStringList::Iterator it = Option::after_user_vars.begin(); it != Option::after_user_vars.end(); ++it) { if(!parse((*it), vars)) { fprintf(stderr, "Argument failed to parse: %s\n", (*it).latin1()); return FALSE; } parser.line_no++; } /* now let the user override the template from an option.. */ if(!Option::user_template.isEmpty()) { debug_msg(1, "Overriding TEMPLATE (%s) with: %s", vars["TEMPLATE"].first().latin1(), Option::user_template.latin1()); vars["TEMPLATE"].clear(); vars["TEMPLATE"].append(Option::user_template); } if(vars["TEMPLATE"].isEmpty()) vars["TEMPLATE"].append(QString("app")); else vars["TEMPLATE"].first().replace(QRegExp("\\.t$"), ""); if(!Option::user_template_prefix.isEmpty()) vars["TEMPLATE"].first().prepend(Option::user_template_prefix); if(vars["TARGET"].isEmpty()) { // ### why not simply use: // QFileInfo fi(pfile); // fi.baseName(); QString tmp = pfile; if(tmp.findRev('/') != -1) tmp = tmp.right( tmp.length() - tmp.findRev('/') - 1 ); if(tmp.findRev('.') != -1) tmp = tmp.left(tmp.findRev('.')); vars["TARGET"].append(tmp); } QString test_version = getenv("QTESTVERSION"); if (!test_version.isEmpty()) { QString s = vars["TARGET"].first(); |