author | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2003-07-10 02:40:10 (UTC) |
commit | 155d68c1e7d7dc0fed2534ac43d6d77ce2781f55 (patch) (unidiff) | |
tree | e6edaa5a7040fe6c224c3943d1094dcf02e4f74c /qmake/main.cpp | |
parent | 86703e8a5527ef114facd02c005b6b3a7e62e263 (diff) | |
download | opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.zip opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.gz opie-155d68c1e7d7dc0fed2534ac43d6d77ce2781f55.tar.bz2 |
update qmake to 1.05a
-rw-r--r-- | qmake/main.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/qmake/main.cpp b/qmake/main.cpp index eed1697..cc2d08a 100644 --- a/qmake/main.cpp +++ b/qmake/main.cpp | |||
@@ -1,153 +1,158 @@ | |||
1 | /**************************************************************************** | 1 | /**************************************************************************** |
2 | ** $Id$ | 2 | ** $Id$ |
3 | ** | 3 | ** |
4 | ** Definition of ________ class. | 4 | ** Definition of ________ class. |
5 | ** | 5 | ** |
6 | ** Created : 970521 | 6 | ** Created : 970521 |
7 | ** | 7 | ** |
8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. | 8 | ** Copyright (C) 1992-2000 Trolltech AS. All rights reserved. |
9 | ** | 9 | ** |
10 | ** This file is part of the network module of the Qt GUI Toolkit. | 10 | ** This file is part of the network module of the Qt GUI Toolkit. |
11 | ** | 11 | ** |
12 | ** This file may be distributed under the terms of the Q Public License | 12 | ** 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 | 13 | ** as defined by Trolltech AS of Norway and appearing in the file |
14 | ** LICENSE.QPL included in the packaging of this file. | 14 | ** LICENSE.QPL included in the packaging of this file. |
15 | ** | 15 | ** |
16 | ** This file may be distributed and/or modified under the terms of the | 16 | ** 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 | 17 | ** GNU General Public License version 2 as published by the Free Software |
18 | ** Foundation and appearing in the file LICENSE.GPL included in the | 18 | ** Foundation and appearing in the file LICENSE.GPL included in the |
19 | ** packaging of this file. | 19 | ** packaging of this file. |
20 | ** | 20 | ** |
21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this | 21 | ** Licensees holding valid Qt Enterprise Edition licenses may use this |
22 | ** file in accordance with the Qt Commercial License Agreement provided | 22 | ** file in accordance with the Qt Commercial License Agreement provided |
23 | ** with the Software. | 23 | ** with the Software. |
24 | ** | 24 | ** |
25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 25 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 26 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
27 | ** | 27 | ** |
28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | 28 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for |
29 | ** information about Qt Commercial License Agreements. | 29 | ** information about Qt Commercial License Agreements. |
30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | 30 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. |
31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 31 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
32 | ** | 32 | ** |
33 | ** Contact info@trolltech.com if any conditions of this licensing are | 33 | ** Contact info@trolltech.com if any conditions of this licensing are |
34 | ** not clear to you. | 34 | ** not clear to you. |
35 | ** | 35 | ** |
36 | **********************************************************************/ | 36 | **********************************************************************/ |
37 | 37 | ||
38 | #include "project.h" | 38 | #include "project.h" |
39 | #include "option.h" | 39 | #include "option.h" |
40 | #include "makefile.h" | 40 | #include "makefile.h" |
41 | #include <qnamespace.h> | 41 | #include <qnamespace.h> |
42 | #include <qregexp.h> | 42 | #include <qregexp.h> |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <stdio.h> | 44 | #include <stdio.h> |
45 | #include <stdlib.h> | 45 | #include <stdlib.h> |
46 | #include <ctype.h> | 46 | #include <ctype.h> |
47 | #include <fcntl.h> | 47 | #include <fcntl.h> |
48 | #include <sys/types.h> | 48 | #include <sys/types.h> |
49 | #include <sys/stat.h> | 49 | #include <sys/stat.h> |
50 | 50 | ||
51 | // for Borland, main is defined to qMain which breaks qmake | 51 | // for Borland, main is defined to qMain which breaks qmake |
52 | #undef main | 52 | #undef main |
53 | 53 | ||
54 | int main(int argc, char **argv) | 54 | int main(int argc, char **argv) |
55 | { | 55 | { |
56 | /* parse command line */ | 56 | /* parse command line */ |
57 | if(!Option::parseCommandLine(argc, argv)) | 57 | if(!Option::parseCommandLine(argc, argv)) |
58 | return 666; | 58 | return 666; |
59 | 59 | ||
60 | QDir sunworkshop42workaround = QDir::current(); | 60 | QDir sunworkshop42workaround = QDir::current(); |
61 | QString oldpwd = sunworkshop42workaround.currentDirPath(); | 61 | QString oldpwd = sunworkshop42workaround.currentDirPath(); |
62 | Option::output_dir = oldpwd; //for now this is the output dir | 62 | Option::output_dir = oldpwd; //for now this is the output dir |
63 | if(Option::output_dir.right(1) != QString(QChar(QDir::separator()))) | 63 | #ifdef Q_WS_WIN |
64 | Option::output_dir += QDir::separator(); | 64 | if ( !(Option::output_dir.length() == 3 && Option::output_dir[0].isLetter() && Option::output_dir.endsWith(":/") ) ) |
65 | #endif | ||
66 | { | ||
67 | if(Option::output_dir.right(1) != QString(QChar(QDir::separator()))) | ||
68 | Option::output_dir += QDir::separator(); | ||
69 | } | ||
65 | QMakeProject proj; | 70 | QMakeProject proj; |
66 | int exit_val = 0; | 71 | int exit_val = 0; |
67 | QStringList files; | 72 | QStringList files; |
68 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) | 73 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) |
69 | files << "(*hack*)"; //we don't even use files, but we do the for() body once | 74 | files << "(*hack*)"; //we don't even use files, but we do the for() body once |
70 | else | 75 | else |
71 | files = Option::mkfile::project_files; | 76 | files = Option::mkfile::project_files; |
72 | for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) { | 77 | for(QStringList::Iterator pfile = files.begin(); pfile != files.end(); pfile++) { |
73 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 78 | if(Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
74 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { | 79 | Option::qmake_mode == Option::QMAKE_GENERATE_PRL) { |
75 | QString fn = (*pfile); | 80 | QString fn = (*pfile); |
76 | 81 | ||
77 | //setup pwd properly | 82 | //setup pwd properly |
78 | debug_msg(1, "Resetting dir to: %s", oldpwd.latin1()); | 83 | debug_msg(1, "Resetting dir to: %s", oldpwd.latin1()); |
79 | QDir::setCurrent(oldpwd); //reset the old pwd | 84 | QDir::setCurrent(oldpwd); //reset the old pwd |
80 | int di = fn.findRev(Option::dir_sep); | 85 | int di = fn.findRev(Option::dir_sep); |
81 | if(di != -1) { | 86 | if(di != -1) { |
82 | debug_msg(1, "Changing dir to: %s", fn.left(di).latin1()); | 87 | debug_msg(1, "Changing dir to: %s", fn.left(di).latin1()); |
83 | if(!QDir::setCurrent(fn.left(fn.findRev(Option::dir_sep)))) | 88 | if(!QDir::setCurrent(fn.left(fn.findRev(Option::dir_sep)))) |
84 | fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1()); | 89 | fprintf(stderr, "Cannot find directory: %s\n", fn.left(di).latin1()); |
85 | fn = fn.right(fn.length() - di - 1); | 90 | fn = fn.right(fn.length() - di - 1); |
86 | } | 91 | } |
87 | 92 | ||
88 | /* read project.. */ | 93 | /* read project.. */ |
89 | if(!proj.read(fn, oldpwd)) { | 94 | if(!proj.read(fn, oldpwd)) { |
90 | fprintf(stderr, "Error processing project file: %s\n", | 95 | fprintf(stderr, "Error processing project file: %s\n", |
91 | fn == "-" ? "(stdin)" : (*pfile).latin1()); | 96 | fn == "-" ? "(stdin)" : (*pfile).latin1()); |
92 | exit_val = 2; | 97 | exit_val = 2; |
93 | continue; | 98 | continue; |
94 | } | 99 | } |
95 | if(Option::mkfile::do_preprocess) //no need to create makefile | 100 | if(Option::mkfile::do_preprocess) //no need to create makefile |
96 | continue; | 101 | continue; |
97 | 102 | ||
98 | /* let Option post-process */ | 103 | /* let Option post-process */ |
99 | if(!Option::postProcessProject(&proj)) { | 104 | if(!Option::postProcessProject(&proj)) { |
100 | fprintf(stderr, "Error post-processing project file: %s", | 105 | fprintf(stderr, "Error post-processing project file: %s", |
101 | fn == "-" ? "(stdin)" : (*pfile).latin1()); | 106 | fn == "-" ? "(stdin)" : (*pfile).latin1()); |
102 | exit_val = 8; | 107 | exit_val = 8; |
103 | continue; | 108 | continue; |
104 | } | 109 | } |
105 | } | 110 | } |
106 | 111 | ||
107 | bool using_stdout = FALSE; | 112 | bool using_stdout = FALSE; |
108 | MakefileGenerator *mkfile = MakefileGenerator::create(&proj); //figure out generator | 113 | MakefileGenerator *mkfile = MakefileGenerator::create(&proj); //figure out generator |
109 | if(mkfile && (Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || | 114 | if(mkfile && (Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE || |
110 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)) { | 115 | Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT)) { |
111 | //open output | 116 | //open output |
112 | if(!(Option::output.state() & IO_Open)) { | 117 | if(!(Option::output.state() & IO_Open)) { |
113 | if(Option::output.name() == "-") { | 118 | if(Option::output.name() == "-") { |
114 | Option::output.setName(""); | 119 | Option::output.setName(""); |
115 | Option::output_dir = QDir::currentDirPath(); | 120 | Option::output_dir = QDir::currentDirPath(); |
116 | Option::output.open(IO_WriteOnly | IO_Translate, stdout); | 121 | Option::output.open(IO_WriteOnly | IO_Translate, stdout); |
117 | using_stdout = TRUE; | 122 | using_stdout = TRUE; |
118 | } else { | 123 | } else { |
119 | if(Option::output.name().isEmpty() && Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE) | 124 | if(Option::output.name().isEmpty() && Option::qmake_mode == Option::QMAKE_GENERATE_MAKEFILE) |
120 | Option::output.setName(proj.first("QMAKE_MAKEFILE")); | 125 | Option::output.setName(proj.first("QMAKE_MAKEFILE")); |
121 | if(!mkfile->openOutput(Option::output)) { | 126 | if(!mkfile->openOutput(Option::output)) { |
122 | fprintf(stderr, "Failure to open file: %s\n", | 127 | fprintf(stderr, "Failure to open file: %s\n", |
123 | Option::output.name().isEmpty() ? "(stdout)" : Option::output.name().latin1()); | 128 | Option::output.name().isEmpty() ? "(stdout)" : Option::output.name().latin1()); |
124 | return 5; | 129 | return 5; |
125 | } | 130 | } |
126 | } | 131 | } |
127 | } | 132 | } |
128 | } else { | 133 | } else { |
129 | using_stdout = TRUE; //kind of.. | 134 | using_stdout = TRUE; //kind of.. |
130 | } | 135 | } |
131 | if(mkfile && !mkfile->write()) { | 136 | if(mkfile && !mkfile->write()) { |
132 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) | 137 | if(Option::qmake_mode == Option::QMAKE_GENERATE_PROJECT) |
133 | fprintf(stderr, "Unable to generate project file.\n"); | 138 | fprintf(stderr, "Unable to generate project file.\n"); |
134 | else | 139 | else |
135 | fprintf(stderr, "Unable to generate makefile for: %s\n", (*pfile).latin1()); | 140 | fprintf(stderr, "Unable to generate makefile for: %s\n", (*pfile).latin1()); |
136 | if(!using_stdout) | 141 | if(!using_stdout) |
137 | QFile::remove(Option::output.name()); | 142 | QFile::remove(Option::output.name()); |
138 | exit_val = 6; | 143 | exit_val = 6; |
139 | } | 144 | } |
140 | delete mkfile; | 145 | delete mkfile; |
141 | mkfile = NULL; | 146 | mkfile = NULL; |
142 | 147 | ||
143 | /* debugging */ | 148 | /* debugging */ |
144 | if(Option::debug_level) { | 149 | if(Option::debug_level) { |
145 | QMap<QString, QStringList> &vars = proj.variables(); | 150 | QMap<QString, QStringList> &vars = proj.variables(); |
146 | for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) { | 151 | for(QMap<QString, QStringList>::Iterator it = vars.begin(); it != vars.end(); ++it) { |
147 | if(it.key().left(1) != "." && !it.data().isEmpty()) | 152 | if(it.key().left(1) != "." && !it.data().isEmpty()) |
148 | debug_msg(1, "%s === %s", it.key().latin1(), it.data().join(" :: ").latin1()); | 153 | debug_msg(1, "%s === %s", it.key().latin1(), it.data().join(" :: ").latin1()); |
149 | } | 154 | } |
150 | } | 155 | } |
151 | } | 156 | } |
152 | return exit_val; | 157 | return exit_val; |
153 | } | 158 | } |