Changeset 39 for trunk/qmake/generators/os2/gnumake.cpp
- Timestamp:
- Jun 20, 2009, 1:36:57 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/qmake/generators/os2/gnumake.cpp
r35 r39 54 54 GNUMakefileGenerator::GNUMakefileGenerator() : Win32MakefileGenerator(), init_flag(false) 55 55 { 56 if ( Option::shellPath.isEmpty())56 if (isDosLikeShell()) 57 57 quote = "\""; 58 58 else … … 69 69 } 70 70 71 QString GNUMakefileGenerator::escape DependencyPath(const QString &path) const71 QString GNUMakefileGenerator::escapeFilePath(const QString &path) const 72 72 { 73 73 QString ret = path; 74 ret.remove('\"'); 75 ret.replace('\\', "/"); 76 ret.replace(' ', "\\ "); 74 if (!isDosLikeShell()) { 75 ret.remove('\"'); 76 ret.replace('\\', "/"); 77 ret.replace(' ', "\\ "); 78 } else { 79 ret.replace(QRegExp("\""), ""); 80 if (ret.contains(QRegExp("[ +&;%]"))) 81 ret = quote + ret + quote; 82 /* @todo exclude $(var) constructs from quoting like this: 83 * $(OBJECTS_DIR)\my file.obj = > $(OBJECTS_DIR)\"my file.obj" 84 */ 85 } 77 86 return ret; 78 87 } … … 191 200 init_flag = true; 192 201 193 /* this should probably not be here, but I'm using it to wrap the .t files */194 202 if(project->first("TEMPLATE") == "app") 195 203 project->values("QMAKE_APP_FLAG").append("1"); … … 201 209 project->values("QMAKE_COPY_FILE").append("$(COPY)"); 202 210 if(project->isEmpty("QMAKE_COPY_DIR")) 203 project->values("QMAKE_COPY_DIR").append(" xcopy /s /q /y /i");211 project->values("QMAKE_COPY_DIR").append("$(COPY)"); 204 212 if(project->isEmpty("QMAKE_INSTALL_FILE")) 205 213 project->values("QMAKE_INSTALL_FILE").append("$(COPY_FILE)"); … … 219 227 processVars(); 220 228 221 if (!project->values("RES_FILE").isEmpty()) {222 project->values("QMAKE_LIBS") += escapeFilePaths(project->values("RES_FILE"));223 }224 225 229 // LIBS defined in Profile comes first for gcc 226 230 project->values("QMAKE_LIBS") += escapeFilePaths(project->values("LIBS")); … … 238 242 destDir = Option::fixPathToTargetOS(project->first("DESTDIR") + Option::dir_sep, false, false); 239 243 } 240 241 if(!project->values("DEF_FILE").isEmpty())242 project->values("QMAKE_LFLAGS").append(QString("-Wl,") + project->first("DEF_FILE"));243 244 244 245 MakefileGenerator::init(); … … 270 271 void GNUMakefileGenerator::fixTargetExt() 271 272 { 272 if (project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { 273 project->values("TARGET_EXT").append(".lib"); 274 project->values("QMAKE_LFLAGS").append("-static"); 275 project->values("TARGET").first() = "lib" + project->first("TARGET"); 276 } else { 277 Win32MakefileGenerator::fixTargetExt(); 278 } 273 Win32MakefileGenerator::fixTargetExt(); 279 274 } 280 275 … … 287 282 QString incsSemicolon; 288 283 for(QStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { 289 QString inc = maybeQuotePath(*incit);284 QString inc = escapeFilePath(*incit); 290 285 t << " " << opt << inc; 291 286 incsSemicolon += inc + Option::dirlist_sep; … … 309 304 QStringList libs = project->values("QMAKE_LIBS"); 310 305 for(QStringList::Iterator it = libs.begin(); it != libs.end(); ++it) { 311 QString lib = maybeQuotePath(*it);306 QString lib = escapeFilePath(*it); 312 307 /* lib may be prefixed with -l which is commonly used in e.g. PRF 313 308 * (feature) files on all platforms; remove it before prepending … … 326 321 QStringList libDirs = project->values("QMAKE_LIBDIR"); 327 322 for(QStringList::Iterator it = libDirs.begin(); it != libDirs.end(); ++it) { 328 QString libDir = maybeQuotePath(*it);323 QString libDir = escapeFilePath(*it); 329 324 /* libDir may be prefixed with -L which is commonly used in e.g. PRF 330 325 * (feature) files on all platforms; remove it before prepending … … 353 348 if(!project->isEmpty("QMAKE_PRE_LINK")) 354 349 t << "\n\t" <<var("QMAKE_PRE_LINK"); 355 if(project->isActiveConfig("staticlib") && project->first("TEMPLATE") == "lib") { 356 t << "\n\t" << "$(LIB) $(DESTDIR_TARGET) $(OBJECTS)"; 350 if(project->first("TEMPLATE") == "lib" && project->isActiveConfig("staticlib")) { 351 /* static library */ 352 t << "\n\t" << var("QMAKE_RUN_LIB"); 357 353 } else { 358 t << "\n\t" << "$(LINK) $(LFLAGS) -o $(DESTDIR_TARGET) $(OBJECTS) $(LIBS)"; 354 /* application or DLL */ 355 t << "\n\t" << var("QMAKE_RUN_LINK"); 356 if (!project->isEmpty("RES_FILE") && !project->isEmpty("QMAKE_RUN_RC2EXE")) { 357 t << "\n\t" << var("QMAKE_RUN_RC2EXE"); 358 } 359 if (project->first("TEMPLATE") == "lib") { 360 if (!project->isEmpty("QMAKE_RUN_IMPLIB")) 361 t << "\n\t" << var("QMAKE_RUN_IMPLIB"); 362 } 359 363 } 360 364 if(!project->isEmpty("QMAKE_POST_LINK")) … … 363 367 } 364 368 365 void GNUMakefileGenerator::writeRcFilePart(QTextStream &t) 366 { 367 const QString rc_file = fileFixify(project->first("RC_FILE")); 368 369 QString incPathStr = fileInfo(rc_file).path(); 370 if (incPathStr != "." && QDir::isRelativePath(incPathStr)) 371 incPathStr.prepend("./"); 372 373 if (!rc_file.isEmpty()) { 374 t << escapeDependencyPath(var("RES_FILE")) << ": " << rc_file << "\n\t" 375 << var("QMAKE_RC") << " -i " << rc_file << " -o " << var("RES_FILE") 376 << " --include-dir=" << incPathStr << endl << endl; 377 } 369 void GNUMakefileGenerator::writeRcAndDefVariables(QTextStream &t) 370 { 371 if (!project->isEmpty("RC_FILE")) { 372 t << "RC_FILE = " << escapeFilePath(var("RC_FILE")) << endl; 373 } 374 if (!project->isEmpty("RES_FILE")) { 375 t << "RES_FILE = " << valList(escapeFilePaths(project->values("RES_FILE"))) << endl; 376 } 377 if (project->first("TEMPLATE") == "lib" && !project->isActiveConfig("staticlib") && 378 !project->isEmpty( "QMAKE_RUN_IMPLIB")) { 379 t << "TARGET_IMPLIB = $(basename $(DESTDIR_TARGET)).lib" << endl; 380 project->values("QMAKE_CLEAN").append( "$(TARGET_IMPLIB)" ); 381 } 382 } 383 384 void GNUMakefileGenerator::writeRcAndDefPart(QTextStream &t) 385 { 386 if (!project->isEmpty("RC_FILE") && !project->isEmpty("RES_FILE") && 387 !project->isEmpty("QMAKE_RUN_RC2RES")) { 388 t << "$(RES_FILE): $(RC_FILE)\n\t"; 389 t << var("QMAKE_RUN_RC2RES") << endl; 390 } 391 } 392 393 void GNUMakefileGenerator::processRcFileVar() 394 { 395 if (Option::qmake_mode == Option::QMAKE_GENERATE_NOTHING) 396 return; 397 398 if (!project->values("RC_FILE").isEmpty()) { 399 if (!project->values("RES_FILE").isEmpty()) { 400 fprintf(stderr, "Both rc and res file specified.\n"); 401 fprintf(stderr, "Please specify one of them, not both."); 402 exit(1); 403 } 404 project->values("RES_FILE").prepend(escapeFilePath(QString("$(OBJECTS_DIR)") + 405 QDir::separator() + 406 QFileInfo(var("RC_FILE")).baseName() + 407 ".res")); 408 project->values("CLEAN_FILES") += "$(RES_FILE)"; 409 } 410 411 if (!project->values("RES_FILE").isEmpty()) 412 project->values("POST_TARGETDEPS") += "$(RES_FILE)"; 378 413 } 379 414 … … 421 456 } 422 457 423 QString GNUMakefileGenerator::maybeQuotePath(const QString &path)424 {425 QString quoted = path;426 quoted.replace(QRegExp("\\\\$"), "");427 quoted.replace(QRegExp("\""), "");428 if (quoted.contains(QRegExp("[ +&;$%()]")))429 quoted = quote + quoted + quote;430 return quoted;431 }432 433 458 void GNUMakefileGenerator::writeProjectVarToStream(QTextStream &t, const QString &var) 434 459 { … … 475 500 if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { 476 501 QTextStream rt(&file); 477 writeProjectVarToStream(rt, vars[i+1]); 502 if (!qstrcmp(vars[i+1], "INCPATH")) { 503 QString opt = var("QMAKE_CFLAGS_INCDIR"); 504 rt << varGlue(vars[i+1], opt, "\n" + opt, QString::null); 505 } else 506 rt << varGlue(vars[i+1], QString::null, "\n", QString::null); 478 507 rt.flush(); 479 508 file.close(); … … 494 523 if (file.open(QIODevice::WriteOnly | QIODevice::Text)) { 495 524 QTextStream rt(&file); 496 writeProjectVarToStream(rt, "OBJECTS");525 rt << varGlue("OBJECTS", QString::null, "\n", QString::null); 497 526 rt.flush(); 498 527 file.close();
Note:
See TracChangeset
for help on using the changeset viewer.