-rw-r--r-- | qmake/main.cpp | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index cc2d08a..a731314 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp | |||
@@ -1,13 +1,11 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | ||
3 | ** | 2 | ** |
4 | ** Definition of ________ class. | ||
5 | ** | 3 | ** |
6 | ** Created : 970521 | 4 | ** ??? |
7 | ** | 5 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
9 | ** | 7 | ** |
10 | ** This file is part of the network module of the Qt GUI Toolkit. | 8 | ** This file is part of qmake. |
11 | ** | 9 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 10 | ** This file may be distributed under the terms of the Q Public License |
13 | ** as defined by Trolltech AS of Norway and appearing in the file | 11 | ** as defined by Trolltech AS of Norway and appearing in the file |
@@ -36,6 +34,7 @@ | |||
36 | **********************************************************************/ | 34 | **********************************************************************/ |
37 | 35 | ||
38 | #include "project.h" | 36 | #include "project.h" |
37 | #include "property.h" | ||
39 | #include "option.h" | 38 | #include "option.h" |
40 | #include "makefile.h" | 39 | #include "makefile.h" |
41 | #include <qnamespace.h> | 40 | #include <qnamespace.h> |
@@ -50,6 +49,10 @@ | |||
50 | 49 | ||
51 | // for Borland, main is defined to qMain which breaks qmake | 50 | // for Borland, main is defined to qMain which breaks qmake |
52 | #undef main | 51 | #undef main |
52 | #ifdef Q_OS_MAC | ||
53 | // for qurl | ||
54 | bool qt_resolve_symlinks = FALSE; | ||
55 | #endif | ||
53 | 56 | ||
54 | int main(int argc, char **argv) | 57 | int main(int argc, char **argv) |
55 | { | 58 | { |
@@ -59,15 +62,36 @@ int main(int argc, char **argv) | |||
59 | 62 | ||
60 | QDir sunworkshop42workaround = QDir::current(); | 63 | QDir sunworkshop42workaround = QDir::current(); |
61 | QString oldpwd = sunworkshop42workaround.currentDirPath(); | 64 | QString oldpwd = sunworkshop42workaround.currentDirPath(); |
62 | Option::output_dir = oldpwd; //for now this is the output dir | ||
63 | #ifdef Q_WS_WIN | 65 | #ifdef Q_WS_WIN |
64 | if ( !(Option::output_dir.length() == 3 && Option::output_dir[0].isLetter() && Option::output_dir.endsWith(":/") ) ) | 66 | if(!(oldpwd.length() == 3 && oldpwd[0].isLetter() && oldpwd.endsWith(":/") ) ) |
65 | #endif | 67 | #endif |
66 | { | 68 | { |
67 | if(Option::output_dir.right(1) != QString(QChar(QDir::separator()))) | 69 | if(oldpwd.right(1) != QString(QChar(QDir::separator()))) |
68 | Option::output_dir += QDir::separator(); | 70 | oldpwd += QDir::separator(); |
69 | } | 71 | } |
70 | QMakeProject proj; | 72 | Option::output_dir = oldpwd; //for now this is the output dir |
73 | |||
74 | if(Option::output.name() != "-") { | ||
75 | QFileInfo fi(Option::output); | ||
76 | QString dir; | ||
77 | if(fi.isDir()) { | ||
78 | dir = fi.filePath(); | ||
79 | } else { | ||
80 | QString tmp_dir = fi.dirPath(); | ||
81 | if(!tmp_dir.isEmpty() && QFile::exists(tmp_dir)) | ||
82 | dir = tmp_dir; | ||
83 | } | ||
84 | if(!dir.isNull() && dir != ".") | ||
85 | Option::output_dir = dir; | ||
86 | if(QDir::isRelativePath(Option::output_dir)) | ||
87 | Option::output_dir.prepend(oldpwd); | ||
88 | } | ||
89 | |||
90 | QMakeProperty prop; | ||
91 | if(Option::qmake_mode == Option::QMAKE_QUERY_PROPERTY || Option::qmake_mode == Option::QMAKE_SET_PROPERTY) | ||
92 | return prop.exec() ? 0 : 101; | ||
93 | |||
94 | QMakeProject proj(&prop); | ||
71 | int exit_val = 0; | 95 | int exit_val = 0; |
72 | QStringList files; | 96 | QStringList files; |
73 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) | 97 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) |
@@ -77,7 +101,7 @@ int main(int argc, char **argv) | |||
77 | for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) { | 101 | for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) { |
78 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 102 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
79 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { | 103 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { |
80 | QString fn = (*pfile); | 104 | QString fn = Option::fixPathToLocalOS((*pfile)); |
81 | 105 | ||
82 | //setup pwd properly | 106 | //setup pwd properly |
83 | debug_msg(1, "Resetting dir to: %s", oldpwd.latin1()); | 107 | debug_msg(1, "Resetting dir to: %s", oldpwd.latin1()); |
@@ -85,7 +109,7 @@ int main(int argc, char **argv) | |||
85 | int di = fn.findRev(Option::dir_sep); | 109 | int di = fn.findRev(Option::dir_sep); |
86 | if(di != -1) { | 110 | if(di != -1) { |
87 | debug_msg(1, "Changing dir to: %s", fn.left(di).latin1()); | 111 | debug_msg(1, "Changing dir to: %s", fn.left(di).latin1()); |
88 | if(!QDir::setCurrent(fn.left(fn.findRev(Option::dir_sep)))) | 112 | if(!QDir::setCurrent(fn.left(di))) |
89 | fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1()); | 113 | fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1()); |
90 | fn = fn.right(fn.length() - di - 1); | 114 | fn = fn.right(fn.length() - di - 1); |
91 | } | 115 | } |
@@ -123,6 +147,7 @@ int main(int argc, char **argv) | |||
123 | } else { | 147 | } else { |
124 | if(Option::output.name().isEmpty() && Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE) | 148 | if(Option::output.name().isEmpty() && Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE) |
125 | Option::output.setName(proj.first("QMAKE_MAKEFILE")); | 149 | Option::output.setName(proj.first("QMAKE_MAKEFILE")); |
150 | Option::output_dir = oldpwd; | ||
126 | if(!mkfile->openOutput(Option::output)) { | 151 | if(!mkfile->openOutput(Option::output)) { |
127 | fprintf(stderr, "Failure to open file: %s\n", | 152 | fprintf(stderr, "Failure to open file: %s\n", |
128 | Option::output.name().isEmpty() ? "(stdout)" : Option::output.name().latin1()); | 153 | Option::output.name().isEmpty() ? "(stdout)" : Option::output.name().latin1()); |
@@ -149,7 +174,7 @@ int main(int argc, char **argv) | |||
149 | if(Option::debug_level) { | 174 | if(Option::debug_level) { |
150 | QMap<QString, QStringList> &vars = proj.variables(); | 175 | QMap<QString, QStringList> &vars = proj.variables(); |
151 | for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) { | 176 | for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) { |
152 | if(it.key().left(1) != "." && !it.data().isEmpty()) | 177 | if(!it.key().startsWith(".") && !it.data().isEmpty()) |
153 | debug_msg(1, "%s === %s", it.key().latin1(), it.data().join(" :: ").latin1()); | 178 | debug_msg(1, "%s === %s", it.key().latin1(), it.data().join(" :: ").latin1()); |
154 | } | 179 | } |
155 | } | 180 | } |