summaryrefslogtreecommitdiff
path: root/qmake/generators/mac/pbuilder_pbx.cpp
Unidiff
Diffstat (limited to 'qmake/generators/mac/pbuilder_pbx.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--qmake/generators/mac/pbuilder_pbx.cpp981
1 files changed, 697 insertions, 284 deletions
diff --git a/qmake/generators/mac/pbuilder_pbx.cpp b/qmake/generators/mac/pbuilder_pbx.cpp
index b46005b..9d1286e 100644
--- a/qmake/generators/mac/pbuilder_pbx.cpp
+++ b/qmake/generators/mac/pbuilder_pbx.cpp
@@ -1,13 +1,11 @@
1/**************************************************************************** 1/****************************************************************************
2** $Id$ 2**
3** 3**
4** Definition of ________ class. 4** Implementation of ProjectBuilderMakefileGenerator class.
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
@@ -37,11 +35,13 @@
37 35
38#include "pbuilder_pbx.h" 36#include "pbuilder_pbx.h"
39#include "option.h" 37#include "option.h"
38#include "meta.h"
40#include <qdir.h> 39#include <qdir.h>
41#include <qdict.h> 40#include <qdict.h>
42#include <qregexp.h> 41#include <qregexp.h>
43#include <stdlib.h> 42#include <stdlib.h>
44#include <time.h> 43#include <time.h>
44#include "qtmd5.h"
45#ifdef Q_OS_UNIX 45#ifdef Q_OS_UNIX
46# include <sys/types.h> 46# include <sys/types.h>
47# include <sys/stat.h> 47# include <sys/stat.h>
@@ -49,7 +49,6 @@
49 49
50// Note: this is fairly hacky, but it does the job... 50// Note: this is fairly hacky, but it does the job...
51 51
52
53ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p) 52ProjectBuilderMakefileGenerator::ProjectBuilderMakefileGenerator(QMakeProject *p) : UnixMakefileGenerator(p)
54{ 53{
55 54
@@ -67,16 +66,210 @@ ProjectBuilderMakefileGenerator::writeMakefile(QTextStream &t)
67 66
68 project->variables()["MAKEFILE"].clear(); 67 project->variables()["MAKEFILE"].clear();
69 project->variables()["MAKEFILE"].append("Makefile"); 68 project->variables()["MAKEFILE"].append("Makefile");
70 if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib") { 69 if(project->first("TEMPLATE") == "app" || project->first("TEMPLATE") == "lib")
71 return writeMakeParts(t); 70 return writeMakeParts(t);
72 } else if(project->first("TEMPLATE") == "subdirs") { 71 else if(project->first("TEMPLATE") == "subdirs")
73 writeSubdirs(t, FALSE); 72 return writeSubdirs(t, FALSE);
74 return TRUE;
75 }
76 return FALSE; 73 return FALSE;
77} 74}
78 75
79bool 76bool
77ProjectBuilderMakefileGenerator::writeSubdirs(QTextStream &t, bool direct)
78{
79 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
80 QDir::currentDirPath());
81 QFile mkwrapf(mkwrap);
82 if(mkwrapf.open(IO_WriteOnly | IO_Translate)) {
83 debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1());
84 QTextStream mkwrapt(&mkwrapf);
85 UnixMakefileGenerator::writeSubdirs(mkwrapt, direct);
86 }
87
88 //HEADER
89 t << "// !$*UTF8*$!" << "\n"
90 << "{" << "\n"
91 << "\t" << "archiveVersion = 1;" << "\n"
92 << "\t" << "classes = {" << "\n" << "\t" << "};" << "\n"
93 << "\t" << "objectVersion = " << pbuilderVersion() << ";" << "\n"
94 << "\t" << "objects = {" << endl;
95
96 //SUBDIRS
97 QStringList subdirs = project->variables()["SUBDIRS"];
98 QString oldpwd = QDir::currentDirPath();
99 QMap<QString, QStringList> groups;
100 for(QStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) {
101 QFileInfo fi(Option::fixPathToLocalOS((*it), TRUE));
102 if(fi.exists()) {
103 if(fi.isDir()) {
104 QString profile = (*it);
105 if(!profile.endsWith(Option::dir_sep))
106 profile += Option::dir_sep;
107 profile += fi.baseName() + ".pro";
108 subdirs.append(profile);
109 } else {
110 QMakeProject tmp_proj;
111 QString dir = fi.dirPath(), fn = fi.fileName();
112 if(!dir.isEmpty()) {
113 if(!QDir::setCurrent(dir))
114 fprintf(stderr, "Cannot find directory: %s\n", dir.latin1());
115 }
116 if(tmp_proj.read(fn, oldpwd)) {
117 if(Option::debug_level) {
118 QMap<QString, QStringList> &vars = tmp_proj.variables();
119 for(QMap<QString, QStringList>::Iterator it = vars.begin();
120 it != vars.end(); ++it) {
121 if(it.key().left(1) != "." && !it.data().isEmpty())
122 debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(),
123 it.data().join(" :: ").latin1());
124 }
125 }
126 if(tmp_proj.first("TEMPLATE") == "subdirs") {
127 subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]);
128 } else if(tmp_proj.first("TEMPLATE") == "app" || tmp_proj.first("TEMPLATE") == "lib") {
129 QString pbxproj = QDir::currentDirPath() + Option::dir_sep + tmp_proj.first("TARGET") + projectSuffix();
130 if(!QFile::exists(pbxproj)) {
131 warn_msg(WarnLogic, "Ignored (not found) '%s'", pbxproj.latin1());
132 goto nextfile; // # Dirty!
133 }
134 project->variables()["QMAKE_PBX_SUBDIRS"] += pbxproj;
135 //PROJECTREF
136 {
137 bool in_root = TRUE;
138 QString name = QDir::currentDirPath();
139 QString project_key = keyFor(pbxproj + "_PROJECTREF");
140 if(project->isActiveConfig("flat")) {
141 QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);
142 if(flat_file.find(Option::dir_sep) != -1) {
143 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
144 name = dirs.back();
145 }
146 } else {
147 QString flat_file = fileFixify(name, oldpwd, Option::output_dir, TRUE);
148 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {
149 QString last_grp("QMAKE_PBX_HEIR_GROUP");
150 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
151 name = dirs.back();
152 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
153 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp));
154 if(dir_it == dirs.begin()) {
155 if(!groups.contains(new_grp))
156 project->variables()["QMAKE_PBX_GROUPS"].append(new_grp_key);
157 } else {
158 if(!groups[last_grp].contains(new_grp_key))
159 groups[last_grp] += new_grp_key;
160 }
161 last_grp = new_grp;
162 }
163 groups[last_grp] += project_key;
164 in_root = FALSE;
165 }
166 }
167 if(in_root)
168 project->variables()["QMAKE_PBX_GROUPS"] += project_key;
169 t << "\t\t" << project_key << " = {" << "\n"
170 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
171 << "\t\t\t" << "name = " << tmp_proj.first("TARGET") << ";" << "\n"
172 << "\t\t\t" << "path = " << pbxproj << ";" << "\n"
173 << "\t\t\t" << "refType = 0;" << "\n"
174 << "\t\t\t" << "sourceTree = \"<absolute>\";" << "\n"
175 << "\t\t" << "};" << "\n";
176 //PRODUCTGROUP
177 t << "\t\t" << keyFor(pbxproj + "_PRODUCTGROUP") << " = {" << "\n"
178 << "\t\t\t" << "children = (" << "\n"
179 << "\t\t\t" << ");" << "\n"
180 << "\t\t\t" << "isa = PBXGroup;" << "\n"
181 << "\t\t\t" << "name = Products;" << "\n"
182 << "\t\t\t" << "refType = 4;" << "\n"
183 << "\t\t\t" << "sourceTree = \"<group>\";" << "\n"
184 << "\t\t" << "};" << "\n";
185 }
186 }
187 }
188nextfile:
189 QDir::setCurrent(oldpwd);
190 }
191 }
192 }
193 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) {
194 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"
195 << "\t\t\t" << "isa = PBXGroup;" << "\n"
196 << "\t\t\t" << "children = (" << "\n"
197 << valGlue(grp_it.data(), "\t\t\t\t", ",\n\t\t\t\t", "\n")
198 << "\t\t\t" << ");" << "\n"
199 << "\t\t\t" << "name = \"" << grp_it.key().section(Option::dir_sep, -1) << "\";" << "\n"
200 << "\t\t\t" << "refType = 4;" << "\n"
201 << "\t\t" << "};" << "\n";
202 }
203
204 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
205 //BUILDSTYLE
206 QString active_buildstyle;
207#if 0
208 for(int as_release = 0; as_release < 2; as_release++)
209#else
210 bool as_release = !project->isActiveConfig("debug");
211#endif
212 {
213 QString key = keyFor("QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"));
214 if(project->isActiveConfig("debug") != as_release)
215 active_buildstyle = key;
216 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key);
217 t << "\t\t" << key << " = {" << "\n"
218 << "\t\t\t" << "buildRules = (" << "\n"
219 << "\t\t\t" << ");" << "\n"
220 << "\t\t\t" << "buildSettings = {" << "\n"
221 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n";
222 if(as_release)
223 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n";
224 t << "\t\t\t" << "};" << "\n"
225 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"
226 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n"
227 << "\t\t" << "};" << "\n";
228 }
229
230 //ROOT_GROUP
231 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n"
232 << "\t\t\t" << "children = (" << "\n"
233 << varGlue("QMAKE_PBX_GROUPS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
234 << "\t\t\t" << ");" << "\n"
235 << "\t\t\t" << "isa = PBXGroup;" << "\n"
236 << "\t\t\t" << "refType = 4;" << "\n"
237 << "\t\t\t" << "sourceTree = \"<group>\";" << "\n"
238 << "\t\t" << "};" << "\n";
239
240 //ROOT
241 t << "\t\t" << keyFor("QMAKE_PBX_ROOT") << " = {" << "\n"
242 << "\t\t\t" << "buildSettings = {" << "\n"
243 << "\t\t\t" << "};" << "\n"
244 << "\t\t\t" << "buildStyles = (" << "\n"
245 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
246 << "\t\t\t" << ");" << "\n"
247 << "\t\t\t" << "isa = PBXProject;" << "\n"
248 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n"
249 << "\t\t\t" << "projectDirPath = \"\";" << "\n"
250 << "\t\t\t" << "projectReferences = (" << "\n";
251 {
252 QStringList &libdirs = project->variables()["QMAKE_PBX_SUBDIRS"];
253 for(QStringList::Iterator it = libdirs.begin(); it != libdirs.end(); ++it)
254 t << "\t\t\t\t" << "{" << "\n"
255 << "\t\t\t\t\t" << "ProductGroup = " << keyFor((*it) + "_PRODUCTGROUP") << ";" << "\n"
256 << "\t\t\t\t\t" << "ProjectRef = " << keyFor((*it) + "_PROJECTREF") << ";" << "\n"
257 << "\t\t\t\t" << "}," << "\n";
258 }
259 t << "\t\t\t" << ");" << "\n"
260 << "\t\t\t" << "targets = (" << "\n"
261 << "\t\t\t" << ");" << "\n"
262 << "\t\t" << "};" << "\n";
263
264 //FOOTER
265 t << "\t" << "};" << "\n"
266 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n"
267 << "}" << endl;
268
269 return TRUE;
270}
271
272bool
80ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t) 273ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
81{ 274{
82 int i; 275 int i;
@@ -107,7 +300,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
107 } 300 }
108 QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE"); 301 QString phase_key = keyFor("QMAKE_PBX_MAKEQMAKE_BUILDPHASE");
109 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 302 mkfile = fileFixify(mkfile, QDir::currentDirPath());
110 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 303 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
111 t << "\t\t" << phase_key << " = {" << "\n" 304 t << "\t\t" << phase_key << " = {" << "\n"
112 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" 305 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
113 << "\t\t\t" << "files = (" << "\n" 306 << "\t\t\t" << "files = (" << "\n"
@@ -126,60 +319,118 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
126 319
127 //DUMP SOURCES 320 //DUMP SOURCES
128 QMap<QString, QStringList> groups; 321 QMap<QString, QStringList> groups;
129 QString srcs[] = { "SOURCES", "SRCMOC", "UICIMPLS", QString::null }; 322 QString srcs[] = { "HEADERS", "SOURCES", "SRCMOC", "UICIMPLS", "QMAKE_IMAGE_COLLECTION",
323 "FORMS", "QMAKE_INTERNAL_INCLUDED_FILES", QString::null };
130 for(i = 0; !srcs[i].isNull(); i++) { 324 for(i = 0; !srcs[i].isNull(); i++) {
131 tmp = project->variables()[srcs[i]]; 325 tmp = project->variables()[srcs[i]];
326 if(srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES") {
327 QString pfile = project->projectFile();
328 if(pfile != "(stdin)")
329 tmp.prepend(pfile);
330 }
132 QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]]; 331 QStringList &src_list = project->variables()["QMAKE_PBX_" + srcs[i]];
332 QStringList &root_group_list = project->variables()["QMAKE_PBX_GROUPS"];
333
334 //hard coded groups..
335 QString src_group;
336 if(srcs[i] == "SOURCES")
337 src_group = "Sources";
338 else if(srcs[i] == "HEADERS")
339 src_group = "Headers";
340 else if(srcs[i] == "SRCMOC")
341 src_group = "Sources [moc]";
342 else if(srcs[i] == "UICIMPLS" || srcs[i] == "FORMS")
343 src_group = "Sources [uic]";
344 else if(srcs[i] == "QMAKE_IMAGE_COLLECTION")
345 src_group = "Sources [images]";
346 else if(srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES")
347 src_group = "Sources [qmake]";
348
133 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) { 349 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {
134 QString file = fileFixify((*it)); 350 QStringList files = (*it);
135 if(file.endsWith(Option::moc_ext)) 351 bool buildable = TRUE;
136 continue; 352 if(srcs[i] == "FORMS") {
137 bool in_root = TRUE; 353 QString form_dot_h = (*it) + Option::h_ext.first();
138 QString src_key = keyFor(file); 354 if(QFile::exists(form_dot_h))
139 if(!project->isActiveConfig("flat")) { 355 files += form_dot_h;
140 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE); 356 buildable = FALSE;
141 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) { 357 } else if(srcs[i] == "HEADERS" || srcs[i] == "QMAKE_INTERNAL_INCLUDED_FILES") {
142 QString last_grp("QMAKE_PBX_" + srcs[i] + "_HEIR_GROUP"); 358 buildable = FALSE;
143 QStringList dirs = QStringList::split(Option::dir_sep, flat_file); 359 }
144 dirs.pop_back(); //remove the file portion as it will be added via src_key 360
145 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { 361 files = fileFixify(files);
146 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), 362 for(QStringList::Iterator file_it = files.begin(); file_it != files.end(); ++file_it) {
147 new_grp_key(keyFor(new_grp)), last_grp_key(keyFor(last_grp)); 363 QString file = (*file_it);
148 if(dir_it == dirs.begin()) { 364 if(file.length() >= 2 && (file[0] == '"' || file[0] == '\'') && file[(int) file.length()-1] == file[0])
149 if(!groups.contains(new_grp)) 365 file = file.mid(1, file.length()-2);
150 project->variables()["QMAKE_PBX_" + srcs[i]].append(new_grp_key); 366 if(file.endsWith(Option::cpp_moc_ext) || file.endsWith(Option::prl_ext))
151 } else { 367 continue;
152 groups[last_grp] += new_grp_key; 368 bool in_root = TRUE;
369 QString src_key = keyFor(file), name = file;
370 if(project->isActiveConfig("flat")) {
371 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);
372 if(flat_file.find(Option::dir_sep) != -1) {
373 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
374 name = dirs.back();
375 }
376 } else {
377 QString flat_file = fileFixify(file, QDir::currentDirPath(), Option::output_dir, TRUE);
378 if(QDir::isRelativePath(flat_file) && flat_file.find(Option::dir_sep) != -1) {
379 QString last_grp("QMAKE_PBX_" + src_group + "_HEIR_GROUP");
380 QStringList dirs = QStringList::split(Option::dir_sep, flat_file);
381 name = dirs.back();
382 dirs.pop_back(); //remove the file portion as it will be added via src_key
383 for(QStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) {
384 QString new_grp(last_grp + Option::dir_sep + (*dir_it)), new_grp_key(keyFor(new_grp));
385 if(dir_it == dirs.begin()) {
386 if(!src_list.contains(new_grp_key))
387 src_list.append(new_grp_key);
388 } else {
389 if(!groups[last_grp].contains(new_grp_key))
390 groups[last_grp] += new_grp_key;
391 }
392 last_grp = new_grp;
393 }
394 groups[last_grp] += src_key;
395 in_root = FALSE;
396 }
397 }
398 if(in_root)
399 src_list.append(src_key);
400 //source reference
401 t << "\t\t" << src_key << " = {" << "\n"
402 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
403 << "\t\t\t" << "name = \"" << name << "\";" << "\n"
404 << "\t\t\t" << "path = \"" << file << "\";" << "\n"
405 << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n";
406 if (ideType() == MAC_XCODE) {
407 QString filetype;
408 for(QStringList::Iterator cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) {
409 if(file.endsWith((*cppit))) {
410 filetype = "sourcecode.cpp.cpp";
411 break;
153 } 412 }
154 last_grp = new_grp;
155 } 413 }
156 groups[last_grp] += src_key; 414 if(!filetype.isNull())
157 in_root = FALSE; 415 t << "\t\t\t" << "lastKnownFileType = " << filetype << ";" << "\n";
416 }
417 t << "\t\t" << "};" << "\n";
418 if(buildable) { //build reference
419 QString obj_key = file + ".o";
420 obj_key = keyFor(obj_key);
421 t << "\t\t" << obj_key << " = {" << "\n"
422 << "\t\t\t" << "fileRef = " << src_key << ";" << "\n"
423 << "\t\t\t" << "isa = PBXBuildFile;" << "\n"
424 << "\t\t\t" << "settings = {" << "\n"
425 << "\t\t\t\t" << "ATTRIBUTES = (" << "\n"
426 << "\t\t\t\t" << ");" << "\n"
427 << "\t\t\t" << "};" << "\n"
428 << "\t\t" << "};" << "\n";
429 project->variables()["QMAKE_PBX_OBJ"].append(obj_key);
158 } 430 }
159 } 431 }
160 if(in_root)
161 src_list.append(src_key);
162 //source reference
163 t << "\t\t" << src_key << " = {" << "\n"
164 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
165 << "\t\t\t" << "path = \"" << file << "\";" << "\n"
166 << "\t\t\t" << "refType = " << reftypeForFile(file) << ";" << "\n"
167 << "\t\t" << "};" << "\n";
168 //build reference
169 QString obj_key = file + ".o";
170 obj_key = keyFor(obj_key);
171 t << "\t\t" << obj_key << " = {" << "\n"
172 << "\t\t\t" << "fileRef = " << src_key << ";" << "\n"
173 << "\t\t\t" << "isa = PBXBuildFile;" << "\n"
174 << "\t\t\t" << "settings = {" << "\n"
175 << "\t\t\t\t" << "ATTRIBUTES = (" << "\n"
176 << "\t\t\t\t" << ");" << "\n"
177 << "\t\t\t" << "};" << "\n"
178 << "\t\t" << "};" << "\n";
179 project->variables()["QMAKE_PBX_OBJ"].append(obj_key);
180 } 432 }
181 if(!src_list.isEmpty()) { 433 if(!src_list.isEmpty()) {
182 QString grp;
183 if(srcs[i] == "SOURCES") { 434 if(srcs[i] == "SOURCES") {
184 if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon 435 if(project->first("TEMPLATE") == "app" && !project->isEmpty("RC_FILE")) { //Icon
185 QString icns_file = keyFor("ICNS_FILE"); 436 QString icns_file = keyFor("ICNS_FILE");
@@ -196,26 +447,15 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
196 << "\t\t\t" << "};" << "\n" 447 << "\t\t\t" << "};" << "\n"
197 << "\t\t" << "};" << "\n"; 448 << "\t\t" << "};" << "\n";
198 } 449 }
199 grp = "Sources";
200 } else if(srcs[i] == "SRCMOC") {
201 grp = "Mocables";
202 } else if(srcs[i] == "UICIMPLS") {
203 grp = "UICables";
204 } 450 }
205 QString grp_key = keyFor(grp); 451
206 project->variables()["QMAKE_PBX_GROUPS"].append(grp_key); 452 QString src_group_key = keyFor(src_group);
207 t << "\t\t" << grp_key << " = {" << "\n" 453 if(root_group_list.findIndex(src_group_key) == -1)
208 << "\t\t\t" << "children = (" << "\n" 454 root_group_list += src_group_key;
209 << varGlue("QMAKE_PBX_" + srcs[i], "\t\t\t\t", ",\n\t\t\t\t", "\n") 455 groups[src_group] += src_list;
210 << "\t\t\t" << ");" << "\n"
211 << "\t\t\t" << "isa = PBXGroup;" << "\n"
212 << "\t\t\t" << "name = " << grp << ";" << "\n"
213 << "\t\t\t" << "refType = 4;" << "\n"
214 << "\t\t" << "};" << "\n";
215 } 456 }
216 } 457 }
217 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); 458 for(QMap<QString, QStringList>::Iterator grp_it = groups.begin(); grp_it != groups.end(); ++grp_it) {
218 grp_it != groups.end(); ++grp_it) {
219 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n" 459 t << "\t\t" << keyFor(grp_it.key()) << " = {" << "\n"
220 << "\t\t\t" << "isa = PBXGroup;" << "\n" 460 << "\t\t\t" << "isa = PBXGroup;" << "\n"
221 << "\t\t\t" << "children = (" << "\n" 461 << "\t\t\t" << "children = (" << "\n"
@@ -236,8 +476,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
236 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1()); 476 debug_msg(1, "pbuilder: Creating file: %s", mkfile.latin1());
237 QTextStream mkt(&mkf); 477 QTextStream mkt(&mkf);
238 writeHeader(mkt); 478 writeHeader(mkt);
239 mkt << "MOC = " << var("QMAKE_MOC") << endl; 479 mkt << "MOC = " << Option::fixPathToTargetOS(var("QMAKE_MOC")) << endl;
240 mkt << "UIC = " << var("QMAKE_UIC") << endl; 480 mkt << "UIC = " << Option::fixPathToTargetOS(var("QMAKE_UIC")) << endl;
241 mkt << "LEX = " << var("QMAKE_LEX") << endl; 481 mkt << "LEX = " << var("QMAKE_LEX") << endl;
242 mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl; 482 mkt << "LEXFLAGS = " << var("QMAKE_LEXFLAGS") << endl;
243 mkt << "YACC = " << var("QMAKE_YACC") << endl; 483 mkt << "YACC = " << var("QMAKE_YACC") << endl;
@@ -245,6 +485,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
245 mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; 485 mkt << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl;
246 mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl; 486 mkt << "MOVE = " << var("QMAKE_MOVE") << endl << endl;
247 mkt << "FORMS = " << varList("UICIMPLS") << endl; 487 mkt << "FORMS = " << varList("UICIMPLS") << endl;
488 mkt << "IMAGES = " << varList("QMAKE_IMAGE_COLLECTION") << endl;
248 mkt << "MOCS = " << varList("SRCMOC") << endl; 489 mkt << "MOCS = " << varList("SRCMOC") << endl;
249 mkt << "PARSERS ="; 490 mkt << "PARSERS =";
250 if(!project->isEmpty("YACCSOURCES")) { 491 if(!project->isEmpty("YACCSOURCES")) {
@@ -264,14 +505,16 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
264 } 505 }
265 } 506 }
266 mkt << "\n"; 507 mkt << "\n";
267 mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS)" << endl; 508 mkt << "preprocess: $(FORMS) $(MOCS) $(PARSERS) $(IMAGES)" << endl;
268 mkt << "preprocess_clean: mocclean uiclean parser_clean" << endl << endl; 509 mkt << "clean preprocess_clean: mocclean uiclean parser_clean" << endl << endl;
269 mkt << "mocclean:" << "\n"; 510 mkt << "mocclean:" << "\n";
270 if(!project->isEmpty("SRCMOC")) 511 if(!project->isEmpty("SRCMOC"))
271 mkt << "\t-rm -f $(MOCS)" << "\n"; 512 mkt << "\t-rm -f $(MOCS)" << "\n";
272 mkt << "uiclean:" << "\n"; 513 mkt << "uiclean:" << "\n";
273 if(!project->isEmpty("UICIMPLS")) 514 if(!project->isEmpty("UICIMPLS"))
274 mkt << "\t-rm -f $(FORMS)" << "\n"; 515 mkt << "\t-rm -f $(FORMS)" << "\n";
516 if(!project->isEmpty("QMAKE_IMAGE_COLLECTION"))
517 mkt << "\t-rm -f $(IMAGES)" << "\n";
275 mkt << "parser_clean:" << "\n"; 518 mkt << "parser_clean:" << "\n";
276 if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES")) 519 if(!project->isEmpty("YACCSOURCES") || !project->isEmpty("LEXSOURCES"))
277 mkt << "\t-rm -f $(PARSERS)" << "\n"; 520 mkt << "\t-rm -f $(PARSERS)" << "\n";
@@ -281,36 +524,31 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
281 writeMocSrc(mkt, "UICDECLS"); 524 writeMocSrc(mkt, "UICDECLS");
282 writeYaccSrc(mkt, "YACCSOURCES"); 525 writeYaccSrc(mkt, "YACCSOURCES");
283 writeLexSrc(mkt, "LEXSOURCES"); 526 writeLexSrc(mkt, "LEXSOURCES");
527 writeImageSrc(mkt, "QMAKE_IMAGE_COLLECTION");
284 mkf.close(); 528 mkf.close();
285 } 529 }
286 QString target_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");
287 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 530 mkfile = fileFixify(mkfile, QDir::currentDirPath());
288 t << "\t\t" << target_key << " = {" << "\n" 531 QString phase_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET");
289 << "\t\t\t" << "buildArgumentsString = \"-f " << mkfile << "\";" << "\n" 532 //project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
290 << "\t\t\t" << "buildPhases = (" << "\n" 533 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
534 t << "\t\t" << phase_key << " = {" << "\n"
535 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
536 << "\t\t\t" << "files = (" << "\n"
291 << "\t\t\t" << ");" << "\n" 537 << "\t\t\t" << ");" << "\n"
292 << "\t\t\t" << "buildSettings = {" << "\n" 538 << "\t\t\t" << "generatedFileNames = (" << "\n"
293 << "\t\t\t" << "};" << "\n" 539 << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n")
294 << "\t\t\t" << "buildToolPath = \"/usr/bin/gnumake\";"<< "\n"
295 << "\t\t\t" << "buildWorkingDirectory = \"" << QDir::currentDirPath() << "\";" << "\n"
296 << "\t\t\t" << "dependencies = (" << "\n"
297 << "\t\t\t" << ");" << "\n" 540 << "\t\t\t" << ");" << "\n"
298 << "\t\t\t" << "isa = PBXLegacyTarget;" << "\n" 541 << "\t\t\t" << "isa = PBXShellScriptBuildPhase;" << "\n"
299 << "\t\t\t" << "name = QtPreprocessors;" << "\n" 542 << "\t\t\t" << "name = \"Qt Preprocessors\";" << "\n"
300 << "\t\t\t" << "productName = QtPreprocessors;" << "\n" 543 << "\t\t\t" << "neededFileNames = (" << "\n"
301 << "\t\t\t" << "settingsToExpand = 6;" << "\n" 544 << varGlue("QMAKE_PBX_OBJ", "\t\t\t\t", ",\n\t\t\t\t", "\n")
302 << "\t\t\t" << "settingsToPassInEnvironment = 287;" << "\n" 545 << "\t\t\t" << ");" << "\n"
303 << "\t\t\t" << "settingsToPassOnCommandLine = 280;" << "\n" 546 << "\t\t\t" << "shellPath = /bin/sh;" << "\n"
304 << "\t\t\t" << "shouldsUseHeadermap = 0;" << "\n" 547 << "\t\t\t" << "shellScript = \"make -C " << QDir::currentDirPath() <<
548 " -f " << mkfile << "\";" << "\n"
305 << "\t\t" << "};" << "\n"; 549 << "\t\t" << "};" << "\n";
550 }
306 551
307 QString target_depend_key = keyFor("QMAKE_PBX_PREPROCESS_TARGET_DEPEND");
308 project->variables()["QMAKE_PBX_TARGETDEPENDS"].append(target_depend_key);
309 t << "\t\t" << target_depend_key << " = {" << "\n"
310 << "\t\t\t" << "isa = PBXTargetDependency;" << "\n"
311 << "\t\t\t" << "target = " << target_key << ";" << "\n"
312 << "\t\t" << "};" << "\n";
313 }
314 //SOURCE BUILDPHASE 552 //SOURCE BUILDPHASE
315 if(!project->isEmpty("QMAKE_PBX_OBJ")) { 553 if(!project->isEmpty("QMAKE_PBX_OBJ")) {
316 QString grp = "Build Sources", key = keyFor(grp); 554 QString grp = "Build Sources", key = keyFor(grp);
@@ -327,40 +565,44 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
327 565
328 if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES 566 if(!project->isActiveConfig("staticlib")) { //DUMP LIBRARIES
329 QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"]; 567 QStringList &libdirs = project->variables()["QMAKE_PBX_LIBPATHS"];
330 QString libs[] = { "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null }; 568 QString libs[] = { "QMAKE_LFLAGS", "QMAKE_LIBDIR_FLAGS", "QMAKE_LIBS", QString::null };
331 for(i = 0; !libs[i].isNull(); i++) { 569 for(i = 0; !libs[i].isNull(); i++) {
332 tmp = project->variables()[libs[i]]; 570 tmp = project->variables()[libs[i]];
333 for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) { 571 for(QStringList::Iterator it = tmp.begin(); it != tmp.end();) {
334 bool remove = FALSE; 572 bool remove = FALSE;
335 QString library, name, opt = (*it).stripWhiteSpace(); 573 QString library, name, opt = (*it).stripWhiteSpace();
574 if(opt.length() >= 2 && (opt[0] == '"' || opt[0] == '\'') && opt[(int) opt.length()-1] == opt[0])
575 opt = opt.mid(1, opt.length()-2);
336 if(opt.startsWith("-L")) { 576 if(opt.startsWith("-L")) {
337 QString r = opt.right(opt.length() - 2); 577 QString r = opt.right(opt.length() - 2);
338 fixEnvVariables(r); 578 fixEnvVariables(r);
339 libdirs.append(r); 579 libdirs.append(r);
580 } else if(opt == "-prebind") {
581 project->variables()["QMAKE_DO_PREBINDING"].append("TRUE");
582 remove = TRUE;
340 } else if(opt.startsWith("-l")) { 583 } else if(opt.startsWith("-l")) {
341 name = opt.right(opt.length() - 2); 584 name = opt.right(opt.length() - 2);
342 QString lib("lib" + name); 585 QString lib("lib" + name);
343 for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) { 586 for(QStringList::Iterator lit = libdirs.begin(); lit != libdirs.end(); ++lit) {
344 if(project->isActiveConfig("link_prl")) { 587 if(project->isActiveConfig("link_prl")) {
345 /* This isn't real nice, but it is real useful. This looks in a prl 588 /* This isn't real nice, but it is real usefull. This looks in a prl
346 for what the library will ultimately be called so we can stick it 589 for what the library will ultimately be called so we can stick it
347 in the ProjectFile. If the prl format ever changes (not likely) then 590 in the ProjectFile. If the prl format ever changes (not likely) then
348 this will not really work. However, more concerning is that it will 591 this will not really work. However, more concerning is that it will
349 encode the version number in the Project file which might be a bad 592 encode the version number in the Project file which might be a bad
350 things in days to come? --Sam 593 things in days to come? --Sam
351 */ 594 */
352 QString prl_file = (*lit) + Option::dir_sep + lib + Option::prl_ext; 595 QString lib_file = (*lit) + Option::dir_sep + lib;
353 if(QFile::exists(prl_file)) { 596 if(QMakeMetaInfo::libExists(lib_file)) {
354 QMakeProject proj; 597 QMakeMetaInfo libinfo;
355 if(proj.read(prl_file, QDir::currentDirPath())) { 598 if(libinfo.readLib(lib_file)) {
356 if(!proj.isEmpty("QMAKE_PRL_TARGET")) { 599 if(!libinfo.isEmpty("QMAKE_PRL_TARGET")) {
357 library = (*lit) + Option::dir_sep + proj.first("QMAKE_PRL_TARGET"); 600 library = (*lit) + Option::dir_sep + libinfo.first("QMAKE_PRL_TARGET");
358 debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)", 601 debug_msg(1, "pbuilder: Found library (%s) via PRL %s (%s)",
359 opt.latin1(), prl_file.latin1(), library.latin1()); 602 opt.latin1(), lib_file.latin1(), library.latin1());
360 remove = TRUE; 603 remove = TRUE;
361 } 604 }
362 } 605 }
363
364 } 606 }
365 } 607 }
366 if(!remove) { 608 if(!remove) {
@@ -392,6 +634,8 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
392 break; 634 break;
393 } 635 }
394 } 636 }
637 } else if(opt == "-undefined") {
638 ++it; //the next option is not a library..
395 } else if(opt.left(1) != "-") { 639 } else if(opt.left(1) != "-") {
396 remove = TRUE; 640 remove = TRUE;
397 library = opt; 641 library = opt;
@@ -453,7 +697,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
453 } 697 }
454 QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE"); 698 QString phase_key = keyFor("QMAKE_PBX_SUBLIBS_BUILDPHASE");
455 mkfile = fileFixify(mkfile, QDir::currentDirPath()); 699 mkfile = fileFixify(mkfile, QDir::currentDirPath());
456 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 700 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].append(phase_key);
457 t << "\t\t" << phase_key << " = {" << "\n" 701 t << "\t\t" << phase_key << " = {" << "\n"
458 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n" 702 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
459 << "\t\t\t" << "files = (" << "\n" 703 << "\t\t\t" << "files = (" << "\n"
@@ -498,8 +742,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
498 << "\t\t\t" << "name = \"" << grp << "\";" << "\n" 742 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
499 << "\t\t" << "};" << "\n"; 743 << "\t\t" << "};" << "\n";
500 } 744 }
501 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console") && 745 if(!project->isActiveConfig("console") && project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES
502 project->first("TEMPLATE") == "app") { //BUNDLE RESOURCES
503 QString grp("Bundle Resources"), key = keyFor(grp); 746 QString grp("Bundle Resources"), key = keyFor(grp);
504 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key); 747 project->variables()["QMAKE_PBX_BUILDPHASES"].append(key);
505 t << "\t\t" << key << " = {" << "\n" 748 t << "\t\t" << key << " = {" << "\n"
@@ -511,21 +754,6 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
511 << "\t\t\t" << "name = \"" << grp << "\";" << "\n" 754 << "\t\t\t" << "name = \"" << grp << "\";" << "\n"
512 << "\t\t" << "};" << "\n"; 755 << "\t\t" << "};" << "\n";
513 } 756 }
514
515 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
516 //PRODUCTS
517 {
518 QString grp("Products"), key = keyFor(grp);
519 project->variables()["QMAKE_PBX_GROUPS"].append(key);
520 t << "\t\t" << key << " = {" << "\n"
521 << "\t\t\t" << "children = (" << "\n"
522 << "\t\t\t\t" << keyFor("QMAKE_PBX_REFERENCE") << "\n"
523 << "\t\t\t" << ");" << "\n"
524 << "\t\t\t" << "isa = PBXGroup;" << "\n"
525 << "\t\t\t" << "name = Products;" << "\n"
526 << "\t\t\t" << "refType = 4;" << "\n"
527 << "\t\t" << "};" << "\n";
528 }
529 { //INSTALL BUILDPHASE (sh script) 757 { //INSTALL BUILDPHASE (sh script)
530 QString targ = project->first("TARGET"); 758 QString targ = project->first("TARGET");
531 if(project->first("TEMPLATE") == "app" || 759 if(project->first("TEMPLATE") == "app" ||
@@ -540,7 +768,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
540 if(project->first("TEMPLATE") == "app") { 768 if(project->first("TEMPLATE") == "app") {
541 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 769 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console"))
542 targ += ".app"; 770 targ += ".app";
543 } else if(!project->isActiveConfig("staticlib") && 771 } else if(!project->isActiveConfig("staticlib") && !project->isActiveConfig("plugin") &&
544 !project->isActiveConfig("frameworklib")) { 772 !project->isActiveConfig("frameworklib")) {
545 QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null }; 773 QString li[] = { "TARGET_", "TARGET_x", "TARGET_x.y", QString::null };
546 for(int n = 0; !li[n].isNull(); n++) { 774 for(int n = 0; !li[n].isNull(); n++) {
@@ -559,7 +787,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
559 QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags; 787 QString targ = project->first("QMAKE_ORIG_TARGET"), cpflags;
560 if(project->first("TEMPLATE") == "app") { 788 if(project->first("TEMPLATE") == "app") {
561 targ = project->first("TARGET"); 789 targ = project->first("TARGET");
562 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 790 if(!project->isActiveConfig("console")) {
563 targ += ".app"; 791 targ += ".app";
564 cpflags += "-r "; 792 cpflags += "-r ";
565 } 793 }
@@ -568,24 +796,26 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
568 targ = project->first("TARGET"); 796 targ = project->first("TARGET");
569 else 797 else
570 targ = project->first("TARGET_"); 798 targ = project->first("TARGET_");
571 int slsh = targ.findRev(Option::dir_sep);
572 if(slsh != -1)
573 targ = targ.right(targ.length() - slsh - 1);
574 } 799 }
575 QTextStream sht(&shf); 800 int slsh = targ.findRev(Option::dir_sep);
801 if(slsh != -1)
802 targ = targ.right(targ.length() - slsh - 1);
803
576 QString dstdir = project->first("DESTDIR"); 804 QString dstdir = project->first("DESTDIR");
577 fixEnvVariables(dstdir); 805 fixEnvVariables(dstdir);
578 806
807 QTextStream sht(&shf);
579 sht << "#!/bin/sh" << endl; 808 sht << "#!/bin/sh" << endl;
580 //copy the actual target 809 //copy the actual target
581 sht << "OUT_TARG=\"" << targ << "\"\n" 810 sht << "OUT_TARG=\"${TARGET_BUILD_DIR}/${FULL_PRODUCT_NAME}\"\n"
582 << "[ -z \"$BUILD_ROOT\" ] || OUT_TARG=\"${BUILD_ROOT}/${OUT_TARG}\"" << endl; 811 << "if [ -e \"$OUT_TARG\" ]; then" << "\n"
583 sht << "[ \"$OUT_TARG\" = \"" 812 << " [ \"$OUT_TARG\" = \""
584 << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || " 813 << (dstdir.isEmpty() ? QDir::currentDirPath() + QDir::separator(): dstdir) << targ << "\" ] || "
585 << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || " 814 << "[ \"$OUT_TARG\" = \"" << targ << "\" ] || "
586 << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << endl; 815 << "cp -r \"$OUT_TARG\" " << "\"" << dstdir << targ << "\"" << "\n"
816 << "fi" << endl;
587 //rename as a framework 817 //rename as a framework
588 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib")) 818 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("frameworklib") && !project->isActiveConfig("plugin"))
589 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl; 819 sht << "ln -sf \"" << targ << "\" " << "\"" << dstdir << targ << "\"" << endl;
590 //create all the version symlinks (just to be like unixmake) 820 //create all the version symlinks (just to be like unixmake)
591 for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) { 821 for(QStringList::Iterator it = links.begin(); it != links.end(); ++it) {
@@ -600,7 +830,7 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
600 script = fileFixify(script, QDir::currentDirPath()); 830 script = fileFixify(script, QDir::currentDirPath());
601 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key); 831 project->variables()["QMAKE_PBX_BUILDPHASES"].append(phase_key);
602 t << "\t\t" << phase_key << " = {" << "\n" 832 t << "\t\t" << phase_key << " = {" << "\n"
603 << "\t\t\t" << "buildActionMask = 8;" << "\n" //only on install! 833 << "\t\t\t" << "buildActionMask = 2147483647;" << "\n"
604 << "\t\t\t" << "files = (" << "\n" 834 << "\t\t\t" << "files = (" << "\n"
605 << "\t\t\t" << ");" << "\n" 835 << "\t\t\t" << ");" << "\n"
606 << "\t\t\t" << "generatedFileNames = (" << "\n" 836 << "\t\t\t" << "generatedFileNames = (" << "\n"
@@ -614,6 +844,45 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
614 << "\t\t" << "};" << "\n"; 844 << "\t\t" << "};" << "\n";
615 } 845 }
616 } 846 }
847 if(/*ideType() == MAC_XCODE &&*/ !project->isEmpty("QMAKE_PBX_PRESCRIPT_BUILDPHASES") && 0) {
848 // build reference
849 t << "\t\t" << keyFor("QMAKE_PBX_PRESCRIPT_BUILDREFERENCE") << " = {" << "\n"
850 << "\t\t\t" << "includeInIndex = 0;" << "\n"
851 << "\t\t\t" << "isa = PBXFileReference;" << "\n"
852 << "\t\t\t" << "path = preprocessor.out;" << "\n"
853 << "\t\t\t" << "refType = 3;" << "\n"
854 << "\t\t\t" << "sourceTree = BUILT_PRODUCTS_DIR;" << "\n"
855 << "\t\t" << "};" << "\n";
856 project->variables()["QMAKE_PBX_PRODUCTS"].append(keyFor("QMAKE_PBX_PRESCRIPTS_BUILDREFERENCE"));
857 //build phase
858 QString prescript_key = keyFor("QMAKE_PBX_PRESCRIPTS_BUILDPHASE");
859 project->variables()["QMAKE_PBX_TARGETS"].append(prescript_key);
860 t << "\t\t" << prescript_key << " = {" << "\n"
861 << "\t\t\t" << "buildPhases = (" << "\n"
862 << varGlue("QMAKE_PBX_PRESCRIPT_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
863 << "\t\t\t" << ");" << "\n"
864 << "\t\t\t" << "buildRules = (" << "\n"
865 << "\t\t\t" << ");" << "\n"
866 << "\t\t\t" << "buildSettings = {" << "\n"
867 << "\t\t\t" << "};" << "\n"
868 << "\t\t\t" << "dependencies = (" << "\n"
869 << "\t\t\t" << ");" << "\n"
870 << "\t\t\t" << "isa = PBXNativeTarget;" << "\n"
871 << "\t\t\t" << "name = \"Qt Preprocessor Steps\";" << "\n"
872 << "\t\t\t" << "productName = \"Qt Preprocessor Steps\";" << "\n"
873 << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_PRESCRIPTS_BUILDREFERENCE") << ";" << "\n"
874 << "\t\t\t" << "productType = \"com.apple.product-type.tool\";" << "\n"
875 << "\t\t" << "};" << "\n";
876 //dependency
877 t << "\t\t" << keyFor("QMAKE_PBX_PRESCRIPTS_DEPENDENCY") << " = {" << "\n"
878 << "\t\t\t" << "isa = PBXTargetDependency;" << "\n"
879 << "\t\t\t" << "target = " << keyFor("QMAKE_PBX_PRESCRIPTS_BUILDPHASE") << ";" << "\n"
880 << "\t\t" << "};" << "\n";
881 project->variables()["QMAKE_PBX_TARGET_DEPENDS"].append(keyFor("QMAKE_PBX_PRESCRIPTS_DEPENDENCY"));
882 project->variables()["QMAKE_PBX_PRESCRIPT_BUILDPHASES"].clear(); //these are already consumed above
883 }
884
885 //DUMP EVERYTHING THAT TIES THE ABOVE TOGETHER
617 //ROOT_GROUP 886 //ROOT_GROUP
618 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n" 887 t << "\t\t" << keyFor("QMAKE_PBX_ROOT_GROUP") << " = {" << "\n"
619 << "\t\t\t" << "children = (" << "\n" 888 << "\t\t\t" << "children = (" << "\n"
@@ -625,7 +894,9 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
625 << "\t\t\t" << "refType = 4;" << "\n" 894 << "\t\t\t" << "refType = 4;" << "\n"
626 << "\t\t" << "};" << "\n"; 895 << "\t\t" << "};" << "\n";
627 //REFERENCE 896 //REFERENCE
628 t << "\t\t" << keyFor("QMAKE_PBX_REFERENCE") << " = {" << "\n"; 897 project->variables()["QMAKE_PBX_PRODUCTS"].append(keyFor(pbx_dir + "QMAKE_PBX_REFERENCE"));
898 t << "\t\t" << keyFor(pbx_dir + "QMAKE_PBX_REFERENCE") << " = {" << "\n"
899 << "\t\t\t" << "fallbackIsa = PBXFileReference;" << "\n";
629 if(project->first("TEMPLATE") == "app") { 900 if(project->first("TEMPLATE") == "app") {
630 QString targ = project->first("QMAKE_ORIG_TARGET"); 901 QString targ = project->first("QMAKE_ORIG_TARGET");
631 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 902 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) {
@@ -653,31 +924,80 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
653 if(slsh != -1) 924 if(slsh != -1)
654 lib = lib.right(lib.length() - slsh - 1); 925 lib = lib.right(lib.length() - slsh - 1);
655 t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n" 926 t << "\t\t\t" << "isa = PBXLibraryReference;" << "\n"
927 << "\t\t\t" << "expectedFileType = \"compiled.mach-o.dylib\";" << "\n"
656 << "\t\t\t" << "path = " << lib << ";\n" 928 << "\t\t\t" << "path = " << lib << ";\n"
657 << "\t\t\t" << "refType = " << reftypeForFile(lib) << ";" << "\n"; 929 << "\t\t\t" << "refType = " << 3/*reftypeForFile(lib)*/ << ";" << "\n"
930 << "\t\t\t" << "sourceTree = BUILT_PRODUCTS_DIR" << ";" << "\n";
658 } 931 }
659 t << "\t\t" << "};" << "\n"; 932 t << "\t\t" << "};" << "\n";
933 { //Products group
934 QString grp("Products"), key = keyFor(grp);
935 project->variables()["QMAKE_PBX_GROUPS"].append(key);
936 t << "\t\t" << key << " = {" << "\n"
937 << "\t\t\t" << "children = (" << "\n"
938 << varGlue("QMAKE_PBX_PRODUCTS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
939 << "\t\t\t" << ");" << "\n"
940 << "\t\t\t" << "isa = PBXGroup;" << "\n"
941 << "\t\t\t" << "name = Products;" << "\n"
942 << "\t\t\t" << "refType = 4;" << "\n"
943 << "\t\t" << "};" << "\n";
944 }
660 //TARGET 945 //TARGET
661 t << "\t\t" << keyFor("QMAKE_PBX_TARGET") << " = {" << "\n" 946 QString target_key = keyFor("QMAKE_PBX_TARGET");
947 project->variables()["QMAKE_PBX_TARGETS"].append(target_key);
948 t << "\t\t" << target_key << " = {" << "\n"
662 << "\t\t\t" << "buildPhases = (" << "\n" 949 << "\t\t\t" << "buildPhases = (" << "\n"
950 << varGlue("QMAKE_PBX_PRESCRIPT_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", ",\n")
663 << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n") 951 << varGlue("QMAKE_PBX_BUILDPHASES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
664 << "\t\t\t" << ");" << "\n" 952 << "\t\t\t" << ");" << "\n"
665 << "\t\t\t" << "buildSettings = {" << "\n" 953 << "\t\t\t" << "buildSettings = {" << "\n"
954 << "\t\t\t\t" << "CC = \"" << fixEnvsList("QMAKE_CC") << "\";" << "\n"
955 << "\t\t\t\t" << "CPLUSPLUS = \"" << fixEnvsList("QMAKE_CXX") << "\";" << "\n"
666 << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n" 956 << "\t\t\t\t" << "FRAMEWORK_SEARCH_PATHS = \"\";" << "\n"
667 << "\t\t\t\t" << "HEADER_SEARCH_PATHS = \"" << fixEnvsList("INCLUDEPATH") << " " << fixEnvs(specdir()) << "\";" << "\n" 957 << "\t\t\t\t" << "HEADER_SEARCH_PATHS = \"" << fixEnvsList("INCLUDEPATH") << " " << fixEnvs(specdir()) << "\";" << "\n"
668 << "\t\t\t\t" << "LIBRARY_SEARCH_PATHS = \"" << var("QMAKE_PBX_LIBPATHS") << "\";" << "\n" 958 << "\t\t\t\t" << "LIBRARY_SEARCH_PATHS = \"" << var("QMAKE_PBX_LIBPATHS") << "\";" << "\n"
669 << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n" 959 << "\t\t\t\t" << "OPTIMIZATION_CFLAGS = \"\";" << "\n"
670 << "\t\t\t\t" << "OTHER_CFLAGS = \"" << 960 << "\t\t\t\t" << "OTHER_CFLAGS = \"" <<
671 fixEnvsList("QMAKE_CFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << 961 fixEnvsList("QMAKE_CFLAGS") << fixQuotes(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","")) <<
672 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" 962 fixQuotes(varGlue("DEFINES"," -D"," -D","")) << "\";" << "\n"
673 << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n" 963 << "\t\t\t\t" << "LEXFLAGS = \"" << var("QMAKE_LEXFLAGS") << "\";" << "\n"
674 << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n" 964 << "\t\t\t\t" << "YACCFLAGS = \"" << var("QMAKE_YACCFLAGS") << "\";" << "\n"
675 << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" << 965 << "\t\t\t\t" << "OTHER_CPLUSPLUSFLAGS = \"" <<
676 fixEnvsList("QMAKE_CXXFLAGS") << varGlue("PRL_EXPORT_DEFINES"," -D"," -D","") << 966 fixEnvsList("QMAKE_CXXFLAGS") << fixQuotes(varGlue("PRL_EXPORT_DEFINES"," -D"," -D","")) <<
677 varGlue("DEFINES"," -D"," -D","") << "\";" << "\n" 967 fixQuotes(varGlue("DEFINES"," -D"," -D","")) << "\";" << "\n"
678 << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n" 968 << "\t\t\t\t" << "OTHER_REZFLAGS = \"\";" << "\n"
679 << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n" 969 << "\t\t\t\t" << "SECTORDER_FLAGS = \"\";" << "\n"
680 << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n"; 970 << "\t\t\t\t" << "WARNING_CFLAGS = \"\";" << "\n"
971 << "\t\t\t\t" << "PREBINDING = " << (project->isEmpty("QMAKE_DO_PREBINDING") ? "NO" : "YES") << ";" << "\n";
972 if(!project->isEmpty("PRECOMPILED_HEADER")) {
973 if (ideType() == MAC_XCODE) {
974 t << "\t\t\t\t" << "GCC_PRECOMPILE_PREFIX_HEADER = \"YES\";" << "\n"
975 << "\t\t\t\t" << "GCC_PREFIX_HEADER = \"" << project->first("PRECOMPILED_HEADER") << "\";" << "\n";
976 } else {
977 t << "\t\t\t\t" << "PRECOMPILE_PREFIX_HEADER = \"YES\";" << "\n"
978 << "\t\t\t\t" << "PREFIX_HEADER = \"" << project->first("PRECOMPILED_HEADER") << "\";" << "\n";
979 }
980 }
981 if(project->first("TEMPLATE") == "app") {
982 QString plist = fileFixify(project->first("QMAKE_INFO_PLIST"));
983 if(plist.isEmpty())
984 plist = specdir() + QDir::separator() + "Info.plist." + project->first("TEMPLATE");
985 if(QFile::exists(plist)) {
986 QFile plist_in_file(plist);
987 if(plist_in_file.open(IO_ReadOnly)) {
988 QTextStream plist_in(&plist_in_file);
989 QString plist_in_text = plist_in.read();
990 plist_in_text = plist_in_text.replace("@ICON@", (project->isEmpty("RC_FILE") ? QString("") : project->first("RC_FILE").section(Option::dir_sep, -1)));
991 plist_in_text = plist_in_text.replace("@EXECUTABLE@", project->first("QMAKE_ORIG_TARGET"));
992 QFile plist_out_file("Info.plist");
993 if(plist_out_file.open(IO_WriteOnly | IO_Translate)) {
994 QTextStream plist_out(&plist_out_file);
995 plist_out << plist_in_text;
996 t << "\t\t\t\t" << "INFOPLIST_FILE = \"Info.plist\";" << "\n";
997 }
998 }
999 }
1000 }
681#if 1 1001#if 1
682 t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n"; 1002 t << "\t\t\t\t" << "BUILD_ROOT = \"" << QDir::currentDirPath() << "\";" << "\n";
683#endif 1003#endif
@@ -685,104 +1005,166 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
685 t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " << 1005 t << "\t\t\t\t" << "OTHER_LDFLAGS = \"" << fixEnvsList("SUBLIBS") << " " <<
686 fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") << 1006 fixEnvsList("QMAKE_LFLAGS") << " " << fixEnvsList("QMAKE_LIBDIR_FLAGS") <<
687 " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n"; 1007 " " << fixEnvsList("QMAKE_LIBS") << "\";" << "\n";
1008 if(!project->isEmpty("DESTDIR")) {
1009 QString dir = project->first("DESTDIR");
1010 if (QDir::isRelativePath(dir))
1011 dir.prepend(QDir::currentDirPath() + Option::dir_sep);
1012 t << "\t\t\t\t" << "INSTALL_DIR = \"" << dir << "\";" << "\n";
1013 }
1014 if ( project->first("TEMPLATE") == "lib") {
1015 t << "\t\t\t\t" << "INSTALL_PATH = \"" << "\";" << "\n";
1016 }
1017 if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0") {
1018 t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VER_MAJ") << "."
1019 << project->first("VER_MIN") << "." << project->first("VER_PAT") << "\";" << "\n";
1020 if(project->isEmpty("COMPAT_VERSION"))
1021 t << "\t\t\t\t" << "DYLIB_COMPATIBILITY_VERSION = \"" << project->first("VER_MAJ") << "."
1022 << project->first("VER_MIN") << "\";" << "\n";
1023 }
1024 if(!project->isEmpty("COMPAT_VERSION"))
1025 t << "\t\t\t\t" << "DYLIB_COMPATIBILITY_VERSION = \"" << project->first("COMPAT_VERSION") << "\";" << "\n";
1026
1027 if(ideType() == MAC_XCODE) {
1028 if(!project->isEmpty("OBJECTS_DIR"))
1029 t << "\t\t\t\t" << "OBJROOT = \"" << project->first("OBJECTS_DIR") << "\";" << "\n";
1030 }
1031#if 0
688 if(!project->isEmpty("DESTDIR")) 1032 if(!project->isEmpty("DESTDIR"))
689 t << "\t\t\t\t" << "INSTALL_PATH = \"" << project->first("DESTDIR") << "\";" << "\n"; 1033 t << "\t\t\t\t" << "SYMROOT = \"" << project->first("DESTDIR") << "\";" << "\n";
690 if(!project->isEmpty("VERSION") && project->first("VERSION") != "0.0.0") 1034 else
691 t << "\t\t\t\t" << "DYLIB_CURRENT_VERSION = \"" << project->first("VERSION") << "\";" << "\n"; 1035 t << "\t\t\t\t" << "SYMROOT = \"" << QDir::currentDirPath() << "\";" << "\n";
692 if(!project->isEmpty("OBJECTS_DIR")) 1036#endif
693 t << "\t\t\t\t" << "OBJECT_FILE_DIR = \"" << project->first("OBJECTS_DIR") << "\";" << "\n";
694 if(project->first("TEMPLATE") == "app") { 1037 if(project->first("TEMPLATE") == "app") {
695 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) 1038 if(ideType() == MAC_PBUILDER && !project->isActiveConfig("console"))
696 t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n"; 1039 t << "\t\t\t\t" << "WRAPPER_EXTENSION = app;" << "\n";
697 t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; 1040 t << "\t\t\t\t" << "PRODUCT_NAME = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
698 } else { 1041 } else {
699 QString lib = project->first("QMAKE_ORIG_TARGET");
700 if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) { 1042 if(!project->isActiveConfig("plugin") && project->isActiveConfig("staticlib")) {
701 t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n"; 1043 t << "\t\t\t\t" << "LIBRARY_STYLE = STATIC;" << "\n";
702 lib = project->first("TARGET");
703 } else { 1044 } else {
704 t << "\t\t\t\t" << "LIBRARY_STYLE = DYNAMIC;" << "\n"; 1045 t << "\t\t\t\t" << "LIBRARY_STYLE = DYNAMIC;" << "\n";
705 if(!project->isActiveConfig("frameworklib")) {
706 if(project->isActiveConfig("plugin"))
707 lib = project->first("TARGET");
708 else
709 lib = project->first("TARGET_");
710 }
711 } 1046 }
712 int slsh = lib.findRev(Option::dir_sep); 1047 QString lib = project->first("QMAKE_ORIG_TARGET");
713 if(slsh != -1) 1048 if (!project->isActiveConfig("frameworklib") && !project->isActiveConfig("staticlib"))
714 lib = lib.right(lib.length() - slsh - 1); 1049 lib.prepend("lib");
715 t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n"; 1050 t << "\t\t\t\t" << "PRODUCT_NAME = " << lib << ";" << "\n";
716 } 1051 }
717 tmp = project->variables()["QMAKE_PBX_VARS"]; 1052 tmp = project->variables()["QMAKE_PBX_VARS"];
718 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) 1053 for(QStringList::Iterator it = tmp.begin(); it != tmp.end(); ++it) {
719 t << "\t\t\t\t" << (*it) << " = \"" << getenv((*it)) << "\";" << "\n"; 1054 QString var = (*it), val = getenv(var);
1055 if(!val && var == "TB")
1056 val = "/usr/bin/";
1057 t << "\t\t\t\t" << var << " = \"" << val << "\";" << "\n";
1058 }
720 t << "\t\t\t" << "};" << "\n" 1059 t << "\t\t\t" << "};" << "\n"
721 << "\t\t\t" << "conditionalBuildSettings = {" << "\n" 1060 << "\t\t\t" << "conditionalBuildSettings = {" << "\n"
722 << "\t\t\t" << "};" << "\n" 1061 << "\t\t\t" << "};" << "\n"
723 << "\t\t\t" << "dependencies = (" << "\n" 1062 << "\t\t\t" << "dependencies = (" << "\n"
724 << varGlue("QMAKE_PBX_TARGETDEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n") 1063 << varGlue("QMAKE_PBX_TARGET_DEPENDS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
725 << "\t\t\t" << ");" << "\n" 1064 << "\t\t\t" << ");" << "\n"
726 << "\t\t\t" << "productReference = " << keyFor("QMAKE_PBX_REFERENCE") << ";" << "\n" 1065 << "\t\t\t" << "productReference = " << keyFor(pbx_dir + "QMAKE_PBX_REFERENCE") << ";" << "\n"
727 << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n"; 1066 << "\t\t\t" << "shouldUseHeadermap = 1;" << "\n";
1067 if(ideType() == MAC_XCODE)
1068 t << "\t\t\t" << "isa = PBXNativeTarget;" << "\n";
728 if(project->first("TEMPLATE") == "app") { 1069 if(project->first("TEMPLATE") == "app") {
729 if(project->isActiveConfig("resource_fork") && !project->isActiveConfig("console")) { 1070 if(project->isActiveConfig("console")) {
730 t << "\t\t\t" << "isa = PBXApplicationTarget;" << "\n" 1071 if(ideType() == MAC_XCODE)
731 << "\t\t\t" << "productSettingsXML = " << "\"" << "<?xml version=" 1072 t << "\t\t\t" << "productType = \"com.apple.product-type.tool\";" << "\n";
732 << "\\\"1.0\\\" encoding=" << "\\\"UTF-8\\\"" << "?>" << "\n" 1073 else
733 << "\t\t\t\t" << "<!DOCTYPE plist SYSTEM \\\"file://localhost/System/" 1074 t << "\t\t\t" << "isa = PBXToolTarget;" << "\n";
734 << "Library/DTDs/PropertyList.dtd\\\">" << "\n"
735 << "\t\t\t\t" << "<plist version=\\\"0.9\\\">" << "\n"
736 << "\t\t\t\t" << "<dict>" << "\n"
737 << "\t\t\t\t\t" << "<key>CFBundleDevelopmentRegion</key>" << "\n"
738 << "\t\t\t\t\t" << "<string>English</string>" << "\n"
739 << "\t\t\t\t\t" << "<key>CFBundleExecutable</key>" << "\n"
740 << "\t\t\t\t\t" << "<string>" << project->first("QMAKE_ORIG_TARGET") << "</string>" << "\n"
741 << "\t\t\t\t\t" << "<key>CFBundleIconFile</key>" << "\n"
742 << "\t\t\t\t\t" << "<string>" << var("RC_FILE").section(Option::dir_sep, -1) << "</string>" << "\n"
743 << "\t\t\t\t\t" << "<key>CFBundleInfoDictionaryVersion</key>" << "\n"
744 << "\t\t\t\t\t" << "<string>6.0</string>" << "\n"
745 << "\t\t\t\t\t" << "<key>CFBundlePackageType</key>" << "\n"
746 << "\t\t\t\t\t" << "<string>APPL</string>" << "\n"
747 << "\t\t\t\t\t" << "<key>CFBundleSignature</key>" << "\n"
748 << "\t\t\t\t\t" << "<string>????</string>" << "\n"
749 << "\t\t\t\t\t" << "<key>CFBundleVersion</key>" << "\n"
750 << "\t\t\t\t\t" << "<string>0.1</string>" << "\n"
751 << "\t\t\t\t\t" << "<key>CSResourcesFileMapped</key>" << "\n"
752 << "\t\t\t\t\t" << "<true/>" << "\n"
753 << "\t\t\t\t" << "</dict>" << "\n"
754 << "\t\t\t\t" << "</plist>" << "\";" << "\n";
755 } else { 1075 } else {
756 t << "\t\t\t" << "isa = PBXToolTarget;" << "\n"; 1076 if(ideType() == MAC_XCODE)
1077 t << "\t\t\t" << "productType = \"com.apple.product-type.application\";" << "\n";
1078 else
1079 t << "\t\t\t" << "isa = PBXApplicationReference;" << "\n";
1080 t << "\t\t\t" << "productSettingsXML = \"";
1081 bool read_plist = false;
1082 if(QFile::exists("Info.plist")) {
1083 QFile plist("Info.plist");
1084 if(plist.open(IO_ReadOnly)) {
1085 read_plist = true;
1086 QTextStream stream(&plist);
1087 while(!stream.eof())
1088 t << stream.readLine().replace('"', "\\\"") << endl;
1089 }
1090 }
1091 if(!read_plist) {
1092 t << "<?xml version="
1093 << "\\\"1.0\\\" encoding=" << "\\\"UTF-8\\\"" << "?>" << "\n"
1094 << "\t\t\t\t" << "<!DOCTYPE plist SYSTEM \\\"file://localhost/System/"
1095 << "Library/DTDs/PropertyList.dtd\\\">" << "\n"
1096 << "\t\t\t\t" << "<plist version=\\\"0.9\\\">" << "\n"
1097 << "\t\t\t\t" << "<dict>" << "\n"
1098 << "\t\t\t\t\t" << "<key>CFBundleDevelopmentRegion</key>" << "\n"
1099 << "\t\t\t\t\t" << "<string>English</string>" << "\n"
1100 << "\t\t\t\t\t" << "<key>CFBundleExecutable</key>" << "\n"
1101 << "\t\t\t\t\t" << "<string>" << project->first("QMAKE_ORIG_TARGET") << "</string>" << "\n"
1102 << "\t\t\t\t\t" << "<key>CFBundleIconFile</key>" << "\n"
1103 << "\t\t\t\t\t" << "<string>" << var("RC_FILE").section(Option::dir_sep, -1) << "</string>" << "\n"
1104 << "\t\t\t\t\t" << "<key>CFBundleInfoDictionaryVersion</key>" << "\n"
1105 << "\t\t\t\t\t" << "<string>6.0</string>" << "\n"
1106 << "\t\t\t\t\t" << "<key>CFBundlePackageType</key>" << "\n"
1107 << "\t\t\t\t\t" << "<string>APPL</string>" << "\n"
1108 << "\t\t\t\t\t" << "<key>CFBundleSignature</key>" << "\n"
1109 //Although the output below looks strange it is to avoid the trigraph ??<
1110 << "\t\t\t\t\t" << "<string>????" << "</string>" << "\n"
1111 << "\t\t\t\t\t" << "<key>CFBundleVersion</key>" << "\n"
1112 << "\t\t\t\t\t" << "<string>0.1</string>" << "\n"
1113 << "\t\t\t\t\t" << "<key>CSResourcesFileMapped</key>" << "\n"
1114 << "\t\t\t\t\t" << "<true/>" << "\n"
1115 << "\t\t\t\t" << "</dict>" << "\n"
1116 << "\t\t\t\t" << "</plist>";
1117 }
757 } 1118 }
1119 t << "\";" << "\n";
758 t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n" 1120 t << "\t\t\t" << "name = \"" << project->first("QMAKE_ORIG_TARGET") << "\";" << "\n"
759 << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n"; 1121 << "\t\t\t" << "productName = " << project->first("QMAKE_ORIG_TARGET") << ";" << "\n";
760 } else { 1122 } else {
761 QString lib = project->first("QMAKE_ORIG_TARGET"); 1123 QString lib = project->first("QMAKE_ORIG_TARGET");
762 if(!project->isActiveConfig("frameworklib")) 1124 if(!project->isActiveConfig("frameworklib") && !project->isActiveConfig("staticlib"))
763 lib.prepend("lib"); 1125 lib.prepend("lib");
764 t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n" 1126 t << "\t\t\t" << "name = \"" << lib << "\";" << "\n"
765 << "\t\t\t" << "name = \"" << lib << "\";" << "\n"
766 << "\t\t\t" << "productName = " << lib << ";" << "\n"; 1127 << "\t\t\t" << "productName = " << lib << ";" << "\n";
1128 if(ideType() == MAC_XCODE) {
1129 if(project->isActiveConfig("staticlib"))
1130 t << "\t\t\t" << "productType = \"com.apple.product-type.library.static\";" << "\n";
1131 else
1132 t << "\t\t\t" << "productType = \"com.apple.product-type.library.dynamic\";" << "\n";
1133 } else {
1134 t << "\t\t\t" << "isa = PBXLibraryTarget;" << "\n";
1135 }
767 } 1136 }
1137 t << "\t\t\t" << "startupPath = \"<<ProjectDirectory>>\";" << "\n";
768 if(!project->isEmpty("DESTDIR")) 1138 if(!project->isEmpty("DESTDIR"))
769 t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n"; 1139 t << "\t\t\t" << "productInstallPath = \"" << project->first("DESTDIR") << "\";" << "\n";
770 t << "\t\t" << "};" << "\n"; 1140 t << "\t\t" << "};" << "\n";
771 //DEBUG/RELEASE 1141 //DEBUG/RELEASE
772 for(i = 0; i < 2; i++) { 1142 QString active_buildstyle;
773 bool as_release = !i; 1143#if 0
774 if(project->isActiveConfig("debug")) 1144 for(int as_release = 0; as_release < 2; as_release++)
775 as_release = i; 1145#else
776 QString key = "QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"); 1146 bool as_release = !project->isActiveConfig("debug");
777 key = keyFor(key); 1147#endif
1148 {
1149 QString key = keyFor("QMAKE_PBX_" + QString(as_release ? "RELEASE" : "DEBUG"));
1150 if(project->isActiveConfig("debug") != as_release)
1151 active_buildstyle = key;
778 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key); 1152 project->variables()["QMAKE_PBX_BUILDSTYLES"].append(key);
779 t << "\t\t" << key << " = {" << "\n" 1153 t << "\t\t" << key << " = {" << "\n"
780 << "\t\t\t" << "buildRules = (" << "\n" 1154 << "\t\t\t" << "buildRules = (" << "\n"
781 << "\t\t\t" << ");" << "\n" 1155 << "\t\t\t" << ");" << "\n"
782 << "\t\t\t" << "buildSettings = {" << "\n" 1156 << "\t\t\t" << "buildSettings = {" << "\n"
783 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n"; 1157 << "\t\t\t\t" << "COPY_PHASE_STRIP = " << (as_release ? "YES" : "NO") << ";" << "\n";
784 if(as_release) 1158 if(as_release) {
785 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n"; 1159 t << "\t\t\t\t" << "DEBUGGING_SYMBOLS = NO;" << "\n";
1160 } else {
1161 t << "\t\t\t\t" << "GCC_ENABLE_FIX_AND_CONTINUE = "
1162 << (project->isActiveConfig("no_fix_and_continue") ? "NO" : "YES") << ";" << "\n"
1163 << "\t\t\t\t" << "GCC_GENERATE_DEBUGGING_SYMBOLS = YES;" << "\n"
1164 << "\t\t\t\t" << "GCC_OPTIMIZATION_LEVEL = 0;" << "\n"
1165 << "\t\t\t\t" << "ZERO_LINK ="
1166 << (project->isActiveConfig("no_zero_link") ? "NO" : "YES") << ";" << "\n";
1167 }
786 t << "\t\t\t" << "};" << "\n" 1168 t << "\t\t\t" << "};" << "\n"
787 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n" 1169 << "\t\t\t" << "isa = PBXBuildStyle;" << "\n"
788 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n" 1170 << "\t\t\t" << "name = " << (as_release ? "Deployment" : "Development") << ";" << "\n"
@@ -793,10 +1175,12 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
793 << "\t\t\t" << "buildStyles = (" << "\n" 1175 << "\t\t\t" << "buildStyles = (" << "\n"
794 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n") 1176 << varGlue("QMAKE_PBX_BUILDSTYLES", "\t\t\t\t", ",\n\t\t\t\t", "\n")
795 << "\t\t\t" << ");" << "\n" 1177 << "\t\t\t" << ");" << "\n"
1178 << "\t\t\t" << "hasScannedForEncodings = 1;" << "\n"
796 << "\t\t\t" << "isa = PBXProject;" << "\n" 1179 << "\t\t\t" << "isa = PBXProject;" << "\n"
797 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n" 1180 << "\t\t\t" << "mainGroup = " << keyFor("QMAKE_PBX_ROOT_GROUP") << ";" << "\n"
1181 << "\t\t\t" << "projectDirPath = \"\";" << "\n"
798 << "\t\t\t" << "targets = (" << "\n" 1182 << "\t\t\t" << "targets = (" << "\n"
799 << "\t\t\t\t" << keyFor("QMAKE_PBX_TARGET") << "\n" 1183 << varGlue("QMAKE_PBX_TARGETS", "\t\t\t\t", ",\n\t\t\t\t", "\n")
800 << "\t\t\t" << ");" << "\n" 1184 << "\t\t\t" << ");" << "\n"
801 << "\t\t" << "};" << "\n"; 1185 << "\t\t" << "};" << "\n";
802 1186
@@ -805,32 +1189,42 @@ ProjectBuilderMakefileGenerator::writeMakeParts(QTextStream &t)
805 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n" 1189 << "\t" << "rootObject = " << keyFor("QMAKE_PBX_ROOT") << ";" << "\n"
806 << "}" << endl; 1190 << "}" << endl;
807 1191
808 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"), 1192 if(project->isActiveConfig("generate_pbxbuild_makefile")) {
809 QDir::currentDirPath()); 1193 QString mkwrap = fileFixify(pbx_dir + Option::dir_sep + ".." + Option::dir_sep + project->first("MAKEFILE"),
810 QFile mkwrapf(mkwrap); 1194 QDir::currentDirPath());
811 if(mkwrapf.open(IO_WriteOnly | IO_Translate)) { 1195 QFile mkwrapf(mkwrap);
812 debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1()); 1196 if(mkwrapf.open(IO_WriteOnly | IO_Translate)) {
813 QTextStream mkwrapt(&mkwrapf); 1197 debug_msg(1, "pbuilder: Creating file: %s", mkwrap.latin1());
814 writeHeader(mkwrapt); 1198 QTextStream mkwrapt(&mkwrapf);
815 const char *cleans = "uiclean mocclean preprocess_clean "; 1199 writeHeader(mkwrapt);
816 mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n" 1200 const char *cleans = "uiclean mocclean preprocess_clean ";
817 << "all:" << "\n\t" 1201 mkwrapt << "#This is a makefile wrapper for PROJECT BUILDER\n"
818 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild") << "\n" 1202 << "all:" << "\n\t"
819 << "install: all" << "\n\t" 1203 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << "\n"
820 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild install") << "\n" 1204 << "install: all" << "\n\t"
821 << "distclean clean: preprocess_clean" << "\n\t" 1205 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " install\n"
822 << "cd " << (project->first("QMAKE_ORIG_TARGET") + ".pbproj/ && pbxbuild clean") << "\n" 1206 << "distclean clean: preprocess_clean" << "\n\t"
823 << (!did_preprocess ? cleans : "") << ":" << "\n"; 1207 << "cd " << project->first("QMAKE_ORIG_TARGET") << projectSuffix() << "/ && " << pbxbuild() << " clean" << "\n"
824 if(did_preprocess) 1208 << (!did_preprocess ? cleans : "") << ":" << "\n";
825 mkwrapt << cleans << ":" << "\n\t" 1209 if(did_preprocess)
826 << "make -f " 1210 mkwrapt << cleans << ":" << "\n\t"
827 << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl; 1211 << "make -f "
1212 << pbx_dir << Option::dir_sep << "qt_preprocess.mak $@" << endl;
1213 }
828 } 1214 }
829 return TRUE; 1215 return TRUE;
830} 1216}
831 1217
832QString 1218QString
833ProjectBuilderMakefileGenerator::fixEnvs(QString file) 1219ProjectBuilderMakefileGenerator::fixQuotes(const QString &val)
1220{
1221 QString ret(val);
1222 ret = ret.replace(QRegExp("('|\")"), "\\\\1");
1223 return ret;
1224}
1225
1226QString
1227ProjectBuilderMakefileGenerator::fixEnvs(const QString &file)
834{ 1228{
835 QRegExp reg_var("\\$\\((.*)\\)"); 1229 QRegExp reg_var("\\$\\((.*)\\)");
836 for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) { 1230 for(int rep = 0; (rep = reg_var.search(file, rep)) != -1; ) {
@@ -842,7 +1236,7 @@ ProjectBuilderMakefileGenerator::fixEnvs(QString file)
842} 1236}
843 1237
844QString 1238QString
845ProjectBuilderMakefileGenerator::fixEnvsList(QString where) 1239ProjectBuilderMakefileGenerator::fixEnvsList(const QString &where)
846{ 1240{
847 QString ret; 1241 QString ret;
848 const QStringList &l = project->variables()[where]; 1242 const QStringList &l = project->variables()[where];
@@ -856,32 +1250,15 @@ ProjectBuilderMakefileGenerator::fixEnvsList(QString where)
856} 1250}
857 1251
858QString 1252QString
859ProjectBuilderMakefileGenerator::keyFor(QString block) 1253ProjectBuilderMakefileGenerator::keyFor(const QString &block)
860{ 1254{
861#if 0 //This make this code much easier to debug.. 1255#if 1 //This make this code much easier to debug..
862 return block; 1256 if(project->isActiveConfig("no_pb_munge_key"))
1257 return block;
863#endif 1258#endif
864
865 QString ret; 1259 QString ret;
866 if(!keys.contains(block)) { 1260 if(!keys.contains(block)) {
867#if 0 1261 ret = qtMD5(block.utf8()).left(24).upper();
868 static unsigned int r = 0;
869 ret.sprintf("%024x", ++r);
870#else //not really necesary, but makes it look more interesting..
871 static struct { unsigned int a1, a2, a3; } r = { 0, 0, 0 };
872 if(!r.a1 && !r.a2 && !r.a3) {
873 r.a1 = rand();
874 r.a2 = rand();
875 r.a3 = rand();
876 }
877 switch(rand() % 3) {
878 case 0: ++r.a1; break;
879 case 1: ++r.a2; break;
880 case 2: ++r.a3; break;
881 }
882 ret.sprintf("%08x%08x%08x", r.a1, r.a2, r.a3);
883#endif
884 ret = ret.upper();
885 keys.insert(block, ret); 1262 keys.insert(block, ret);
886 } else { 1263 } else {
887 ret = keys[block]; 1264 ret = keys[block];
@@ -892,28 +1269,27 @@ ProjectBuilderMakefileGenerator::keyFor(QString block)
892bool 1269bool
893ProjectBuilderMakefileGenerator::openOutput(QFile &file) const 1270ProjectBuilderMakefileGenerator::openOutput(QFile &file) const
894{ 1271{
895 if(project->first("TEMPLATE") != "subdirs") { 1272 if(QDir::isRelativePath(file.name()))
896 QFileInfo fi(file); 1273 file.setName(Option::output_dir + file.name()); //pwd when qmake was run
897 if(fi.extension() != "pbxproj" || file.name().isEmpty()) { 1274 QFileInfo fi(file);
898 QString output = file.name(); 1275 if(fi.extension() != "pbxproj" || file.name().isEmpty()) {
899 if(fi.isDir()) 1276 QString output = file.name();
900 output += QDir::separator(); 1277 if(fi.isDir())
901 if(fi.extension() != "pbproj") { 1278 output += QDir::separator();
902 if(file.name().isEmpty() || fi.isDir()) 1279 if(!output.endsWith(projectSuffix())) {
903 output += project->first("TARGET"); 1280 if(file.name().isEmpty() || fi.isDir())
904 output += QString(".pbproj") + QDir::separator(); 1281 output += project->first("TARGET");
905 } else if(output[(int)output.length() - 1] != QDir::separator()) { 1282 output += projectSuffix() + QDir::separator();
906 output += QDir::separator(); 1283 } else if(output[(int)output.length() - 1] != QDir::separator()) {
907 } 1284 output += QDir::separator();
908 output += QString("project.pbxproj");
909 file.setName(output);
910 } 1285 }
911 bool ret = UnixMakefileGenerator::openOutput(file); 1286 output += QString("project.pbxproj");
912 ((ProjectBuilderMakefileGenerator*)this)->pbx_dir = Option::output_dir.section(Option::dir_sep, 0, -1); 1287 file.setName(output);
913 Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2);
914 return ret;
915 } 1288 }
916 return UnixMakefileGenerator::openOutput(file); 1289 bool ret = UnixMakefileGenerator::openOutput(file);
1290 ((ProjectBuilderMakefileGenerator*)this)->pbx_dir = Option::output_dir.section(Option::dir_sep, 0, -1);
1291 Option::output_dir = pbx_dir.section(Option::dir_sep, 0, -2);
1292 return ret;
917} 1293}
918 1294
919/* This function is such a hack it is almost pointless, but it 1295/* This function is such a hack it is almost pointless, but it
@@ -928,10 +1304,14 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
928 QString ret; 1304 QString ret;
929 if(project->isEmpty("QMAKE_PBUILDER_VERSION")) { 1305 if(project->isEmpty("QMAKE_PBUILDER_VERSION")) {
930 QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST"); 1306 QString version, version_plist = project->first("QMAKE_PBUILDER_VERSION_PLIST");
931 if(version_plist.isEmpty()) 1307 if(version_plist.isEmpty()) {
932 version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist"; 1308 if(ideType() == MAC_XCODE && QFile::exists("/Developer/Applications/Xcode.app/Contents/version.plist"))
933 else 1309 version_plist = "/Developer/Applications/Xcode.app/Contents/version.plist";
1310 else
1311 version_plist = "/Developer/Applications/Project Builder.app/Contents/version.plist";
1312 } else {
934 version_plist = version_plist.replace(QRegExp("\""), ""); 1313 version_plist = version_plist.replace(QRegExp("\""), "");
1314 }
935 QFile version_file(version_plist); 1315 QFile version_file(version_plist);
936 if(version_file.open(IO_ReadOnly)) { 1316 if(version_file.open(IO_ReadOnly)) {
937 debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1()); 1317 debug_msg(1, "pbuilder: version.plist: Reading file: %s", version_plist.latin1());
@@ -954,11 +1334,15 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
954 } 1334 }
955 } 1335 }
956 version_file.close(); 1336 version_file.close();
957 } else debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); 1337 } else { debug_msg(1, "pbuilder: version.plist: Failure to open %s", version_plist.latin1()); }
958 if(version.startsWith("2.0")) 1338 if(version_plist.contains("Xcode")) {
959 ret = "38"; 1339 ret = "39";
960 else if(version == "1.1") 1340 } else {
961 ret = "34"; 1341 if(version.startsWith("2."))
1342 ret = "38";
1343 else if(version == "1.1")
1344 ret = "34";
1345 }
962 } else { 1346 } else {
963 ret = project->first("QMAKE_PBUILDER_VERSION"); 1347 ret = project->first("QMAKE_PBUILDER_VERSION");
964 } 1348 }
@@ -974,10 +1358,39 @@ ProjectBuilderMakefileGenerator::pbuilderVersion() const
974 return 34; //my fallback 1358 return 34; //my fallback
975} 1359}
976 1360
977QString 1361int
978ProjectBuilderMakefileGenerator::reftypeForFile(QString where) 1362ProjectBuilderMakefileGenerator::reftypeForFile(const QString &where)
979{ 1363{
1364 int ret = 0; //absolute is the default..
980 if(QDir::isRelativePath(where)) 1365 if(QDir::isRelativePath(where))
981 return "4"; //relative 1366 ret = 4; //relative
982 return "0"; //absolute 1367 return ret;
1368}
1369
1370ProjectBuilderMakefileGenerator::IDE_TYPE
1371ProjectBuilderMakefileGenerator::ideType() const
1372{
1373 if(!project->isActiveConfig("no_pbx_xcode") &&
1374 (QFile::exists("/Developer/Applications/Xcode.app") || project->isActiveConfig("pbx_xcode")))
1375 return ProjectBuilderMakefileGenerator::MAC_XCODE;
1376 return ProjectBuilderMakefileGenerator::MAC_PBUILDER;
1377}
1378
1379QString
1380ProjectBuilderMakefileGenerator::projectSuffix() const
1381{
1382 if(ideType() == MAC_XCODE)
1383 return ".xcode";
1384 return ".pbproj";
1385}
1386
1387QString
1388ProjectBuilderMakefileGenerator::pbxbuild()
1389{
1390 if(QFile::exists("/usr/bin/pbbuild"))
1391 return "pbbuild";
1392 if(QFile::exists("/usr/bin/xcodebuild"))
1393 return "xcodebuild";
1394 return (ideType() == MAC_XCODE ? "xcodebuild" : "pbxbuild");
983} 1395}
1396