-rw-r--r-- | qmake/main.cpp | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index cc2d08a..a731314 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp | |||
@@ -1,18 +1,16 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** |
3 | ** | 3 | ** |
4 | ** Definition of ________ class. | 4 | ** ??? |
5 | ** | 5 | ** |
6 | ** Created : 970521 | 6 | ** Copyright (C) 1992-2003 Trolltech AS. All rights reserved. |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** This file is part of qmake. |
9 | ** | ||
10 | ** This file is part of the network module of the Qt GUI Toolkit. | ||
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 |
14 | ** LICENSE.QPL included in the packaging of this file. | 12 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 13 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 14 | ** This file may be distributed and/or modified under the terms of the |
17 | ** GNU General Public License version 2 as published by the Free Software | 15 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 16 | ** Foundation and appearing in the file LICENSE.GPL included in the |
@@ -31,66 +29,92 @@ | |||
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 29 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 30 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 31 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 32 | ** not clear to you. |
35 | ** | 33 | ** |
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> |
42 | #include <qregexp.h> | 41 | #include <qregexp.h> |
43 | #include <qdir.h> | 42 | #include <qdir.h> |
44 | #include <stdio.h> | 43 | #include <stdio.h> |
45 | #include <stdlib.h> | 44 | #include <stdlib.h> |
46 | #include <ctype.h> | 45 | #include <ctype.h> |
47 | #include <fcntl.h> | 46 | #include <fcntl.h> |
48 | #include <sys/types.h> | 47 | #include <sys/types.h> |
49 | #include <sys/stat.h> | 48 | #include <sys/stat.h> |
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 | { |
56 | /* parse command line */ | 59 | /* parse command line */ |
57 | if(!Option::parseCommandLine(argc, argv)) | 60 | if(!Option::parseCommandLine(argc, argv)) |
58 | return 666; | 61 | return 666; |
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(); |
71 | } | ||
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); | ||
69 | } | 88 | } |
70 | QMakeProject proj; | 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) |
74 | files << "(*hack*)"; //we don't even use files, but we do the for() body once | 98 | files << "(*hack*)"; //we don't even use files, but we do the for() body once |
75 | else | 99 | else |
76 | files = Option::mkfile::project_files; | 100 | files = Option::mkfile::project_files; |
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()); |
84 | QDir::setCurrent(oldpwd); //reset the old pwd | 108 | QDir::setCurrent(oldpwd); //reset the old pwd |
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 | } |
92 | 116 | ||
93 | /* read project.. */ | 117 | /* read project.. */ |
94 | if(!proj.read(fn, oldpwd)) { | 118 | if(!proj.read(fn, oldpwd)) { |
95 | fprintf(stderr, "Error processing project file: %s\n", | 119 | fprintf(stderr, "Error processing project file: %s\n", |
96 | fn == "-" ? "(stdin)" : (*pfile).latin1()); | 120 | fn == "-" ? "(stdin)" : (*pfile).latin1()); |
@@ -118,16 +142,17 @@ int main(int argc, char **argv) | |||
118 | if(Option::output.name() == "-") { | 142 | if(Option::output.name() == "-") { |
119 | Option::output.setName(""); | 143 | Option::output.setName(""); |
120 | Option::output_dir = QDir::currentDirPath(); | 144 | Option::output_dir = QDir::currentDirPath(); |
121 | Option::output.open(IO_WriteOnly | IO_Translate, stdout); | 145 | Option::output.open(IO_WriteOnly | IO_Translate, stdout); |
122 | using_stdout = TRUE; | 146 | using_stdout = TRUE; |
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()); |
129 | return 5; | 154 | return 5; |
130 | } | 155 | } |
131 | } | 156 | } |
132 | } | 157 | } |
133 | } else { | 158 | } else { |
@@ -144,15 +169,15 @@ int main(int argc, char **argv) | |||
144 | } | 169 | } |
145 | delete mkfile; | 170 | delete mkfile; |
146 | mkfile = NULL; | 171 | mkfile = NULL; |
147 | 172 | ||
148 | /* debugging */ | 173 | /* debugging */ |
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 | } |
156 | } | 181 | } |
157 | return exit_val; | 182 | return exit_val; |
158 | } | 183 | } |