qmake/generators/metamakefile.cpp
branchGCC_SURGE
changeset 31 5daf16870df6
parent 30 5dc02b23752f
child 33 3e2da88830cd
equal deleted inserted replaced
27:93b982ccede2 31:5daf16870df6
    55 MetaMakefileGenerator::~MetaMakefileGenerator()
    55 MetaMakefileGenerator::~MetaMakefileGenerator()
    56 {
    56 {
    57     if(own_project)
    57     if(own_project)
    58         delete project;
    58         delete project;
    59 }
    59 }
       
    60 
       
    61 #ifndef QT_QMAKE_PARSER_ONLY
    60 
    62 
    61 class BuildsMetaMakefileGenerator : public MetaMakefileGenerator
    63 class BuildsMetaMakefileGenerator : public MetaMakefileGenerator
    62 {
    64 {
    63 private:
    65 private:
    64     bool init_flag;
    66     bool init_flag;
   291     if(init_flag)
   293     if(init_flag)
   292         return false;
   294         return false;
   293     init_flag = true;
   295     init_flag = true;
   294     bool hasError = false;
   296     bool hasError = false;
   295 
   297 
   296     if(Option::recursive) {
   298     // It might make sense to bequeath the CONFIG option to the recursed
       
   299     // projects. OTOH, one would most likely have it in all projects anyway -
       
   300     // either through a qmakespec, a .qmake.cache or explicitly - as otherwise
       
   301     // running qmake in a subdirectory would have a different auto-recurse
       
   302     // setting than in parent directories.
       
   303     bool recurse = Option::recursive == Option::QMAKE_RECURSIVE_YES
       
   304                    || (Option::recursive == Option::QMAKE_RECURSIVE_DEFAULT
       
   305                        && project->isRecursive());
       
   306     if(recurse) {
   297         QString old_output_dir = Option::output_dir;
   307         QString old_output_dir = Option::output_dir;
   298 	QString old_output = Option::output.fileName();
   308 	QString old_output = Option::output.fileName();
   299         QString oldpwd = qmake_getpwd();
   309         QString oldpwd = qmake_getpwd();
   300         QString thispwd = oldpwd;
   310         QString thispwd = oldpwd;
   301         if(!thispwd.endsWith('/'))
   311         if(!thispwd.endsWith('/'))
   376     }
   386     }
   377 
   387 
   378     Subdir *self = new Subdir;
   388     Subdir *self = new Subdir;
   379     self->input_dir = qmake_getpwd();
   389     self->input_dir = qmake_getpwd();
   380     self->output_dir = Option::output_dir;
   390     self->output_dir = Option::output_dir;
   381     if(!Option::recursive || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir()))
   391     if(!recurse || (!Option::output.fileName().endsWith(Option::dir_sep) && !QFileInfo(Option::output).isDir()))
   382 	self->output_file = Option::output.fileName();
   392 	self->output_file = Option::output.fileName();
   383     self->makefile = new BuildsMetaMakefileGenerator(project, name, false);
   393     self->makefile = new BuildsMetaMakefileGenerator(project, name, false);
   384     self->makefile->init();
   394     self->makefile->init();
   385     subs.append(self);
   395     subs.append(self);
   386 
   396 
   435 #include "mingw_make.h"
   445 #include "mingw_make.h"
   436 #include "projectgenerator.h"
   446 #include "projectgenerator.h"
   437 #include "pbuilder_pbx.h"
   447 #include "pbuilder_pbx.h"
   438 #include "msvc_nmake.h"
   448 #include "msvc_nmake.h"
   439 #include "borland_bmake.h"
   449 #include "borland_bmake.h"
   440 #include "msvc_dsp.h"
       
   441 #include "msvc_vcproj.h"
   450 #include "msvc_vcproj.h"
       
   451 #include "msvc_vcxproj.h"
   442 #include "symmake_abld.h"
   452 #include "symmake_abld.h"
   443 #include "symmake_sbsv2.h"
   453 #include "symmake_sbsv2.h"
       
   454 #include "symbian_makefile.h"
   444 QT_END_INCLUDE_NAMESPACE
   455 QT_END_INCLUDE_NAMESPACE
   445 
   456 
   446 MakefileGenerator *
   457 MakefileGenerator *
   447 MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
   458 MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
   448 {
   459 {
   461         mkfile = new UnixMakefileGenerator;
   472         mkfile = new UnixMakefileGenerator;
   462     } else if(gen == "MINGW") {
   473     } else if(gen == "MINGW") {
   463         mkfile = new MingwMakefileGenerator;
   474         mkfile = new MingwMakefileGenerator;
   464     } else if(gen == "PROJECTBUILDER" || gen == "XCODE") {
   475     } else if(gen == "PROJECTBUILDER" || gen == "XCODE") {
   465         mkfile = new ProjectBuilderMakefileGenerator;
   476         mkfile = new ProjectBuilderMakefileGenerator;
   466     } else if(gen == "MSVC") {
   477     } else if(gen == "MSVC.NET") {
   467         // Visual Studio =< v6.0
   478         if (proj->first("TEMPLATE").startsWith("vc"))
   468         if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1)
   479             mkfile = new VcprojGenerator;
   469             mkfile = new DspMakefileGenerator;
       
   470         else
   480         else
   471             mkfile = new NmakeMakefileGenerator;
   481             mkfile = new NmakeMakefileGenerator;
   472     } else if(gen == "MSVC.NET") {
   482     } else if(gen == "MSBUILD") {
   473         // Visual Studio >= v7.0
   483         // Visual Studio >= v11.0
   474         if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1 || proj->first("TEMPLATE").indexOf(QRegExp("^ce.*")) != -1)
   484         if(proj->first("TEMPLATE").indexOf(QRegExp("^vc.*")) != -1 || proj->first("TEMPLATE").indexOf(QRegExp("^ce.*")) != -1)
   475             mkfile = new VcprojGenerator;
   485             mkfile = new VcxprojGenerator;
   476         else
   486         else
   477             mkfile = new NmakeMakefileGenerator;
   487             mkfile = new NmakeMakefileGenerator;
   478     } else if(gen == "BMAKE") {
   488     } else if(gen == "BMAKE") {
   479         mkfile = new BorlandMakefileGenerator;
   489         mkfile = new BorlandMakefileGenerator;
   480     } else if(gen == "SYMBIAN_ABLD") {
   490     } else if(gen == "SYMBIAN_ABLD") {
   481         mkfile = new SymbianAbldMakefileGenerator;
   491         mkfile = new SymbianAbldMakefileGenerator;
   482     } else if(gen == "SYMBIAN_SBSV2") {
   492     } else if(gen == "SYMBIAN_SBSV2") {
   483         mkfile = new SymbianSbsv2MakefileGenerator;
   493         mkfile = new SymbianSbsv2MakefileGenerator;
       
   494     } else if(gen == "SYMBIAN_UNIX") {
       
   495         mkfile = new SymbianMakefileTemplate<UnixMakefileGenerator>;
   484     } else {
   496     } else {
   485         fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
   497         fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
   486     }
   498     }
   487     if (mkfile) {
   499     if (mkfile) {
   488         mkfile->setNoIO(noIO);
   500         mkfile->setNoIO(noIO);
   506     if (success)
   518     if (success)
   507         *success = res;
   519         *success = res;
   508     return ret;
   520     return ret;
   509 }
   521 }
   510 
   522 
       
   523 #endif // QT_QMAKE_PARSER_ONLY
       
   524 
       
   525 bool
       
   526 MetaMakefileGenerator::modesForGenerator(const QString &gen,
       
   527         Option::HOST_MODE *host_mode, Option::TARG_MODE *target_mode)
       
   528 {
       
   529     if (gen == "UNIX") {
       
   530 #ifdef Q_OS_MAC
       
   531         *host_mode = Option::HOST_MACX_MODE;
       
   532         *target_mode = Option::TARG_MACX_MODE;
       
   533 #else
       
   534         *host_mode = Option::HOST_UNIX_MODE;
       
   535         *target_mode = Option::TARG_UNIX_MODE;
       
   536 #endif
       
   537     } else if (gen == "MSVC.NET" || gen == "MINGW" || gen == "BMAKE" || gen == "MSBUILD") {
       
   538         *host_mode = Option::HOST_WIN_MODE;
       
   539         *target_mode = Option::TARG_WIN_MODE;
       
   540     } else if (gen == "PROJECTBUILDER" || gen == "XCODE") {
       
   541         *host_mode = Option::HOST_MACX_MODE;
       
   542         *target_mode = Option::TARG_MACX_MODE;
       
   543     } else if (gen == "SYMBIAN_ABLD" || gen == "SYMBIAN_SBSV2" || gen == "SYMBIAN_UNIX") {
       
   544 #if defined(Q_OS_MAC)
       
   545         *host_mode = Option::HOST_MACX_MODE;
       
   546 #elif defined(Q_OS_UNIX)
       
   547         *host_mode = Option::HOST_UNIX_MODE;
       
   548 #else
       
   549         *host_mode = Option::HOST_WIN_MODE;
       
   550 #endif
       
   551         *target_mode = Option::TARG_SYMBIAN_MODE;
       
   552     } else {
       
   553         fprintf(stderr, "Unknown generator specified: %s\n", gen.toLatin1().constData());
       
   554         return false;
       
   555     }
       
   556     return true;
       
   557 }
       
   558 
   511 QT_END_NAMESPACE
   559 QT_END_NAMESPACE