diff options
author | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /qmake/generators/win32 | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'qmake/generators/win32')
-rw-r--r-- | qmake/generators/win32/borland_bmake.cpp | 664 | ||||
-rw-r--r-- | qmake/generators/win32/borland_bmake.h | 60 | ||||
-rw-r--r-- | qmake/generators/win32/mingw_make.cpp | 717 | ||||
-rw-r--r-- | qmake/generators/win32/mingw_make.h | 64 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_dsp.cpp | 1145 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_dsp.h | 79 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.cpp | 792 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_nmake.h | 67 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.cpp | 2226 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_objectmodel.h | 801 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.cpp | 1541 | ||||
-rw-r--r-- | qmake/generators/win32/msvc_vcproj.h | 122 | ||||
-rw-r--r-- | qmake/generators/win32/winmakefile.cpp | 487 | ||||
-rw-r--r-- | qmake/generators/win32/winmakefile.h | 75 |
14 files changed, 8840 insertions, 0 deletions
diff --git a/qmake/generators/win32/borland_bmake.cpp b/qmake/generators/win32/borland_bmake.cpp new file mode 100644 index 000000000..218014b0c --- /dev/null +++ b/qmake/generators/win32/borland_bmake.cpp @@ -0,0 +1,664 @@ +/**************************************************************************** +** +** NmakeMakefileGenerator of BorlandMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "borland_bmake.h" +#include "option.h" +#include <qdir.h> +#include <qregexp.h> +#include <time.h> +#include <stdlib.h> + + +BorlandMakefileGenerator::BorlandMakefileGenerator(TQMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +BorlandMakefileGenerator::writeMakefile(TQTextStream &t) +{ + writeHeader(t); + if(!project->variables()["QMAKE_FAILED_RETQUIREMENTS"].isEmpty()) { + t << "all clean:" << "\n\t" + << "@echo \"Some of the retquired modules (" + << var("QMAKE_FAILED_RETQUIREMENTS") << ") are not available.\"" << "\n\t" + << "@echo \"Skipped.\"" << endl << endl; + return TRUE; + } + + if(project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib") { + writeBorlandParts(t); + return MakefileGenerator::writeMakefile(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +void +BorlandMakefileGenerator::writeBorlandParts(TQTextStream &t) +{ + t << "!if !$d(BCB)" << endl; + t << "BCB = $(MAKEDIR)\\.." << endl; + t << "!endif" << endl << endl; + t << "####### Compiler, tools and options" << endl << endl; + t << "CC = " << var("QMAKE_CC") << endl; + t << "CXX = " << var("QMAKE_CXX") << endl; + t << "LEX = " << var("QMAKE_LEX") << endl; + t << "YACC = " << var("QMAKE_YACC") << endl; + t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "CXXFLAGS= " << var("QMAKE_CXXFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "LEXFLAGS=" << var("QMAKE_LEXFLAGS") << endl; + t << "YACCFLAGS=" << var("QMAKE_YACCFLAGS") << endl; + + t << "INCPATH = "; + TQStringList &incs = project->variables()["INCLUDEPATH"]; + for(TQStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + TQString inc = (*incit); + inc.replace(TQRegExp("\\\\*$"), ""); + inc.replace("\"", ""); + t << " -I\"" << inc << "\""; + } + t << " -I\"" << specdir() << "\"" + << endl; + + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "LINK = " << var("QMAKE_LINK") << endl; + t << "LFLAGS = "; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + t << varGlue("QMAKE_LIBDIR","-L",";","") << " "; + t << var("QMAKE_LFLAGS") << endl; + t << "LIBS = " << var("QMAKE_LIBS") << endl; + } + else { + t << "LIB = " << var("QMAKE_LIB") << endl; + } + t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : + Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; + t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : + Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; + t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? TQString("idc") : + Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; + t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? TQString("midl") : + Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; + t << "ZIP = " << var("QMAKE_ZIP") << endl; + t << "DEF_FILE = " << varList("DEF_FILE") << endl; + t << "RES_FILE = " << varList("RES_FILE") << endl; + t << "COPY_FILE = " << var("QMAKE_COPY") << endl; + t << "COPY_DIR = " << var("QMAKE_COPY") << endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; + t << "MOVE = " << var("QMAKE_MOVE") << endl; + t << "CHK_DIR_EXISTS = " << var("QMAKE_CHK_DIR_EXISTS") << endl; + t << "MKDIR = " << var("QMAKE_MKDIR") << endl; + t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl; + t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; + t << endl; + + t << "####### Files" << endl << endl; + t << "HEADERS = " << varList("HEADERS") << endl; + t << "SOURCES = " << varList("SOURCES") << endl; + t << "OBJECTS = " << varList("OBJECTS") << endl; + t << "FORMS = " << varList("FORMS") << endl; + t << "UICDECLS = " << varList("UICDECLS") << endl; + t << "UICIMPLS = " << varList("UICIMPLS") << endl; + t << "SRCMOC = " << varList("SRCMOC") << endl; + t << "OBJMOC = " << varList("OBJMOC") << endl; + + TQString extraCompilerDeps; + if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) { + t << "OBJCOMP = " << varList("OBJCOMP") << endl; + extraCompilerDeps += " $(OBJCOMP) "; + + TQStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(TQStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) { + TQStringList &vars = project->variables()[(*compit) + ".variables"]; + for(TQStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) { + TQStringList vals = project->variables()[(*varit)]; + if(!vals.isEmpty()) + t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl; + } + } + } + + t << "DIST = " << varList("DISTFILES") << endl; + t << "TARGET = " + << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")) + << endl; + t << endl; + + t << "####### Implicit rules" << endl << endl; + t << ".SUFFIXES: .c"; + TQStringList::Iterator cppit; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << " " << (*cppit); + t << endl << endl; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + + t << "####### Build rules" << endl << endl; + t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << " $(TARGET)" << endl << endl; + t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " + << extraCompilerDeps << var("POST_TARGETDEPS"); + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "\n\t" << "$(LINK) @&&|" << "\n\t" + << "$(LFLAGS) $(OBJECTS) $(OBJMOC),$(TARGET),,$(LIBS),$(DEF_FILE),$(RES_FILE)"; + } else { + t << "\n\t-$(DEL_FILE) $(TARGET)" + << "\n\t" << "$(LIB) $(TARGET) @&&|" << " \n+" + << project->variables()["OBJECTS"].join(" \\\n+") << " \\\n+" + << project->variables()["OBJMOC"].join(" \\\n+"); + } + t << extraCompilerDeps; + t << endl << "|" << endl; + + if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) + t << "\t" <<var("QMAKE_POST_LINK") << endl; + + if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { + TQStringList dlldirs = project->variables()["DLLDESTDIR"]; + for ( TQStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + t << "\n\t" << "-$(COPY_FILE) \"$(TARGET)\" " << *dlldir; + } + } + TQString targetfilename = project->variables()["TARGET"].first(); + if(project->isActiveConfig("activeqt")) { + TQString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + if ( project->isActiveConfig("dll")) { + t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); + } else { + t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(TARGET) -regserver"); + } + } + t << endl << endl; + + if(!project->variables()["RC_FILE"].isEmpty()) { + t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" + << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; + } + t << "mocables: $(SRCMOC)" << endl + << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl; + + writeMakeQmake(t); + + TQStringList dist_files = Option::mkfile::project_files; + if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) + dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"]; + if(!project->isEmpty("TRANSLATIONS")) + dist_files << var("TRANSLATIONS"); + if(!project->isEmpty("FORMS")) { + TQStringList &forms = project->variables()["FORMS"]; + for(TQStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { + TQString ui_h = fileFixify((*formit) + Option::h_ext.first()); + if(TQFile::exists(ui_h) ) + dist_files << ui_h; + } + } + t << "dist:" << "\n\t" + << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) " + << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl; + + t << "uiclean:"; + TQString uiclean = varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ",""); + if ( uiclean.isEmpty() ) { + // Borland make does not like an empty command section + uiclean = "\n\t@cd ."; + } + t << uiclean << endl; + + t << "mocclean:"; + TQString mocclean = varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ",""); + if ( mocclean.isEmpty() ) { + // Borland make does not like an empty command section + mocclean = "\n\t@cd ."; + } + t << mocclean << endl; + + t << "clean: uiclean mocclean" + << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ",""); + if ( project->isActiveConfig("activeqt")) { + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl"); + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + } + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", ""); + t << endl; + + // user defined targets + TQStringList::Iterator it; + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(it = qut.begin(); it != qut.end(); ++it) { + TQString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), deps; + if(targ.isEmpty()) + targ = (*it); + TQStringList &deplist = project->variables()[(*it) + ".depends"]; + for(TQStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { + TQString dep = var((*dep_it) + ".target"); + if(dep.isEmpty()) + dep = (*dep_it); + deps += " " + dep; + } + if(!project->variables()["QMAKE_NOFORCE"].isEmpty() && + project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1) + deps += TQString(" ") + "FORCE"; + t << "\n\n" << targ << ":" << deps << "\n\t" + << cmd; + } + + t << endl << endl; + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + TQString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); + TQString tmp_dep = project->variables()[(*it) + ".depends"].join(" "); + TQStringList &vars = project->variables()[(*it) + ".variables"]; + if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out, cmd = tmp_cmd, deps; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + cmd.replace("${QMAKE_FILE_BASE}", fi.baseName()); + cmd.replace("${QMAKE_FILE_OUT}", out); + cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + for(TQStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3) + cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")"); + if(!tmp_dep.isEmpty()) { + char buff[256]; + TQString dep_cmd = tmp_dep; + dep_cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) { + while(!feof(proc)) { + int read_in = int(fread(buff, 1, 255, proc)); + if(!read_in) + break; + int l = 0; + for(int i = 0; i < read_in; i++) { + if(buff[i] == '\n' || buff[i] == ' ') { + deps += " " + TQCString(buff+l, (i - l) + 1); + l = i; + } + } + } + fclose(proc); + } + } + t << out << ": " << in << deps << "\n\t" + << cmd << endl << endl; + } + } + } + t << endl; + + t << "distclean: clean" + << "\n\t-$(DEL_FILE) $(TARGET)" + << endl << endl; +} + +void +BorlandMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + /* this should probably not be here, but I'm using it to wrap the .t files */ + if(project->first("TEMPLATE") == "app") + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "lib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "subdirs") { + MakefileGenerator::init(); + if(project->variables()["MAKEFILE"].isEmpty()) + project->variables()["MAKEFILE"].append("Makefile"); + if(project->variables()["QMAKE"].isEmpty()) + project->variables()["QMAKE"].append("qmake"); + return; + } + + if(project->isEmpty("QMAKE_INSTALL_FILE")) + project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)"); + if(project->isEmpty("QMAKE_INSTALL_DIR")) + project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)"); + + bool is_qt = (project->first("TARGET") == "qt"TQTDLL_POSTFIX || project->first("TARGET") == "qtmt"TQTDLL_POSTFIX); + TQStringList &configs = project->variables()["CONFIG"]; + if (project->isActiveConfig("shared")) + project->variables()["DEFINES"].append("QT_DLL"); + if (project->isActiveConfig("qt_dll")) + if(configs.findIndex("qt") == -1) configs.append("qt"); + if ( project->isActiveConfig("qtopia") ) { + if(configs.findIndex("qtopialib") == -1) + configs.append("qtopialib"); + if(configs.findIndex("qtopiainc") == -1) + configs.append("qtopiainc"); + } + if ( project->isActiveConfig("qt") ) { + if ( project->isActiveConfig("plugin") ) { + project->variables()["CONFIG"].append("dll"); + project->variables()["DEFINES"].append("QT_PLUGIN"); + } + if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && + ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || + project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || + (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { + project->variables()["QMAKE_QT_DLL"].append("1"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) + project->variables()["CONFIG"].append("dll"); + } + } + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["CONFIG"].remove("staticlib"); + project->variables()["QMAKE_APP_OR_DLL"].append("1"); + } else { + project->variables()["CONFIG"].append("staticlib"); + } + if ( project->isActiveConfig("warn_off") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; + } else if ( project->isActiveConfig("warn_on") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; + } + if(project->isActiveConfig("qt")) { + if ( project->isActiveConfig("thread") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); + if ( project->isActiveConfig("accessibility" ) ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); + if ( project->isActiveConfig("tablet") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); + } + + if ( project->isActiveConfig("debug") ) { + if ( project->isActiveConfig("thread") ) { + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; + } else { + if ( project->isActiveConfig("thread") ) { + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; + } + + if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) { + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; + } + if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { + project->variables()["CONFIG"].append("windows"); + } + if ( project->isActiveConfig("qtopiainc") ) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"]; + if ( project->isActiveConfig("qtopialib") ) { + if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA")) + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"]; + } + if ( project->isActiveConfig("qt") ) { + project->variables()["CONFIG"].append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + if ( !project->isActiveConfig("debug") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { + project->variables()["DEFINES"].append("QT_MAKEDLL"); + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; + } + } else { + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); + if ( hver == -1 ) + hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qtmt"); + if(hver != -1) { + TQString ver; + ver.sprintf("qt%s" TQTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "mt" : ""), hver); + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(TQRegExp("qt(mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append( + TQStringList::split('.',project->first("VERSION")).join("") + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } else { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append(".exe"); + } else { + project->variables()["TARGET_EXT"].append(".lib"); + } + } + if ( project->isActiveConfig("windows") ) { + if ( project->isActiveConfig("console") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } else { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; + } + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } + if ( project->isActiveConfig("stl") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; + } + if ( project->isActiveConfig("exceptions") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; + } + if ( project->isActiveConfig("rtti") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; + } + + if ( project->isActiveConfig("thread") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RTMT"]; + } else { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_RT"]; + } + if ( project->isActiveConfig("moc") ) { + setMocAware(TRUE); + } + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + // Update -lname to name.lib, and -Ldir to + TQStringList &libList = project->variables()["QMAKE_LIBS"]; + for( TQStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) { + TQString s = *stIt; + if( s.startsWith( "-l" ) ) { + stIt = libList.remove( stIt ); + stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" ); + } else if( s.startsWith( "-L" ) ) { + stIt = libList.remove( stIt ); + project->variables()["QMAKE_LIBDIR"].append(TQDir::convertSeparators(s.mid( 2 ))); + } else { + stIt++; + } + } + project->variables()["QMAKE_FILETAGS"] += TQStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + TQStringList &l = project->variables()["QMAKE_FILETAGS"]; + TQStringList::Iterator it; + for(it = l.begin(); it != l.end(); ++it) { + TQStringList &gdmf = project->variables()[(*it)]; + for(TQStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) + (*inner) = Option::fixPathToTargetOS((*inner), FALSE); + } + + if ( !project->variables()["RC_FILE"].isEmpty()) { + if ( !project->variables()["RES_FILE"].isEmpty()) { + fprintf(stderr, "Both .rc and .res file specified.\n"); + fprintf(stderr, "Please specify one of them, not both."); + exit(666); + } + project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; + project->variables()["RES_FILE"].first().replace(".rc",".res"); + project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; + project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"]; + } + MakefileGenerator::init(); + if ( !project->variables()["VERSION"].isEmpty()) { + TQStringList l = TQStringList::split('.', project->first("VERSION")); + project->variables()["VER_MAJ"].append(l[0]); + project->variables()["VER_MIN"].append(l[1]); + } + + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + // bcc does not generate a .tds file for static libs + TQString tdsPostfix; + if ( !project->variables()["VERSION"].isEmpty() ) { + tdsPostfix = TQStringList::split( '.', project->first("VERSION") ).join("") + + ".tds"; + } else { + tdsPostfix = ".tds"; + } + project->variables()["QMAKE_CLEAN"].append( + project->first("DESTDIR") + project->first("TARGET") + tdsPostfix ); + } + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + if(tmp_out.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1) + project->variables()["OBJCOMP"] += out; + } + } + } +} diff --git a/qmake/generators/win32/borland_bmake.h b/qmake/generators/win32/borland_bmake.h new file mode 100644 index 000000000..bae9752fa --- /dev/null +++ b/qmake/generators/win32/borland_bmake.h @@ -0,0 +1,60 @@ +/**************************************************************************** +** +** Definition of BorlandMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __BORLAND_BMAKE_H__ +#define __BORLAND_BMAKE_H__ + +#include "winmakefile.h" + +class BorlandMakefileGenerator : public Win32MakefileGenerator +{ + bool init_flag; + void writeBorlandParts(TQTextStream &); + + bool writeMakefile(TQTextStream &); + void init(); + +public: + BorlandMakefileGenerator(TQMakeProject *p); + ~BorlandMakefileGenerator(); +}; + +inline BorlandMakefileGenerator::~BorlandMakefileGenerator() +{ } + +#endif /* __BORLAND_BMAKE_H__ */ diff --git a/qmake/generators/win32/mingw_make.cpp b/qmake/generators/win32/mingw_make.cpp new file mode 100644 index 000000000..5afb16d37 --- /dev/null +++ b/qmake/generators/win32/mingw_make.cpp @@ -0,0 +1,717 @@ +/**************************************************************************** +** +** Implementation of MingwMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "mingw_make.h" +#include "option.h" +#include <qregexp.h> +#include <qdir.h> +#include <stdlib.h> +#include <time.h> + + +MingwMakefileGenerator::MingwMakefileGenerator(TQMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + Option::obj_ext = ".o"; +} + +bool +MingwMakefileGenerator::findLibraries() // todo - pascal +{ + return TRUE; +} + +bool +MingwMakefileGenerator::writeMakefile(TQTextStream &t) +{ + writeHeader(t); + if(!project->variables()["QMAKE_FAILED_RETQUIREMENTS"].isEmpty()) { + t << "all clean:" << "\n\t" + << "@echo \"Some of the retquired modules (" + << var("QMAKE_FAILED_RETQUIREMENTS") << ") are not available.\"" << "\n\t" + << "@echo \"Skipped.\"" << endl << endl; + writeMakeQmake(t); + return TRUE; + } + + if(project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib") { + writeMingwParts(t); + return MakefileGenerator::writeMakefile(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeSubDirs(t); + return TRUE; + } + return FALSE; + } + +void createLdObjectScriptFile(const TQString & fileName, TQStringList & objList) +{ + TQString filePath = Option::output_dir + TQDir::separator() + fileName; + TQFile file(filePath); + if (file.open(IO_WriteOnly | IO_Translate )) { + TQTextStream t(&file); + t << "INPUT(" << endl; + for (TQStringList::Iterator it = objList.begin(); it != objList.end(); ++it ) { + if (TQDir::isRelativePath(*it)) + t << "./" << *it << endl; + else + t << *it << endl; + } + t << ");" << endl; + file.close(); + } +} + +void +MingwMakefileGenerator::writeMingwParts(TQTextStream &t) +{ + t << "####### Compiler, tools and options" << endl << endl; + t << "CC = " << var("QMAKE_CC") << endl; + t << "CXX = " << var("QMAKE_CXX") << endl; + t << "LEX = " << var("QMAKE_LEX") << endl; + t << "YACC = " << var("QMAKE_YACC") << endl; + t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "LEXFLAGS =" << var("QMAKE_LEXFLAGS") << endl; + t << "YACCFLAGS =" << var("QMAKE_YACCFLAGS") << endl; + + t << "INCPATH = "; + TQStringList &incs = project->variables()["INCLUDEPATH"]; + for(TQStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + TQString inc = (*incit); + inc.replace(TQRegExp("\\\\$"), ""); + inc.replace(TQRegExp("\""), ""); + t << " -I" << "\"" << inc << "\""; + } + t << " -I" << "\"" << specdir() << "\"" << endl; + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "LINK = " << var("QMAKE_LINK") << endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS") << endl; + t << "LIBS = "; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + t << varGlue("QMAKE_LIBDIR","-L\"","\" -L\"","\"") << " "; + t << var("QMAKE_LIBS").replace(TQRegExp("(\\slib|^lib)")," -l") << endl; + } + else { + t << "LIB = " << var("QMAKE_LIB") << endl; + } + t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : + Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; + t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : + Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; + t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? TQString("idc") : + Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; + t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? TQString("midl") : + Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; + t << "ZIP = " << var("QMAKE_ZIP") << endl; + t << "DEF_FILE = " << varList("DEF_FILE") << endl; + t << "COPY_FILE = " << var("QMAKE_COPY") << endl; + t << "COPY_DIR = " << var("QMAKE_COPY") << endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; + t << "MOVE = " << var("QMAKE_MOVE") << endl; + t << "CHK_DIR_EXISTS = " << var("QMAKE_CHK_DIR_EXISTS") << endl; + t << "MKDIR = " << var("QMAKE_MKDIR") << endl; + t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl; + t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; + t << endl; + + t << "####### Output directory" << endl << endl; + if (! project->variables()["OBJECTS_DIR"].isEmpty()) + t << "OBJECTS_DIR = " << var("OBJECTS_DIR").replace(TQRegExp("\\\\$"),"") << endl; + else + t << "OBJECTS_DIR = . " << endl; + if (! project->variables()["MOC_DIR"].isEmpty()) + t << "MOC_DIR = " << var("MOC_DIR").replace(TQRegExp("\\\\$"),"") << endl; + else + t << "MOC_DIR = . " << endl; + t << endl; + + t << "####### Files" << endl << endl; + t << "HEADERS = " << varList("HEADERS") << endl; + t << "SOURCES = " << varList("SOURCES") << endl; + TQString objectsLinkLine; + if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() && + project->variables()["OBJECTS"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) { + createLdObjectScriptFile(var("QMAKE_LINK_OBJECT_SCRIPT"), project->variables()["OBJECTS"]); + objectsLinkLine = var("QMAKE_LINK_OBJECT_SCRIPT"); + } else { + objectsLinkLine = "$(OBJECTS)"; + } + t << "OBJECTS = " << varList("OBJECTS") << endl; + t << "FORMS = " << varList("FORMS") << endl; + t << "UICDECLS = " << varList("UICDECLS") << endl; + t << "UICIMPLS = " << varList("UICIMPLS") << endl; + t << "SRCMOC = " << varList("SRCMOC") << endl; + TQString objmocLinkLine; + if (!project->variables()["QMAKE_APP_OR_DLL"].isEmpty() && + project->variables()["OBJMOC"].count() > var("QMAKE_LINK_OBJECT_MAX").toUInt()) { + createLdObjectScriptFile(var("QMAKE_LINK_OBJMOC_SCRIPT"), project->variables()["OBJMOC"]); + objmocLinkLine = var("QMAKE_LINK_OBJMOC_SCRIPT"); + } else { + objmocLinkLine = "$(OBJMOC)"; + } + t << "OBJMOC = " << varList("OBJMOC") << endl; + TQString extraCompilerDeps; + if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) { + t << "OBJCOMP = " << varList("OBJCOMP") << endl; + extraCompilerDeps += " $(OBJCOMP) "; + + TQStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(TQStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) { + TQStringList &vars = project->variables()[(*compit) + ".variables"]; + for(TQStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) { + TQStringList vals = project->variables()[(*varit)]; + if(!vals.isEmpty()) + t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl; + } + } + } + + t << "DIST = " << varList("DISTFILES") << endl; + t << "TARGET = "; + if( !project->variables()[ "DESTDIR" ].isEmpty() ) + t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); + else + t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); + t << endl; + t << endl; + + t << "####### Implicit rules" << endl << endl; + t << ".SUFFIXES: .cpp .cxx .cc .C .c" << endl << endl; + t << ".cpp.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cxx.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".cc.o:\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c.o:\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + + t << "####### Build rules" << endl << endl; + t << "all: " << "$(OBJECTS_DIR) " << "$(MOC_DIR) " << varGlue("ALL_DEPS",""," "," ") << "$(TARGET)" << endl << endl; + t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " + << extraCompilerDeps << var("POST_TARGETDEPS"); + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "\n\t" << "$(LINK) $(LFLAGS) -o $(TARGET) " << objectsLinkLine << " " << objmocLinkLine << " $(LIBS)"; + } else { + t << "\n\t" << "$(LIB) $(TARGET) " << objectsLinkLine << " " << objmocLinkLine; + } + t << extraCompilerDeps; + if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { + TQStringList dlldirs = project->variables()["DLLDESTDIR"]; + for ( TQStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + t << "\n\t" << "$(COPY_FILE) \"$(TARGET)\" " << *dlldir; + } + } + TQString targetfilename = project->variables()["TARGET"].first(); + if(project->isActiveConfig("activeqt")) { + TQString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + if ( project->isActiveConfig("dll")) { + t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); + } else { + t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << "-$(TARGET) -regserver"; + } + } + t << endl << endl; + + if(!project->variables()["RC_FILE"].isEmpty()) { + t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" + << var("QMAKE_RC") << " -i " << var("RC_FILE") << " -o " << var("RC_FILE").replace(TQRegExp("\\.rc"),".o") << " --include-dir=" << TQFileInfo(var("RC_FILE")).dirPath() << endl << endl; + } + project->variables()["RES_FILE"].first().replace(TQRegExp("\\.rc"),".o"); + + t << "mocables: $(SRCMOC)" << endl << endl; + + t << "$(OBJECTS_DIR):" << "\n\t" + << "@if not exist $(OBJECTS_DIR) $(MKDIR) $(OBJECTS_DIR)" << endl << endl; + + t << "$(MOC_DIR):" << "\n\t" + << "@if not exist $(MOC_DIR) $(MKDIR) $(MOC_DIR)" << endl << endl; + + writeMakeQmake(t); + + t << "dist:" << "\n\t" + << "$(ZIP) " << var("PROJECT") << ".zip " + << var("PROJECT") << ".pro $(SOURCES) $(HEADERS) $(DIST) $(FORMS)" << endl << endl; + + t << "clean:" + << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(TQRegExp("\\.obj"),".o") + << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","").replace(TQRegExp("\\.obj"),".o") + << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << "\n\t-$(DEL_FILE) $(TARGET)" + << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ",""); + if ( project->isActiveConfig("activeqt")) { + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl"); + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + } + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", ""); + + // user defined targets + TQStringList::Iterator it; + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + + for(it = qut.begin(); it != qut.end(); ++it) { + TQString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), deps; + if(targ.isEmpty()) + targ = (*it); + TQStringList &deplist = project->variables()[(*it) + ".depends"]; + for(TQStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { + TQString dep = var((*dep_it) + ".target"); + if(dep.isEmpty()) + dep = (*dep_it); + deps += " " + dep; + } + t << "\n\n" << targ << ":" << deps << "\n\t" + << cmd; + } + + t << endl << endl; + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + TQString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); + TQString tmp_dep = project->variables()[(*it) + ".depends"].join(" "); + TQStringList &vars = project->variables()[(*it) + ".variables"]; + if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out, cmd = tmp_cmd, deps; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + cmd.replace("${QMAKE_FILE_BASE}", fi.baseName()); + cmd.replace("${QMAKE_FILE_OUT}", out); + cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + for(TQStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3) + cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")"); + if(!tmp_dep.isEmpty()) { + char buff[256]; + TQString dep_cmd = tmp_dep; + dep_cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) { + while(!feof(proc)) { + int read_in = int(fread(buff, 1, 255, proc)); + if(!read_in) + break; + int l = 0; + for(int i = 0; i < read_in; i++) { + if(buff[i] == '\n' || buff[i] == ' ') { + deps += " " + TQCString(buff+l, (i - l) + 1); + l = i; + } + } + } + fclose(proc); + } + } + t << out << ": " << in << deps << "\n\t" + << cmd << endl << endl; + } + } + } + t << endl; +} + + +void +MingwMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + /* this should probably not be here, but I'm using it to wrap the .t files */ + if(project->first("TEMPLATE") == "app") + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "lib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "subdirs") { + MakefileGenerator::init(); + if(project->variables()["MAKEFILE"].isEmpty()) + project->variables()["MAKEFILE"].append("Makefile"); + if(project->variables()["QMAKE"].isEmpty()) + project->variables()["QMAKE"].append("qmake"); + return; + } + + if(project->isEmpty("QMAKE_INSTALL_FILE")) + project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)"); + if(project->isEmpty("QMAKE_INSTALL_DIR")) + project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)"); + + bool is_qt = (project->first("TARGET") == "qt"TQTDLL_POSTFIX || project->first("TARGET") == "tqt-mt"TQTDLL_POSTFIX); + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + // LIBS defined in Profile comes first for gcc + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + + TQString targetfilename = project->variables()["TARGET"].first(); + TQStringList &configs = project->variables()["CONFIG"]; + + if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) + project->variables()["DEFINES"].append("QT_DLL"); + + if (project->isActiveConfig("qt_dll")) + if (configs.findIndex("qt") == -1) + configs.append("qt"); + + if ( project->isActiveConfig("qt") ) { + if ( project->isActiveConfig( "plugin" ) ) { + project->variables()["CONFIG"].append("dll"); + if(project->isActiveConfig("qt")) + project->variables()["DEFINES"].append("QT_PLUGIN"); + } + if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && + ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || + project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || + (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { + project->variables()["QMAKE_QT_DLL"].append("1"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) + project->variables()["CONFIG"].append("dll"); + } + if ( project->isActiveConfig("thread") ) { + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_THREAD"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_THREAD"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_THREAD"]; + } + if ( project->isActiveConfig("accessibility" ) ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); + if ( project->isActiveConfig("tablet") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); + } + + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["CONFIG"].remove("staticlib"); + project->variables()["QMAKE_APP_OR_DLL"].append("1"); + } else { + project->variables()["CONFIG"].append("staticlib"); + } + + if ( project->isActiveConfig("warn_off") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; + } else if ( project->isActiveConfig("warn_on") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; + } + + if ( project->isActiveConfig("debug") ) { + if ( project->isActiveConfig("thread") ) { + // use the DLL RT even here + if ( project->variables()["DEFINES"].contains("QT_DLL") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; + } else { + if ( project->isActiveConfig("thread") ) { + if ( project->variables()["DEFINES"].contains("QT_DLL") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; + } + + if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; + + if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) + project->variables()["CONFIG"].append("windows"); + + if ( project->isActiveConfig("qt") ) { + project->variables()["CONFIG"].append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + if ( !project->isActiveConfig("debug") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { + project->variables()["DEFINES"].append("QT_MAKEDLL"); + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; + } + } else { + + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); + if ( hver == -1 ) + hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "tqt-mt"); + if(hver != -1) { + TQString ver; + ver.sprintf("-lqt%s" TQTDLL_POSTFIX "%d", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + TQStringList &libs = project->variables()["QMAKE_LIBS"]; +// @@@HGTODO maybe we must change the replace regexp if we understand what's going on + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(TQRegExp("-lqt(-mt)?"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "-lqaxserver"; + if ( project->isActiveConfig( "dll" ) ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + + // QMAKE_LIBS_QT_ENTRY should be first on the link line as it needs qt + project->variables()["QMAKE_LIBS"].remove(project->variables()["QMAKE_LIBS_QT_ENTRY"].first()); + project->variables()["QMAKE_LIBS"].prepend(project->variables()["QMAKE_LIBS_QT_ENTRY"].first()); + + } + } + + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append( + TQStringList::split('.',project->first("VERSION")).join("") + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } else { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append(".exe"); + } else { + project->variables()["TARGET_EXT"].append(".a"); + project->variables()["QMAKE_LFLAGS"].append("-static"); + if(project->variables()["TARGET"].first().left(3) != "lib") + project->variables()["TARGET"].first().prepend("lib"); + } + } + + if ( project->isActiveConfig("windows") ) { + if ( project->isActiveConfig("console") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } else { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; + } + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } + + if ( project->isActiveConfig("exceptions") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; + } + + if ( project->isActiveConfig("rtti") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; + } + + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + + // add -L libs to libdir + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for ( TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ) { + if ( (*libit).startsWith( "-L" ) ) { + project->variables()["QMAKE_LIBDIR"] += (*libit).mid(2); + libit = libs.remove( libit ); + } else { + ++libit; + } + } + + project->variables()["QMAKE_FILETAGS"] += TQStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + TQStringList &l = project->variables()["QMAKE_FILETAGS"]; + TQStringList::Iterator it; + for(it = l.begin(); it != l.end(); ++it) { + TQStringList &gdmf = project->variables()[(*it)]; + for(TQStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) + (*inner) = Option::fixPathToTargetOS((*inner), FALSE); + } + + if ( project->isActiveConfig("dll") ) { + TQString destDir = ""; + if (!project->first("DESTDIR").isEmpty()) + destDir = project->first("DESTDIR") + Option::dir_sep; + project->variables()["QMAKE_LFLAGS"].append(TQString("-Wl,--out-implib,") + + destDir + "lib" + project->first("TARGET") + ".a"); + } + + if ( !project->variables()["DEF_FILE"].isEmpty() ) + project->variables()["QMAKE_LFLAGS"].append(TQString("-Wl,") + project->first("DEF_FILE")); +// if(!project->isActiveConfig("incremental")) +// project->variables()["QMAKE_LFLAGS"].append(TQString("/incremental:no")); + +#if 0 + if ( !project->variables()["VERSION"].isEmpty() ) { + TQString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + TQString major = version.left( firstDot ); + TQString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); + } +#endif + + if ( !project->variables()["RC_FILE"].isEmpty()) { + if ( !project->variables()["RES_FILE"].isEmpty()) { + fprintf(stderr, "Both .rc and .res file specified.\n"); + fprintf(stderr, "Please specify one of them, not both."); + exit(666); + } + project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; + project->variables()["RES_FILE"].first().replace(".rc",".o"); + project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; + project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"]; + } + + if ( !project->variables()["RES_FILE"].isEmpty()) + project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; + + MakefileGenerator::init(); + + if ( !project->variables()["VERSION"].isEmpty()) { + TQStringList l = TQStringList::split('.', project->first("VERSION")); + project->variables()["VER_MAJ"].append(l[0]); + project->variables()["VER_MIN"].append(l[1]); + } + + if(project->isActiveConfig("dll")) { + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") +"lib" + project->first("TARGET") + ".a"); + } + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + if(tmp_out.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1) + project->variables()["OBJCOMP"] += out; + } + } + } +} + +void +MingwMakefileGenerator::writeSubDirs(TQTextStream &t) +{ + TQString qs ; + TQTextStream ts (&qs, IO_WriteOnly) ; + Win32MakefileGenerator::writeSubDirs( ts ) ; + TQRegExp rx("(\\n\\tcd [^\\n\\t]+)(\\n\\t.+)\\n\\t@cd ..") ; + rx.setMinimal(TRUE); + int pos = 0 ; + while ( -1 != (pos = rx.search( qs, pos))) + { + TQString qsMatch = rx.cap(2); + qsMatch.replace("\n\t"," && \\\n\t"); + qs.replace(pos+rx.cap(1).length(), rx.cap(2).length(), qsMatch ); + pos += (rx.cap(1).length()+qsMatch.length()); + } + t << qs ; +} diff --git a/qmake/generators/win32/mingw_make.h b/qmake/generators/win32/mingw_make.h new file mode 100644 index 000000000..6058d7d13 --- /dev/null +++ b/qmake/generators/win32/mingw_make.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Definition of MingwMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __MINGW_MAKE_H__ +#define __MINGW_MAKE_H__ + +#include "winmakefile.h" + +class MingwMakefileGenerator : public Win32MakefileGenerator +{ + bool init_flag; + void writeMingwParts(TQTextStream &); + void writeSubDirs(TQTextStream &t) ; + + bool writeMakefile(TQTextStream &); + void init(); + + virtual bool findLibraries(); + +public: + MingwMakefileGenerator(TQMakeProject *p); + ~MingwMakefileGenerator(); + +}; + +inline MingwMakefileGenerator::~MingwMakefileGenerator() +{ } + +#endif /* __MINGW_MAKE_H__ */ diff --git a/qmake/generators/win32/msvc_dsp.cpp b/qmake/generators/win32/msvc_dsp.cpp new file mode 100644 index 000000000..8534d6908 --- /dev/null +++ b/qmake/generators/win32/msvc_dsp.cpp @@ -0,0 +1,1145 @@ +/**************************************************************************** +** +** Implementation of DspMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "msvc_dsp.h" +#include "option.h" +#include <qdir.h> +#include <qregexp.h> +#include <stdlib.h> +#include <time.h> + +DspMakefileGenerator::DspMakefileGenerator(TQMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +DspMakefileGenerator::writeMakefile(TQTextStream &t) +{ + if(!project->variables()["QMAKE_FAILED_RETQUIREMENTS"].isEmpty()) { + /* for now just dump, I need to generated an empty dsp or something.. */ + fprintf(stderr, "Project file not generated because all retquirements not met:\n\t%s\n", + var("QMAKE_FAILED_RETQUIREMENTS").latin1()); + return TRUE; + } + + if(project->first("TEMPLATE") == "vcapp" || + project->first("TEMPLATE") == "vclib") { + return writeDspParts(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeHeader(t); + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +bool +DspMakefileGenerator::writeDspParts(TQTextStream &t) +{ + TQString dspfile; + if ( !project->variables()["DSP_TEMPLATE"].isEmpty() ) { + dspfile = project->first("DSP_TEMPLATE"); + } else { + dspfile = project->first("MSVCDSP_TEMPLATE"); + } + if (dspfile.startsWith("\"") && dspfile.endsWith("\"")) + dspfile = dspfile.mid(1, dspfile.length() - 2); + TQString dspfile_loc = findTemplate(dspfile); + + TQFile file(dspfile_loc); + if(!file.open(IO_ReadOnly)) { + fprintf(stderr, "Cannot open dsp file: %s\n", dspfile.latin1()); + return FALSE; + } + TQTextStream dsp(&file); + + TQString platform = "Win32"; + if ( !project->variables()["QMAKE_PLATFORM"].isEmpty() ) + platform = varGlue("QMAKE_PLATFORM", "", " ", ""); + + // Setup PCH variables + precompH = project->first("PRECOMPILED_HEADER"); + TQString namePCH = TQFileInfo(precompH).fileName(); + usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + if (usePCH) { + // Created files + TQString origTarget = project->first("QMAKE_ORIG_TARGET"); + origTarget.replace(TQRegExp("-"), "_"); + precompObj = "\"$(IntDir)\\" + origTarget + Option::obj_ext + "\""; + precompPch = "\"$(IntDir)\\" + origTarget + ".pch\""; + // Add PRECOMPILED_HEADER to HEADERS + if (!project->variables()["HEADERS"].contains(precompH)) + project->variables()["HEADERS"] += precompH; + // Add precompile compiler options + project->variables()["PRECOMPILED_FLAGS_REL"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" "; + project->variables()["PRECOMPILED_FLAGS_DEB"] = "/Yu\"" + namePCH + "\" /FI\"" + namePCH + "\" "; + // Return to variable pool + project->variables()["PRECOMPILED_OBJECT"] = precompObj; + project->variables()["PRECOMPILED_PCH"] = precompPch; + } + int rep; + TQString line; + while ( !dsp.eof() ) { + line = dsp.readLine(); + while((rep = line.find(TQRegExp("\\$\\$[a-zA-Z0-9_-]*"))) != -1) { + TQString torep = line.mid(rep, line.find(TQRegExp("[^\\$a-zA-Z0-9_-]"), rep) - rep); + TQString variable = torep.right(torep.length()-2); + + t << line.left(rep); //output the left side + line = line.right(line.length() - (rep + torep.length())); //now past the variable + if(variable == "MSVCDSP_SOURCES") { + if(project->variables()["SOURCES"].isEmpty()) + continue; + + TQString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( TQRegExp( "\\..*$" ), "" ) + " "; + + TQStringList list = project->variables()["SOURCES"] + project->variables()["DEF_FILE"]; + if(!project->isActiveConfig("flat")) + list.sort(); + TQStringList::Iterator it; + for( it = list.begin(); it != list.end(); ++it) { + beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + if (usePCH && (*it).endsWith(".c")) + t << "# SUBTRACT CPP /FI\"" << namePCH << "\" /Yu\"" << namePCH << "\" /Fp" << endl; + if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) { + TQString base = (*it); + base.replace(TQRegExp("\\..*$"), "").upper(); + base.replace(TQRegExp("[^a-zA-Z]"), "_"); + + TQString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" + "\t" + mocpath + findMocSource((*it)) + " -o " + + (*it) + "\n\n" "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" + << build << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } + endGroups(t); + } else if(variable == "MSVCDSP_IMAGES") { + if(project->variables()["IMAGES"].isEmpty()) + continue; + t << "# Begin Source File\n\nSOURCE=" << project->first("QMAKE_IMAGE_COLLECTION") << endl; + t << "# End Source File" << endl; + } else if(variable == "MSVCDSP_HEADERS") { + if(project->variables()["HEADERS"].isEmpty()) + continue; + + TQStringList list = project->variables()["HEADERS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl << endl; + TQString compilePCH; + TQStringList customDependencies; + TQString createMOC; + TQString buildCmdsR, buildCmdsD; + TQString buildCmds = "\nBuildCmds= \\\n"; + // Create unique baseID + TQString base = (*it); + { + base.replace(TQRegExp("\\..*$"), "").upper(); + base.replace(TQRegExp("[^a-zA-Z]"), "_"); + } + if (usePCH && precompH.endsWith(*it)) { + TQString basicBuildCmd = TQString("\tcl.exe /TP /W3 /FD /c /D \"WIN32\" /Yc /Fp\"%1\" /Fo\"%2\" %3 %4 %5 %6 %7 %8 %9 /D \"") + .arg(precompPch) + .arg(precompObj) + .arg(var("MSVCDSP_INCPATH")) + .arg(var("MSVCDSP_DEFINES")) + .arg(var("MSVCDSP_CXXFLAGS")); + buildCmdsR = basicBuildCmd + .arg("/D \"NDEBUG\"") + .arg(var("QMAKE_CXXFLAGS_RELEASE")) + .arg(var("MSVCDSP_MTDEF")) + .arg(var("MSVCDSP_RELDEFS")); + buildCmdsD = basicBuildCmd + .arg("/D \"_DEBUG\" /Od") + .arg(var("QMAKE_CXXFLAGS_DEBUG")) + .arg(var("MSVCDSP_MTDEFD")) + .arg(var("MSVCDSP_DEBUG_OPT")); + if (project->first("TEMPLATE") == "vcapp") { // App + buildCmdsR += var("MSVCDSP_WINCONDEF"); + buildCmdsD += var("MSVCDSP_WINCONDEF"); + } else if (project->isActiveConfig("dll")) { // Dll + buildCmdsR += "_WINDOWS\" /D \"_USRDLL"; + buildCmdsD += "_WINDOWS\" /D \"_USRDLL"; + } else { // Lib + buildCmdsR += "_LIB"; + buildCmdsD += "_LIB"; + } + buildCmdsR += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n"; + buildCmdsD += "\" /Fd\"$(IntDir)\\\\\" " + (*it) + " \\\n"; + + compilePCH = precompPch + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n"; + + TQStringList &tmp = findDependencies(precompH); + if(!tmp.isEmpty()) // Got Deps for PCH + customDependencies += tmp; + } + if (project->isActiveConfig("moc") && !findMocDestination((*it)).isEmpty()) { + TQString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( TQRegExp( "\\..*$" ), "" ) + " "; + buildCmds += "\t" + mocpath + (*it) + " -o " + findMocDestination((*it)) + " \\\n"; + createMOC = "\"" + findMocDestination((*it)) + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n $(BuildCmds)\n\n"; + customDependencies += "\"$(QTDIR)\\bin\\moc.exe\""; + } + if (!createMOC.isEmpty() || !compilePCH.isEmpty()) { + bool doMOC = !createMOC.isEmpty(); + bool doPCH = !compilePCH.isEmpty(); + TQString build = "\n\n# Begin Custom Build - "+ + TQString(doMOC?"Moc'ing ":"") + + TQString((doMOC&&doPCH)?" and ":"") + + TQString(doPCH?"Creating PCH cpp from ":"") + + (*it) + "...\nInputPath=.\\" + (*it) + "\n\n" + + buildCmds + "%1\n" + + createMOC + + compilePCH + + "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=" << valGlue(customDependencies, "\"", "\" \"", "\"") << endl << endl; + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build.arg(buildCmdsR) + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build.arg(buildCmdsD) + << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_FORMSOURCES" || variable == "MSVCDSP_FORMHEADERS") { + if(project->variables()["FORMS"].isEmpty()) + continue; + + TQString uiSourcesDir; + TQString uiHeadersDir; + if(!project->variables()["UI_DIR"].isEmpty()) { + uiSourcesDir = project->first("UI_DIR"); + uiHeadersDir = project->first("UI_DIR"); + } else { + if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) + uiSourcesDir = project->first("UI_SOURCES_DIR"); + else + uiSourcesDir = ""; + if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) + uiHeadersDir = project->first("UI_HEADERS_DIR"); + else + uiHeadersDir = ""; + } + + TQStringList list = project->variables()["FORMS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + TQString ext = variable == "MSVCDSP_FORMSOURCES" ? ".cpp" : ".h"; + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + TQString base = (*it); + int dot = base.findRev("."); + base.replace( dot, base.length() - dot, ext ); + TQString fname = base; + + int lbs = fname.findRev( "\\" ); + TQString fpath; + if ( lbs != -1 ) + fpath = fname.left( lbs + 1 ); + fname = fname.right( fname.length() - lbs - 1 ); + + if ( ext == ".cpp" && !uiSourcesDir.isEmpty() ) + fname.prepend(uiSourcesDir); + else if ( ext == ".h" && !uiHeadersDir.isEmpty() ) + fname.prepend(uiHeadersDir); + else + fname = base; +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname + << "\n# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_TRANSLATIONS" ) { + if(project->variables()["TRANSLATIONS"].isEmpty()) + continue; + + t << "# Begin Group \"Translations\"\n"; + t << "# Prop Default_Filter \"ts\"\n"; + + TQStringList list = project->variables()["TRANSLATIONS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + TQString sify = *it; + sify.replace('/', '\\' ); + TQString base = (*it); + base.replace(TQRegExp("\\..*$"), "").upper(); + base.replace(TQRegExp("[^a-zA-Z]"), "_"); + +// beginGroupForFile(sify, t); + t << "# Begin Source File\n\nSOURCE=" << sify << endl; + t << "\n# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if (variable == "MSVCDSP_MOCSOURCES" && project->isActiveConfig("moc")) { + if ( project->variables()["SRCMOC"].isEmpty()) + continue; + + TQString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( TQRegExp( "\\..*$" ), "" ) + " "; + + TQStringList list = project->variables()["SRCMOC"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + if ( project->isActiveConfig("moc") && (*it).endsWith(Option::cpp_moc_ext)) { + TQString base = (*it); + base.replace(TQRegExp("\\..*$"), "").upper(); + base.replace(TQRegExp("[^a-zA-Z]"), "_"); + + TQString build = "\n\n# Begin Custom Build - Moc'ing " + findMocSource((*it)) + + "...\n" "InputPath=.\\" + (*it) + "\n\n" "\"" + (*it) + "\"" + " : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n" + "\t" + mocpath + findMocSource((*it)) + " -o " + + (*it) + "\n\n" "# End Custom Build\n\n"; + + t << "USERDEP_" << base << "=\".\\" << findMocSource((*it)) << "\" \"$(QTDIR)\\bin\\moc.exe\"" << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" + << build << "!ENDIF " << endl << endl; + } + t << "# End Source File" << endl; + } +// endGroups(t); + } else if(variable == "MSVCDSP_PICTURES") { + if(project->variables()["IMAGES"].isEmpty()) + continue; + + t << "# Begin Group \"Images\"\n" + << "# Prop Default_Filter \"png jpeg bmp xpm\"\n"; + + TQStringList list = project->variables()["IMAGES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + TQStringList::Iterator it; + + // dump the image list to a file UIC can read. + TQFile f( "images.tmp" ); + f.open( IO_WriteOnly ); + TQTextStream ts( &f ); + for( it = list.begin(); it != list.end(); ++it ) + ts << " " << *it; + f.close(); + + // create an output step for images not more than once + bool imagesBuildDone = FALSE; + for( it = list.begin(); it != list.end(); ++it ) { +// beginGroupForFile((*it), t); + t << "# Begin Source File\n\nSOURCE=" << (*it) << endl; + + TQString base = (*it); + TQString uicpath = var("QMAKE_UIC"); + uicpath = uicpath.replace(TQRegExp("\\..*$"), "") + " "; + + if ( !imagesBuildDone ) { + imagesBuildDone = TRUE; + TQString build = "\n\n# Begin Custom Build - Creating image collection...\n" + "InputPath=.\\" + base + "\n\n"; + + build += "\"" + project->first("QMAKE_IMAGE_COLLECTION") + "\" : $(SOURCE) \"$(INTDIR)\" \"$(OUTDIR)\"\n"; + build += "\t" + uicpath + "-embed " + project->first("QMAKE_ORIG_TARGET") + " -f images.tmp -o " + + project->first("QMAKE_IMAGE_COLLECTION") + "\n\n"; + build.append("# End Custom Build\n\n"); + + t << "USERDEP_" << base << "="; + TQStringList::Iterator it2 = list.begin(); + while ( it2 != list.end() ) { + t << "\"" << (*it2) << "\""; + it2++; + if ( it2 != list.end() ) + t << "\\\n"; + } + t << endl << endl; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - Win32 Debug\"" << build + << "!ENDIF \n\n" << endl; + } + + t << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_FORMS") { + if(project->variables()["FORMS"].isEmpty()) + continue; + + t << "# Begin Group \"Forms\"\n" + << "# Prop Default_Filter \"ui\"\n"; + + TQString uicpath = var("QMAKE_UIC"); + uicpath = uicpath.replace(TQRegExp("\\..*$"), "") + " "; + TQString mocpath = var( "QMAKE_MOC" ); + mocpath = mocpath.replace( TQRegExp( "\\..*$" ), "" ) + " "; + + TQStringList list = project->variables()["FORMS"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + TQString base = (*it); +// beginGroupForFile(base, t); + t << "# Begin Source File\n\nSOURCE=" << base << endl; + + TQString fname = base; + fname.replace(".ui", ""); + int lbs = fname.findRev( "\\" ); + TQString fpath; + if ( lbs != -1 ) + fpath = fname.left( lbs + 1 ); + fname = fname.right( fname.length() - lbs - 1 ); + + TQString mocFile; + if(!project->variables()["MOC_DIR"].isEmpty()) + mocFile = project->first("MOC_DIR"); + else + mocFile = fpath; + + TQString uiSourcesDir; + TQString uiHeadersDir; + if(!project->variables()["UI_DIR"].isEmpty()) { + uiSourcesDir = project->first("UI_DIR"); + uiHeadersDir = project->first("UI_DIR"); + } else { + if ( !project->variables()["UI_SOURCES_DIR"].isEmpty() ) + uiSourcesDir = project->first("UI_SOURCES_DIR"); + else + uiSourcesDir = fpath; + if ( !project->variables()["UI_HEADERS_DIR"].isEmpty() ) + uiHeadersDir = project->first("UI_HEADERS_DIR"); + else + uiHeadersDir = fpath; + } + + t << "USERDEP_" << base << "=\"$(QTDIR)\\bin\\moc.exe\" \"$(QTDIR)\\bin\\uic.exe\"" << endl << endl; + + TQString build = "\n\n# Begin Custom Build - Uic'ing " + base + "...\n" + "InputPath=.\\" + base + "\n\n" "BuildCmds= \\\n\t" + uicpath + base + + " -o " + uiHeadersDir + fname + ".h \\\n" "\t" + uicpath + base + + " -i " + fname + ".h -o " + uiSourcesDir + fname + ".cpp \\\n" + "\t" + mocpath + " " + uiHeadersDir + + fname + ".h -o " + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + " \\\n"; + + build.append("\n\"" + uiHeadersDir + fname + ".h\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n" + "\"" + uiSourcesDir + fname + ".cpp\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n" + "\"" + mocFile + Option::h_moc_mod + fname + Option::h_moc_ext + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t$(BuildCmds)\n\n"); + + build.append("# End Custom Build\n\n"); + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build + << "!ENDIF \n\n" << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_LEXSOURCES") { + if(project->variables()["LEXSOURCES"].isEmpty()) + continue; + + t << "# Begin Group \"Lexables\"\n" + << "# Prop Default_Filter \"l\"\n"; + + TQString lexpath = var("QMAKE_LEX") + varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " "; + + TQStringList list = project->variables()["LEXSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + TQString fname = (*it); +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname << endl; + fname.replace(".l", Option::lex_mod + Option::cpp_ext.first()); + + TQString build = "\n\n# Begin Custom Build - Lex'ing " + (*it) + "...\n" + "InputPath=.\\" + (*it) + "\n\n" + "\"" + fname + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t" + lexpath + (*it) + "\\\n" + "\tdel " + fname + "\\\n" + "\tcopy lex.yy.c " + fname + "\n\n" + + "# End Custom Build\n\n"; + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build + << "!ENDIF \n\n" << build + + << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if(variable == "MSVCDSP_YACCSOURCES") { + if(project->variables()["YACCSOURCES"].isEmpty()) + continue; + + t << "# Begin Group \"Yaccables\"\n" + << "# Prop Default_Filter \"y\"\n"; + + TQString yaccpath = var("QMAKE_YACC") + varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " "; + + TQStringList list = project->variables()["YACCSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + TQString fname = (*it); +// beginGroupForFile(fname, t); + t << "# Begin Source File\n\nSOURCE=" << fname << endl; + fname.replace(".y", Option::yacc_mod); + + TQString build = "\n\n# Begin Custom Build - Yacc'ing " + (*it) + "...\n" + "InputPath=.\\" + (*it) + "\n\n" + "\"" + fname + Option::cpp_ext.first() + "\" : \"$(SOURCE)\" \"$(INTDIR)\" \"$(OUTDIR)\"" "\n" + "\t" + yaccpath + (*it) + "\\\n" + "\tdel " + fname + Option::h_ext.first() + "\\\n" + "\tmove y.tab.h " + fname + Option::h_ext.first() + "\n\n" + + "\tdel " + fname + Option::cpp_ext.first() + "\\\n" + "\tmove y.tab.c " + fname + Option::cpp_ext.first() + "\n\n" + + "# End Custom Build\n\n"; + + t << "!IF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Release\"" << build + << "!ELSEIF \"$(CFG)\" == \"" << var("MSVCDSP_PROJECT") << " - " << platform << " Debug\"" << build + << "!ENDIF \n\n" + << "# End Source File" << endl; + } +// endGroups(t); + t << "\n# End Group\n"; + } else if( variable == "MSVCDSP_CONFIGMODE" ) { + if( project->isActiveConfig( "debug" ) ) + t << "Debug"; + else + t << "Release"; + } else if( variable == "MSVCDSP_IDLSOURCES" ) { + TQStringList list = project->variables()["MSVCDSP_IDLSOURCES"]; + if(!project->isActiveConfig("flat")) + list.sort(); + for(TQStringList::Iterator it = list.begin(); it != list.end(); ++it) { + t << "# Begin Source File" << endl << endl; + t << "SOURCE=" << (*it) << endl; + t << "# PROP Exclude_From_Build 1" << endl; + t << "# End Source File" << endl << endl; + } + } + else + t << var(variable); + } + t << line << endl; + } + t << endl; + file.close(); + return TRUE; +} + + + +void +DspMakefileGenerator::init() +{ + if(init_flag) + return; + TQStringList::Iterator it; + init_flag = TRUE; + + const bool thread = project->isActiveConfig("thread"); + + if ( project->isActiveConfig("stl") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; + } + if ( project->isActiveConfig("exceptions") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; + } + if ( project->isActiveConfig("rtti") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; + } + + + /* this should probably not be here, but I'm using it to wrap the .t files */ + if(project->first("TEMPLATE") == "vcapp" ) + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "vclib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + if ( project->variables()["QMAKESPEC"].isEmpty() ) + project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); + + bool is_qt = (project->first("TARGET") == "qt"TQTDLL_POSTFIX || project->first("TARGET") == "tqt-mt"TQTDLL_POSTFIX); + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + TQStringList &configs = project->variables()["CONFIG"]; + if (project->isActiveConfig("shared")) + project->variables()["DEFINES"].append("QT_DLL"); + if (project->isActiveConfig("qt_dll")) + if(configs.findIndex("qt") == -1) configs.append("qt"); + if ( project->isActiveConfig("qtopia") ) { + if(configs.findIndex("qtopialib") == -1) + configs.append("qtopialib"); + if(configs.findIndex("qtopiainc") == -1) + configs.append("qtopiainc"); + } + if ( project->isActiveConfig("qt") ) { + if ( project->isActiveConfig( "plugin" ) ) { + project->variables()["CONFIG"].append("dll"); + project->variables()["DEFINES"].append("QT_PLUGIN"); + } + if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && + ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || + project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || + (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { + project->variables()["QMAKE_QT_DLL"].append("1"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) + project->variables()["CONFIG"].append("dll"); + } + } + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["CONFIG"].remove("staticlib"); + project->variables()["QMAKE_APP_OR_DLL"].append("1"); + } else { + project->variables()["CONFIG"].append("staticlib"); + } + + if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) { + project->variables()["CONFIG"].append("windows"); + } + if ( !project->variables()["VERSION"].isEmpty() ) { + TQString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + TQString major = version.left( firstDot ); + TQString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["MSVCDSP_VERSION"].append( "/VERSION:" + major + "." + minor ); + } + + if ( project->isActiveConfig("qtopiainc") ) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"]; + if ( project->isActiveConfig("qtopialib") ) { + if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA")) + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"]; + } + + if ( project->isActiveConfig("qt") ) { + project->variables()["CONFIG"].append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + project->variables()["DEFINES"].append("QT_MAKEDLL"); + project->variables()["QMAKE_LFLAGS"].append("/base:\"0x39D00000\""); + } + } else { + if( thread ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); + if ( hver == -1 ) + hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "tqt-mt"); + if(hver != -1) { + TQString ver; + ver.sprintf("qt%s" TQTDLL_POSTFIX "%d.lib", (thread ? "-mt" : ""), hver); + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(TQRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + + if ( project->isActiveConfig("debug") ) { + if ( !project->first("OBJECTS_DIR").isEmpty() ) + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = project->first("OBJECTS_DIR"); + else + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; + project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; + if ( !project->first("DESTDIR").isEmpty() ) + project->variables()["MSVCDSP_TARGETDIRDEB"] = project->first("DESTDIR"); + else + project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; + project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; + } else { + if ( !project->first("OBJECTS_DIR").isEmpty() ) + project->variables()["MSVCDSP_OBJECTSDIRREL"] = project->first("OBJECTS_DIR"); + else + project->variables()["MSVCDSP_OBJECTSDIRREL"] = "Release"; + project->variables()["MSVCDSP_OBJECTSDIRDEB"] = "Debug"; + if ( !project->first("DESTDIR").isEmpty() ) + project->variables()["MSVCDSP_TARGETDIRREL"] = project->first("DESTDIR"); + else + project->variables()["MSVCDSP_TARGETDIRREL"] = "Release"; + project->variables()["MSVCDSP_TARGETDIRDEB"] = "Debug"; + } + + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + if ( thread ) { + if(project->isActiveConfig("qt")) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); + if ( project->isActiveConfig("dll") || project->first("TARGET") == "qtmain" + || !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; + project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; + } else { + // YES we want to use the DLL even in a static build + project->variables()["MSVCDSP_MTDEFD"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; + project->variables()["MSVCDSP_MTDEF"] += project->variables()["QMAKE_CXXFLAGS_MT"]; + } + if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt + && project->first("TARGET") != "qtmain" ) + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); + } + + if(project->isActiveConfig("qt")) { + if ( project->isActiveConfig("accessibility" ) ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); + if ( project->isActiveConfig("tablet") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); + } + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + TQString ver_xyz(project->first("VERSION")); + ver_xyz.replace(".", ""); + project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } else { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) + project->variables()["TARGET_EXT"].append(".exe"); + else + project->variables()["TARGET_EXT"].append(".lib"); + } + + if ( project->isActiveConfig("windows") ) { + if ( project->isActiveConfig("console") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } else { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; + } + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } + + project->variables()["MSVCDSP_VER"] = "6.00"; + project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /ZI"; + + if(!project->isActiveConfig("incremental")) { + project->variables()["QMAKE_LFLAGS"].append(TQString("/incremental:no")); + if ( is_qt ) + project->variables()["MSVCDSP_DEBUG_OPT"] = "/GZ /Zi"; + } + + TQString msvcdsp_project; + if ( project->variables()["TARGET"].count() ) + msvcdsp_project = project->variables()["TARGET"].first(); + + TQString targetfilename = project->variables()["TARGET"].first(); + project->variables()["TARGET"].first() += project->first("TARGET_EXT"); + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + project->variables()["QMAKE_FILETAGS"] += TQStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + TQStringList &l = project->variables()["QMAKE_FILETAGS"]; + for(it = l.begin(); it != l.end(); ++it) { + TQStringList &gdmf = project->variables()[(*it)]; + for(TQStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) + (*inner) = Option::fixPathToTargetOS((*inner), FALSE); + } + + MakefileGenerator::init(); + if ( msvcdsp_project.isEmpty() ) + msvcdsp_project = Option::output.name(); + + msvcdsp_project = msvcdsp_project.right( msvcdsp_project.length() - msvcdsp_project.findRev( "\\" ) - 1 ); + msvcdsp_project = msvcdsp_project.left( msvcdsp_project.findRev( "." ) ); + msvcdsp_project.replace("-", ""); + + project->variables()["MSVCDSP_PROJECT"].append(msvcdsp_project); + TQStringList &proj = project->variables()["MSVCDSP_PROJECT"]; + + for(it = proj.begin(); it != proj.end(); ++it) + (*it).replace(TQRegExp("\\.[a-zA-Z0-9_]*$"), ""); + + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["MSVCDSP_TEMPLATE"].append("win32app" + project->first( "DSP_EXTENSION" ) ); + if ( project->isActiveConfig("console") ) { + project->variables()["MSVCDSP_CONSOLE"].append("Console"); + project->variables()["MSVCDSP_WINCONDEF"].append("_CONSOLE"); + project->variables()["MSVCDSP_DSPTYPE"].append("0x0103"); + } else { + project->variables()["MSVCDSP_CONSOLE"].clear(); + project->variables()["MSVCDSP_WINCONDEF"].append("_WINDOWS"); + project->variables()["MSVCDSP_DSPTYPE"].append("0x0101"); + } + } else { + if ( project->isActiveConfig("dll") ) { + project->variables()["MSVCDSP_TEMPLATE"].append("win32dll" + project->first( "DSP_EXTENSION" ) ); + } else { + project->variables()["MSVCDSP_TEMPLATE"].append("win32lib" + project->first( "DSP_EXTENSION" ) ); + } + } + + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + + processPrlFiles(); + + // Update -lname to name.lib, + TQStringList &libList = project->variables()["QMAKE_LIBS"]; + for( TQStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) { + TQString s = *stIt; + if( s.startsWith( "-l" ) ) { + stIt = libList.remove( stIt ); + stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" ); + } else if( s.startsWith( "-L" ) ) { + stIt = libList.remove( stIt ); + project->variables()["QMAKE_LIBDIR"].append(TQDir::convertSeparators(s.mid( 2 ))); + } else { + stIt++; + } + } + + project->variables()["MSVCDSP_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + project->variables()["MSVCDSP_LFLAGS" ].append(varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\"")); + project->variables()["MSVCDSP_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; + project->variables()["MSVCDSP_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); + project->variables()["MSVCDSP_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); + + if (!project->variables()["RES_FILE"].isEmpty()) + project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; + + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { + TQString lib = (*libit); + lib.replace(TQRegExp("\""), ""); + project->variables()["MSVCDSP_LIBS"].append(" \"" + lib + "\""); + } + + TQStringList &incs = project->variables()["INCLUDEPATH"]; + for(TQStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + TQString inc = (*incit); + inc.replace("\"", ""); + if(inc.endsWith("\\")) // Remove trailing \'s from paths + inc.truncate(inc.length()-1); + if (inc.startsWith("\"") && inc.endsWith("\"")) + inc = inc.mid(1, inc.length() - 2); + project->variables()["MSVCDSP_INCPATH"].append("/I \"" + inc + "\""); + } + + project->variables()["MSVCDSP_INCPATH"].append("/I \"" + specdir() + "\""); + if ( project->isActiveConfig("qt") ) { + project->variables()["MSVCDSP_RELDEFS"].append("/D \"QT_NO_DEBUG\""); + } else { + project->variables()["MSVCDSP_RELDEFS"].clear(); + } + + TQString dest; + TQString postLinkStep; + TQString copyDllStep; + TQString activeTQtStepPreCopyDll; + TQString activeTQtStepPostCopyDll; + TQString activeTQtStepPreCopyDllDebug; + TQString activeTQtStepPostCopyDllDebug; + TQString activeTQtStepPreCopyDllRelease; + TQString activeTQtStepPostCopyDllRelease; + + if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) + postLinkStep += var("QMAKE_POST_LINK"); + + if ( !project->variables()["DESTDIR"].isEmpty() ) { + project->variables()["TARGET"].first().prepend(project->first("DESTDIR")); + Option::fixPathToTargetOS(project->first("TARGET")); + dest = project->first("TARGET"); + if ( project->first("TARGET").startsWith("$(QTDIR)") ) + dest.replace( "$(QTDIR)", getenv("QTDIR") ); + project->variables()["MSVCDSP_TARGET"].append( + TQString("/out:\"") + dest + "\""); + if ( project->isActiveConfig("dll") ) { + TQString imp = dest; + imp.replace(".dll", ".lib"); + project->variables()["MSVCDSP_TARGET"].append(TQString(" /implib:\"") + imp + "\""); + } + } + if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { + TQStringList dlldirs = project->variables()["DLLDESTDIR"]; + if ( dlldirs.count() ) + copyDllStep += "\t"; + for ( TQStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + copyDllStep += "copy \"$(TargetPath)\" \"" + *dlldir + "\"\t"; + } + } + + if ( project->isActiveConfig("activeqt") ) { + TQString idl = project->variables()["QMAKE_IDL"].first(); + TQString idc = project->variables()["QMAKE_IDC"].first(); + TQString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + project->variables()["MSVCDSP_IDLSOURCES"].append( var("OBJECTS_DIR") + targetfilename + ".idl" ); + if ( project->isActiveConfig( "dll" ) ) { + activeTQtStepPreCopyDll += + "\t" + idc + " %1 -idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" + + "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"; + activeTQtStepPostCopyDll += + "\t" + idc + " %1 /regserver\n"; + + TQString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".dll"; + activeTQtStepPreCopyDllRelease = activeTQtStepPreCopyDll.arg(executable).arg(executable); + activeTQtStepPostCopyDllRelease = activeTQtStepPostCopyDll.arg(executable); + + executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".dll"; + activeTQtStepPreCopyDllDebug = activeTQtStepPreCopyDll.arg(executable).arg(executable); + activeTQtStepPostCopyDllDebug = activeTQtStepPostCopyDll.arg(executable); + } else { + activeTQtStepPreCopyDll += + "\t%1 -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb" + + "\t" + idc + " %2 /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"; + activeTQtStepPostCopyDll += + "\t%1 -regserver\n"; + TQString executable = project->variables()["MSVCDSP_TARGETDIRREL"].first() + "\\" + targetfilename + ".exe"; + activeTQtStepPreCopyDllRelease = activeTQtStepPreCopyDll.arg(executable).arg(executable); + activeTQtStepPostCopyDllRelease = activeTQtStepPostCopyDll.arg(executable); + + executable = project->variables()["MSVCDSP_TARGETDIRDEB"].first() + "\\" + targetfilename + ".exe"; + activeTQtStepPreCopyDllDebug = activeTQtStepPreCopyDll.arg(executable).arg(executable); + activeTQtStepPostCopyDllDebug = activeTQtStepPostCopyDll.arg(executable); + } + + } + + + if ( !postLinkStep.isEmpty() || !copyDllStep.isEmpty() || !activeTQtStepPreCopyDllDebug.isEmpty() || !activeTQtStepPreCopyDllRelease.isEmpty() ) { + project->variables()["MSVCDSP_POST_LINK_DBG"].append( + "# Begin Special Build Tool\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Post Build Step\n" + "PostBuild_Cmds=" + postLinkStep + activeTQtStepPreCopyDllDebug + copyDllStep + activeTQtStepPostCopyDllDebug + "\n" + "# End Special Build Tool\n" ); + project->variables()["MSVCDSP_POST_LINK_REL"].append( + "# Begin Special Build Tool\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Post Build Step\n" + "PostBuild_Cmds=" + postLinkStep + activeTQtStepPreCopyDllRelease + copyDllStep + activeTQtStepPostCopyDllRelease + "\n" + "# End Special Build Tool\n" ); + } + + if ( !project->variables()["SOURCES"].isEmpty() || !project->variables()["RC_FILE"].isEmpty() ) { + project->variables()["SOURCES"] += project->variables()["RC_FILE"]; + } + TQStringList &list = project->variables()["FORMS"]; + for( it = list.begin(); it != list.end(); ++it ) { + if ( TQFile::exists( *it + ".h" ) ) + project->variables()["SOURCES"].append( *it + ".h" ); + } + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCDSP_LIBS"; +} + + +TQString +DspMakefileGenerator::findTemplate(const TQString &file) +{ + TQString ret; + if(!TQFile::exists((ret = file)) && + !TQFile::exists((ret = TQString(Option::mkfile::qmakespec + "/" + file))) && + !TQFile::exists((ret = TQString(getenv("QTDIR")) + "/mkspecs/win32-msvc/" + file)) && + !TQFile::exists((ret = (TQString(getenv("HOME")) + "/.tmake/" + file)))) + return ""; + return ret; +} + + +void +DspMakefileGenerator::processPrlVariable(const TQString &var, const TQStringList &l) +{ + if(var == "QMAKE_PRL_DEFINES") { + TQStringList &out = project->variables()["MSVCDSP_DEFINES"]; + for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + if(out.findIndex((*it)) == -1) + out.append((" /D \"" + *it + "\"")); + } + } else { + MakefileGenerator::processPrlVariable(var, l); + } +} + + +void +DspMakefileGenerator::beginGroupForFile(TQString file, TQTextStream &t, + const TQString& filter) +{ + if(project->isActiveConfig("flat")) + return; + fileFixify(file, TQDir::currentDirPath(), TQDir::currentDirPath(), TRUE); + file = file.section(Option::dir_sep, 0, -2); + if(file.right(Option::dir_sep.length()) != Option::dir_sep) + file += Option::dir_sep; + if(file == currentGroup) + return; + + if(file.isEmpty() || !TQDir::isRelativePath(file)) { + endGroups(t); + return; + } + + TQString tempFile = file; + if(tempFile.startsWith(currentGroup)) + tempFile = tempFile.mid(currentGroup.length()); + int dirSep = currentGroup.findRev( Option::dir_sep ); + + while( !tempFile.startsWith( currentGroup ) && dirSep != -1 ) { + currentGroup.truncate( dirSep ); + dirSep = currentGroup.findRev( Option::dir_sep ); + if ( !tempFile.startsWith( currentGroup ) && dirSep != -1 ) + t << "\n# End Group\n"; + } + if ( !file.startsWith( currentGroup ) ) { + t << "\n# End Group\n"; + currentGroup = ""; + } + + TQStringList dirs = TQStringList::split(Option::dir_sep, file.right( file.length() - currentGroup.length() ) ); + for(TQStringList::Iterator dir_it = dirs.begin(); dir_it != dirs.end(); ++dir_it) { + t << "# Begin Group \"" << (*dir_it) << "\"\n" + << "# Prop Default_Filter \"" << filter << "\"\n"; + } + currentGroup = file; +} + + +void +DspMakefileGenerator::endGroups(TQTextStream &t) +{ + if(project->isActiveConfig("flat")) + return; + else if(currentGroup.isEmpty()) + return; + + TQStringList dirs = TQStringList::split(Option::dir_sep, currentGroup); + for(TQStringList::Iterator dir_it = dirs.end(); dir_it != dirs.begin(); --dir_it) { + t << "\n# End Group\n"; + } + currentGroup = ""; +} + +bool +DspMakefileGenerator::openOutput(TQFile &file) const +{ + TQString outdir; + if(!file.name().isEmpty()) { + if(TQDir::isRelativePath(file.name())) + file.setName(Option::output_dir + file.name()); //pwd when qmake was run + TQFileInfo fi(file); + if(fi.isDir()) + outdir = file.name() + TQDir::separator(); + } + if(!outdir.isEmpty() || file.name().isEmpty()) + file.setName(outdir + project->first("TARGET") + project->first("DSP_EXTENSION")); + if(TQDir::isRelativePath(file.name())) { + TQString ofile; + ofile = file.name(); + int slashfind = ofile.findRev('\\'); + if (slashfind == -1) { + ofile = ofile.replace(TQRegExp("-"), "_"); + } else { + int hypenfind = ofile.find('-', slashfind); + while (hypenfind != -1 && slashfind < hypenfind) { + ofile = ofile.replace(hypenfind, 1, "_"); + hypenfind = ofile.find('-', hypenfind + 1); + } + } + file.setName(Option::fixPathToLocalOS(TQDir::currentDirPath() + Option::dir_sep + ofile)); + } + return Win32MakefileGenerator::openOutput(file); +} diff --git a/qmake/generators/win32/msvc_dsp.h b/qmake/generators/win32/msvc_dsp.h new file mode 100644 index 000000000..99c6a1051 --- /dev/null +++ b/qmake/generators/win32/msvc_dsp.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** Definition of DspMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __MSVC_DSP_H__ +#define __MSVC_DSP_H__ + +#include "winmakefile.h" +#include <qvaluestack.h> + +class DspMakefileGenerator : public Win32MakefileGenerator +{ + TQString currentGroup; + void beginGroupForFile(TQString file, TQTextStream &, const TQString& filter=""); + void endGroups(TQTextStream &); + + bool init_flag; + bool writeDspParts(TQTextStream &); + + bool writeMakefile(TQTextStream &); + TQString findTemplate(const TQString &file); + void init(); + +public: + DspMakefileGenerator(TQMakeProject *p); + ~DspMakefileGenerator(); + + bool openOutput(TQFile &file) const; + +protected: + virtual void processPrlVariable(const TQString &, const TQStringList &); + virtual bool findLibraries(); + + TQString precompH, + precompObj, precompPch; + bool usePCH; +}; + +inline DspMakefileGenerator::~DspMakefileGenerator() +{ } + +inline bool DspMakefileGenerator::findLibraries() +{ return Win32MakefileGenerator::findLibraries("MSVCDSP_LIBS"); } + +#endif /* __MSVC_DSP_H__ */ diff --git a/qmake/generators/win32/msvc_nmake.cpp b/qmake/generators/win32/msvc_nmake.cpp new file mode 100644 index 000000000..d82977f0b --- /dev/null +++ b/qmake/generators/win32/msvc_nmake.cpp @@ -0,0 +1,792 @@ +/**************************************************************************** +** +** Implementation of NmakeMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "msvc_nmake.h" +#include "option.h" +#include <qregexp.h> +#include <qdict.h> +#include <qdir.h> +#include <stdlib.h> +#include <time.h> + +NmakeMakefileGenerator::NmakeMakefileGenerator(TQMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ + +} + +bool +NmakeMakefileGenerator::writeMakefile(TQTextStream &t) +{ + writeHeader(t); + if(!project->variables()["QMAKE_FAILED_RETQUIREMENTS"].isEmpty()) { + { //write the extra unix targets.. + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(TQStringList::ConstIterator it = qut.begin(); it != qut.end(); ++it) + t << *it << " "; + } + t << "all clean:" << "\n\t" + << "@echo \"Some of the retquired modules (" + << var("QMAKE_FAILED_RETQUIREMENTS") << ") are not available.\"" << "\n\t" + << "@echo \"Skipped.\"" << endl << endl; + writeMakeQmake(t); + return TRUE; + } + + if(project->first("TEMPLATE") == "app" || + project->first("TEMPLATE") == "lib") { + writeNmakeParts(t); + return MakefileGenerator::writeMakefile(t); + } + else if(project->first("TEMPLATE") == "subdirs") { + writeSubDirs(t); + return TRUE; + } + return FALSE; +} + +TQStringList +&NmakeMakefileGenerator::findDependencies(const TQString &file) +{ + TQStringList &aList = MakefileGenerator::findDependencies(file); + // Note: The QMAKE_IMAGE_COLLECTION file have all images + // as dependency, so don't add precompiled header then + if (file == project->first("QMAKE_IMAGE_COLLECTION")) + return aList; + for(TQStringList::Iterator it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) { + if(file.endsWith(*it)) { + if(!precompObj.isEmpty() && !aList.contains(precompObj)) + aList += precompObj; + break; + } + } + return aList; +} + +void +NmakeMakefileGenerator::writeNmakeParts(TQTextStream &t) +{ + t << "####### Compiler, tools and options" << endl << endl; + t << "CC = " << var("QMAKE_CC") << endl; + t << "CXX = " << var("QMAKE_CXX") << endl; + t << "LEX = " << var("QMAKE_LEX") << endl; + t << "YACC = " << var("QMAKE_YACC") << endl; + t << "CFLAGS = " << var("QMAKE_CFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "CXXFLAGS = " << var("QMAKE_CXXFLAGS") << " " + << varGlue("PRL_EXPORT_DEFINES","-D"," -D","") << " " + << varGlue("DEFINES","-D"," -D","") << endl; + t << "LEXFLAGS =" << var("QMAKE_LEXFLAGS") << endl; + t << "YACCFLAGS =" << var("QMAKE_YACCFLAGS") << endl; + + t << "INCPATH = "; + TQStringList &incs = project->variables()["INCLUDEPATH"]; + for(TQStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + TQString inc = (*incit); + if (inc.endsWith("\\")) + inc.truncate(inc.length()-1); + if (inc.startsWith("\"") && inc.endsWith("\"")) + inc = inc.mid(1, inc.length() - 2); + t << " -I\"" << inc << "\""; + } + t << " -I\"" << specdir() << "\"" + << endl; + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "LINK = " << var("QMAKE_LINK") << endl; + t << "LFLAGS = " << var("QMAKE_LFLAGS"); + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) + t << " " << varGlue("QMAKE_LIBDIR","/LIBPATH:\"","\" /LIBPATH:\"","\""); + t << endl; + t << "LIBS = "; + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) { + TQString lib = (*libit); + if (lib.endsWith("\\")) + lib.truncate(lib.length()-1); + t << " \"" << lib << "\""; + } + t << endl; + } + else { + t << "LIB = " << var("QMAKE_LIB") << endl; + } + t << "MOC = " << (project->isEmpty("QMAKE_MOC") ? TQString("moc") : + Option::fixPathToTargetOS(var("QMAKE_MOC"), FALSE)) << endl; + t << "UIC = " << (project->isEmpty("QMAKE_UIC") ? TQString("uic") : + Option::fixPathToTargetOS(var("QMAKE_UIC"), FALSE)) << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : + Option::fixPathToTargetOS(var("QMAKE_QMAKE"), FALSE)) << endl; + t << "IDC = " << (project->isEmpty("QMAKE_IDC") ? TQString("idc") : + Option::fixPathToTargetOS(var("QMAKE_IDC"), FALSE)) << endl; + t << "IDL = " << (project->isEmpty("QMAKE_IDL") ? TQString("midl") : + Option::fixPathToTargetOS(var("QMAKE_IDL"), FALSE)) << endl; + t << "ZIP = " << var("QMAKE_ZIP") << endl; + t << "COPY_FILE = " << var("QMAKE_COPY") << endl; + t << "COPY_DIR = " << var("QMAKE_COPY") << endl; + t << "DEL_FILE = " << var("QMAKE_DEL_FILE") << endl; + t << "DEL_DIR = " << var("QMAKE_DEL_DIR") << endl; + t << "MOVE = " << var("QMAKE_MOVE") << endl; + t << "CHK_DIR_EXISTS = " << var("QMAKE_CHK_DIR_EXISTS") << endl; + t << "MKDIR = " << var("QMAKE_MKDIR") << endl; + t << "INSTALL_FILE= " << var("QMAKE_INSTALL_FILE") << endl; + t << "INSTALL_DIR = " << var("QMAKE_INSTALL_DIR") << endl; + t << endl; + + t << "####### Files" << endl << endl; + t << "HEADERS = " << varList("HEADERS") << endl; + t << "SOURCES = " << varList("SOURCES") << endl; + t << "OBJECTS = " << varList("OBJECTS") << endl; + t << "FORMS = " << varList("FORMS") << endl; + t << "UICDECLS = " << varList("UICDECLS") << endl; + t << "UICIMPLS = " << varList("UICIMPLS") << endl; + t << "SRCMOC = " << varList("SRCMOC") << endl; + t << "OBJMOC = " << varList("OBJMOC") << endl; + + TQString extraCompilerDeps; + if(!project->isEmpty("QMAKE_EXTRA_WIN_COMPILERS")) { + t << "OBJCOMP = " << varList("OBJCOMP") << endl; + extraCompilerDeps += " $(OBJCOMP) "; + + TQStringList &comps = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(TQStringList::Iterator compit = comps.begin(); compit != comps.end(); ++compit) { + TQStringList &vars = project->variables()[(*compit) + ".variables"]; + for(TQStringList::Iterator varit = vars.begin(); varit != vars.end(); ++varit) { + TQStringList vals = project->variables()[(*varit)]; + if(!vals.isEmpty()) + t << "QMAKE_COMP_" << (*varit) << " = " << valList(vals) << endl; + } + } + } + + t << "DIST = " << varList("DISTFILES") << endl; + t << "TARGET = "; + if( !project->variables()[ "DESTDIR" ].isEmpty() ) + t << varGlue("TARGET",project->first("DESTDIR"),"",project->first("TARGET_EXT")); + else + t << project->variables()[ "TARGET" ].first() << project->variables()[ "TARGET_EXT" ].first(); + t << endl; + t << endl; + + t << "####### Implicit rules" << endl << endl; + t << ".SUFFIXES: .c"; + TQStringList::Iterator cppit; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << " " << (*cppit); + t << endl << endl; + + if(!project->isActiveConfig("no_batch")) { + // Batchmode doesn't use the non implicit rules QMAKE_RUN_CXX & QMAKE_RUN_CC + project->variables().remove("QMAKE_RUN_CXX"); + project->variables().remove("QMAKE_RUN_CC"); + + TQDict<void> source_directories; + source_directories.insert(".", (void*)1); + TQString directories[] = { TQString("MOC_DIR"), TQString("UI_SOURCES_DIR"), TQString("UI_DIR"), TQString::null }; + for(int y = 0; !directories[y].isNull(); y++) { + TQString dirTemp = project->first(directories[y]); + if (dirTemp.endsWith("\\")) + dirTemp.truncate(dirTemp.length()-1); + if(!dirTemp.isEmpty()) + source_directories.insert(dirTemp, (void*)1); + } + TQString srcs[] = { TQString("SOURCES"), TQString("UICIMPLS"), TQString("SRCMOC"), TQString::null }; + for(int x = 0; !srcs[x].isNull(); x++) { + TQStringList &l = project->variables()[srcs[x]]; + for(TQStringList::Iterator sit = l.begin(); sit != l.end(); ++sit) { + TQString sep = "\\"; + if((*sit).find(sep) == -1) + sep = "/"; + TQString dir = (*sit).section(sep, 0, -2); + if(!dir.isEmpty() && !source_directories[dir]) + source_directories.insert(dir, (void*)1); + } + } + + for(TQDictIterator<void> it(source_directories); it.current(); ++it) { + if(it.currentKey().isEmpty()) + continue; + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << "{" << it.currentKey() << "}" << (*cppit) << "{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t" + << var("QMAKE_RUN_CXX_IMP_BATCH").replace( TQRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl; + t << "{" << it.currentKey() << "}" << ".c{" << var("OBJECTS_DIR") << "}" << Option::obj_ext << "::\n\t" + << var("QMAKE_RUN_CC_IMP_BATCH").replace( TQRegExp( "\\$@" ), var("OBJECTS_DIR") ) << endl << "\t$<" << endl << "<<" << endl << endl; + } + } else { + for(cppit = Option::cpp_ext.begin(); cppit != Option::cpp_ext.end(); ++cppit) + t << (*cppit) << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CXX_IMP") << endl << endl; + t << ".c" << Option::obj_ext << ":\n\t" << var("QMAKE_RUN_CC_IMP") << endl << endl; + } + + t << "####### Build rules" << endl << endl; + t << "all: " << fileFixify(Option::output.name()) << " " << varGlue("ALL_DEPS"," "," "," ") << "$(TARGET)" << endl << endl; + t << "$(TARGET): " << var("PRE_TARGETDEPS") << " $(UICDECLS) $(OBJECTS) $(OBJMOC) " + << extraCompilerDeps << var("POST_TARGETDEPS"); + if(!project->variables()["QMAKE_APP_OR_DLL"].isEmpty()) { + t << "\n\t" << "$(LINK) $(LFLAGS) /OUT:$(TARGET) @<< " << "\n\t " + << "$(OBJECTS) $(OBJMOC) $(LIBS)"; + } else { + t << "\n\t" << "$(LIB) /OUT:$(TARGET) @<<" << "\n\t " + << "$(OBJECTS) $(OBJMOC)"; + } + t << extraCompilerDeps; + t << endl << "<<" << endl; + if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) + t << "\t" << var( "QMAKE_POST_LINK" ) << endl; + if(project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty()) { + TQStringList dlldirs = project->variables()["DLLDESTDIR"]; + for ( TQStringList::Iterator dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + t << "\n\t" << "-$(COPY_FILE) \"$(TARGET)\" " << *dlldir; + } + } + TQString targetfilename = project->variables()["TARGET"].first(); + if(project->isActiveConfig("activeqt")) { + TQString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + if ( project->isActiveConfig("dll")) { + t << "\n\t" << ("-$(IDC) $(TARGET) /idl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /regserver" ); + } else { + t << "\n\t" << ("-$(TARGET) -dumpidl " + var("OBJECTS_DIR") + targetfilename + ".idl -version " + version); + t << "\n\t" << ("-$(IDL) /nologo " + var("OBJECTS_DIR") + targetfilename + ".idl /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << ("-$(IDC) $(TARGET) /tlb " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + t << "\n\t" << "-$(TARGET) -regserver"; + } + } + t << endl << endl; + + if(!project->variables()["RC_FILE"].isEmpty()) { + t << var("RES_FILE") << ": " << var("RC_FILE") << "\n\t" + << var("QMAKE_RC") << " " << var("RC_FILE") << endl << endl; + } + + t << "mocables: $(SRCMOC)" << endl + << "uicables: $(UICIMPLS) $(UICDECLS)" << endl << endl; + + writeMakeQmake(t); + + TQStringList dist_files = Option::mkfile::project_files; + if(!project->isEmpty("QMAKE_INTERNAL_INCLUDED_FILES")) + dist_files += project->variables()["QMAKE_INTERNAL_INCLUDED_FILES"]; + if(!project->isEmpty("TRANSLATIONS")) + dist_files << var("TRANSLATIONS"); + if(!project->isEmpty("FORMS")) { + TQStringList &forms = project->variables()["FORMS"]; + for(TQStringList::Iterator formit = forms.begin(); formit != forms.end(); ++formit) { + TQString ui_h = fileFixify((*formit) + Option::h_ext.first()); + if(TQFile::exists(ui_h) ) + dist_files << ui_h; + } + } + t << "dist:" << "\n\t" + << "$(ZIP) " << var("QMAKE_ORIG_TARGET") << ".zip " << "$(SOURCES) $(HEADERS) $(DIST) $(FORMS) " + << dist_files.join(" ") << " " << var("TRANSLATIONS") << " " << var("IMAGES") << endl << endl; + + t << "uiclean:" + << varGlue("UICDECLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("UICIMPLS" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl; + + t << "mocclean:" + << varGlue("SRCMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("OBJMOC" ,"\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") << endl; + + t << "clean: uiclean mocclean" + << varGlue("OBJECTS","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","") + << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n") + << varGlue("CLEAN_FILES","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ","\n"); + if ( project->isActiveConfig("activeqt")) { + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".idl"); + t << ("\n\t-$(DEL_FILE) " + var("OBJECTS_DIR") + targetfilename + ".tlb"); + } + if(!project->isEmpty("IMAGES")) + t << varGlue("QMAKE_IMAGE_COLLECTION", "\n\t-$(DEL_FILE) ", "\n\t-$(DEL_FILE) ", ""); + t << endl; + + // user defined targets + + TQStringList::Iterator it; + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(it = qut.begin(); it != qut.end(); ++it) { + TQString targ = var((*it) + ".target"), + cmd = var((*it) + ".commands"), deps; + if(targ.isEmpty()) + targ = (*it); + TQStringList &deplist = project->variables()[(*it) + ".depends"]; + for(TQStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { + TQString dep = var((*dep_it) + ".target"); + if(dep.isEmpty()) + dep = (*dep_it); + deps += " " + dep; + } + if(!project->variables()["QMAKE_NOFORCE"].isEmpty() && + project->variables()[(*it) + ".CONFIG"].findIndex("phony") != -1) + deps += TQString(" ") + "FORCE"; + t << "\n\n" << targ << ":" << deps << "\n\t" + << cmd; + } + t << endl << endl; + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + TQString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); + TQString tmp_dep = project->variables()[(*it) + ".depends"].join(" "); + TQStringList &vars = project->variables()[(*it) + ".variables"]; + if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out, cmd = tmp_cmd, deps; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + cmd.replace("${QMAKE_FILE_BASE}", fi.baseName()); + cmd.replace("${QMAKE_FILE_OUT}", out); + cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + for(TQStringList::Iterator it3 = vars.begin(); it3 != vars.end(); ++it3) + cmd.replace("$(" + (*it3) + ")", "$(QMAKE_COMP_" + (*it3)+")"); + if(!tmp_dep.isEmpty()) { + char buff[256]; + TQString dep_cmd = tmp_dep; + dep_cmd.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(FILE *proc = QT_POPEN(dep_cmd.latin1(), "r")) { + while(!feof(proc)) { + int read_in = int(fread(buff, 1, 255, proc)); + if(!read_in) + break; + int l = 0; + for(int i = 0; i < read_in; i++) { + if(buff[i] == '\n' || buff[i] == ' ') { + deps += " " + TQCString(buff+l, (i - l) + 1); + l = i; + } + } + } + fclose(proc); + } + } + t << out << ": " << in << deps << "\n\t" + << cmd << endl << endl; + } + } + } + t << endl; + + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << "FORCE:" << endl << endl; + + t << "distclean: clean" + << "\n\t-$(DEL_FILE) $(TARGET)" + << endl << endl; + + // precompiled header + if(usePCH) { + TQString precompRule = TQString("-c -Yc -Fp%1 -Fo%2").arg(precompPch).arg(precompObj); + t << precompObj << ": " << precompH << " " << findDependencies(precompH).join(" \\\n\t\t") + << "\n\t" << ("$(CXX) " + precompRule + " $(CXXFLAGS) $(INCPATH) -TP ") << precompH << endl << endl; + } +} + +TQString +NmakeMakefileGenerator::var(const TQString &value) +{ + if (usePCH) { + if ((value == "QMAKE_RUN_CXX_IMP_BATCH" + || value == "QMAKE_RUN_CXX_IMP" + || value == "QMAKE_RUN_CXX")) { + TQFileInfo precompHInfo(precompH); + TQString precompRule = TQString("-c -FI%1 -Yu%2 -Fp%3") + .arg(precompHInfo.fileName()) + .arg(precompHInfo.fileName()) + .arg(precompPch); + TQString p = MakefileGenerator::var(value); + p.replace("-c", precompRule); + // Cannot use -Gm with -FI & -Yu, as this gives an + // internal compiler error, on the newer compilers + p.remove("-Gm"); + return p; + } else if (value == "QMAKE_CXXFLAGS") { + // Remove internal compiler error option + return MakefileGenerator::var(value).remove("-Gm"); + } + } + + // Normal val + return MakefileGenerator::var(value); +} + +void +NmakeMakefileGenerator::init() +{ + if(init_flag) + return; + init_flag = TRUE; + + /* this should probably not be here, but I'm using it to wrap the .t files */ + if(project->first("TEMPLATE") == "app") + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "lib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "subdirs") { + MakefileGenerator::init(); + if(project->variables()["MAKEFILE"].isEmpty()) + project->variables()["MAKEFILE"].append("Makefile"); + if(project->variables()["QMAKE"].isEmpty()) + project->variables()["QMAKE"].append("qmake"); + return; + } + + if(project->isEmpty("QMAKE_INSTALL_FILE")) + project->variables()["QMAKE_INSTALL_FILE"].append("$(COPY_FILE)"); + if(project->isEmpty("QMAKE_INSTALL_DIR")) + project->variables()["QMAKE_INSTALL_DIR"].append("$(COPY_DIR)"); + + bool is_qt = (project->first("TARGET") == "qt"TQTDLL_POSTFIX || project->first("TARGET") == "tqt-mt"TQTDLL_POSTFIX); + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + TQString targetfilename = project->variables()["TARGET"].first(); + TQStringList &configs = project->variables()["CONFIG"]; + if (project->isActiveConfig("qt") && project->isActiveConfig("shared")) + project->variables()["DEFINES"].append("QT_DLL"); + if (project->isActiveConfig("qt_dll")) + if(configs.findIndex("qt") == -1) configs.append("qt"); + if ( project->isActiveConfig("qtopia") ) { + if(configs.findIndex("qtopialib") == -1) + configs.append("qtopialib"); + if(configs.findIndex("qtopiainc") == -1) + configs.append("qtopiainc"); + } + if ( project->isActiveConfig("qt") ) { + if ( project->isActiveConfig( "plugin" ) ) { + project->variables()["CONFIG"].append("dll"); + if(project->isActiveConfig("qt")) + project->variables()["DEFINES"].append("QT_PLUGIN"); + } + if ( (project->variables()["DEFINES"].findIndex("QT_NODLL") == -1) && + ((project->variables()["DEFINES"].findIndex("QT_MAKEDLL") != -1 || + project->variables()["DEFINES"].findIndex("QT_DLL") != -1) || + (getenv("QT_DLL") && !getenv("QT_NODLL"))) ) { + project->variables()["QMAKE_QT_DLL"].append("1"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) + project->variables()["CONFIG"].append("dll"); + } + if ( project->isActiveConfig("thread") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT"); + if ( project->isActiveConfig("accessibility" ) ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); + if ( project->isActiveConfig("tablet") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); + } + if ( project->isActiveConfig("dll") || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["CONFIG"].remove("staticlib"); + project->variables()["QMAKE_APP_OR_DLL"].append("1"); + } else { + project->variables()["CONFIG"].append("staticlib"); + } + if ( project->isActiveConfig("warn_off") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_OFF"]; + } else if ( project->isActiveConfig("warn_on") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_WARN_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_WARN_ON"]; + } + if ( project->isActiveConfig("debug") ) { + if ( project->isActiveConfig("thread") ) { + // use the DLL RT even here + if ( project->variables()["DEFINES"].contains("QT_DLL") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLLDBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DBG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DBG"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_DEBUG"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_DEBUG"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_DEBUG"]; + } else { + if ( project->isActiveConfig("thread") ) { + if ( project->variables()["DEFINES"].contains("QT_DLL") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT_DLL"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT_DLL"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_MT"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_MT"]; + } + } + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RELEASE"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RELEASE"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_RELEASE"]; + } + if ( project->isActiveConfig("thread") && !project->variables()["DEFINES"].contains("QT_DLL") + && !is_qt && project->first("TARGET") != "qtmain") { + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:\"libc\""); + } + + if ( !project->variables()["QMAKE_INCDIR"].isEmpty()) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR"]; + if ( project->isActiveConfig("qt") || project->isActiveConfig("opengl") ) + project->variables()["CONFIG"].append("windows"); + if ( project->isActiveConfig("qtopiainc") ) + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QTOPIA"]; + if ( project->isActiveConfig("qtopialib") ) { + if(!project->isEmpty("QMAKE_LIBDIR_QTOPIA")) + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QTOPIA"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QTOPIA"]; + } + if ( project->isActiveConfig("qt") ) { + project->variables()["CONFIG"].append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + if ( !project->isActiveConfig("debug") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_NO_DEBUG"); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty()) { + project->variables()["DEFINES"].append("QT_MAKEDLL"); + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_QT_DLL"]; + } + } else { + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); + if ( hver == -1 ) + hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "tqt-mt"); + if(hver != -1) { + TQString ver; + ver.sprintf("qt%s" TQTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(TQRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + if ( project->isActiveConfig("dll") ) { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE_DLL"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS_DLL"]; + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append( + TQStringList::split('.',project->first("VERSION")).join("") + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } else { + project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CFLAGS_CONSOLE"]; + project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_CXXFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"] = project->variables()["QMAKE_LFLAGS_CONSOLE"]; + project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"] = project->variables()["QMAKE_LFLAGS_WINDOWS"]; + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty()) { + project->variables()["TARGET_EXT"].append(".exe"); + } else { + project->variables()["TARGET_EXT"].append(".lib"); + } + } + if ( project->isActiveConfig("windows") ) { + if ( project->isActiveConfig("console") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } else { + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_WINDOWS_ANY"]; + } + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_CONSOLE_ANY"]; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_CONSOLE"]; + } + if ( project->isActiveConfig("stl") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; + } + if ( project->isActiveConfig("exceptions") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; + } + if ( project->isActiveConfig("rtti") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; + } + + + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + + TQStringList &libList = project->variables()["QMAKE_LIBS"]; + for( TQStringList::Iterator stIt = libList.begin(); stIt != libList.end(); ) { + TQString s = *stIt; + if( s.startsWith( "-l" ) ) { + stIt = libList.remove( stIt ); + stIt = libList.insert( stIt, s.mid( 2 ) + ".lib" ); + } else if( s.startsWith( "-L" ) ) { + stIt = libList.remove( stIt ); + project->variables()["QMAKE_LIBDIR"].append(TQDir::convertSeparators(s.mid( 2 ))); + } else { + stIt++; + } + } + + project->variables()["QMAKE_FILETAGS"] += TQStringList::split(' ', + "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + TQStringList &l = project->variables()["QMAKE_FILETAGS"]; + TQStringList::Iterator it; + for(it = l.begin(); it != l.end(); ++it) { + TQStringList &gdmf = project->variables()[(*it)]; + for(TQStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) + (*inner) = Option::fixPathToTargetOS((*inner), FALSE); + } + + if ( !project->variables()["DEF_FILE"].isEmpty() ) + project->variables()["QMAKE_LFLAGS"].append(TQString("/DEF:") + project->first("DEF_FILE")); + if(!project->isActiveConfig("incremental")) + project->variables()["QMAKE_LFLAGS"].append(TQString("/incremental:no")); + + if ( !project->variables()["VERSION"].isEmpty() ) { + TQString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + TQString major = version.left( firstDot ); + TQString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); + } + if ( !project->variables()["RC_FILE"].isEmpty()) { + if ( !project->variables()["RES_FILE"].isEmpty()) { + fprintf(stderr, "Both .rc and .res file specified.\n"); + fprintf(stderr, "Please specify one of them, not both."); + exit(666); + } + project->variables()["RES_FILE"] = project->variables()["RC_FILE"]; + project->variables()["RES_FILE"].first().replace(".rc",".res"); + project->variables()["POST_TARGETDEPS"] += project->variables()["RES_FILE"]; + project->variables()["CLEAN_FILES"] += project->variables()["RES_FILE"]; + } + if ( !project->variables()["RES_FILE"].isEmpty()) + project->variables()["QMAKE_LIBS"] += project->variables()["RES_FILE"]; + + // Base class init! + MakefileGenerator::init(); + + // Setup PCH variables + precompH = project->first("PRECOMPILED_HEADER"); + usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + if (usePCH) { + // Created files + precompObj = var("OBJECTS_DIR") + project->first("TARGET") + "_pch" + Option::obj_ext; + precompPch = var("OBJECTS_DIR") + project->first("TARGET") + "_pch.pch"; + // Add linking of precompObj (retquired for whole precompiled classes) + project->variables()["OBJECTS"] += precompObj; + // Add pch file to cleanup + project->variables()["QMAKE_CLEAN"] += precompPch; + // Return to variable pool + project->variables()["PRECOMPILED_OBJECT"] = precompObj; + project->variables()["PRECOMPILED_PCH"] = precompPch; + } + + if ( !project->variables()["VERSION"].isEmpty()) { + TQStringList l = TQStringList::split('.', project->first("VERSION")); + project->variables()["VER_MAJ"].append(l[0]); + project->variables()["VER_MIN"].append(l[1]); + } + + TQString version = TQStringList::split('.', project->first("VERSION")).join(""); + if(project->isActiveConfig("dll")) { + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".exp"); + } + if(project->isActiveConfig("debug")) { + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".pdb"); + project->variables()["QMAKE_CLEAN"].append(project->first("DESTDIR") + project->first("TARGET") + version + ".ilk"); + project->variables()["QMAKE_CLEAN"].append("vc*.pdb"); + project->variables()["QMAKE_CLEAN"].append("vc*.idb"); + } + + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + if(tmp_out.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + TQString in = Option::fixPathToTargetOS((*input), FALSE), + out = tmp_out; + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(project->variables()[(*it) + ".CONFIG"].findIndex("no_link") == -1) + project->variables()["OBJCOMP"] += out; + } + } + } +} diff --git a/qmake/generators/win32/msvc_nmake.h b/qmake/generators/win32/msvc_nmake.h new file mode 100644 index 000000000..22d3c1aa7 --- /dev/null +++ b/qmake/generators/win32/msvc_nmake.h @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Definition of NmakeMakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __MSVC_NMAKE_H__ +#define __MSVC_NMAKE_H__ + +#include "winmakefile.h" + +class NmakeMakefileGenerator : public Win32MakefileGenerator +{ + bool init_flag; + void writeNmakeParts(TQTextStream &); + + bool writeMakefile(TQTextStream &); + void init(); + +protected: + TQStringList &findDependencies(const TQString &file); + TQString var(const TQString &value); + TQString precompH, precompObj, precompPch; + bool usePCH; + +public: + NmakeMakefileGenerator(TQMakeProject *p); + ~NmakeMakefileGenerator(); + +}; + +inline NmakeMakefileGenerator::~NmakeMakefileGenerator() +{ } + +#endif /* __MSVC_NMAKE_H__ */ diff --git a/qmake/generators/win32/msvc_objectmodel.cpp b/qmake/generators/win32/msvc_objectmodel.cpp new file mode 100644 index 000000000..7b89932e4 --- /dev/null +++ b/qmake/generators/win32/msvc_objectmodel.cpp @@ -0,0 +1,2226 @@ +/**************************************************************************** +** +** Implementation of VCProject class. +** +** Copyright (C) 2002-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "msvc_objectmodel.h" +#include "msvc_vcproj.h" +#include <qtextstream.h> +#include <qstringlist.h> +#include <qfileinfo.h> + +extern DotNET which_dotnet_version(); + +// XML Tags --------------------------------------------------------- +const char* _xmlInit = "<?xml version=\"1.0\" encoding = \"Windows-1252\"?>"; +const char* _begConfiguration = "\n\t\t<Configuration"; +const char* _begConfigurations = "\n\t<Configurations>"; +const char* _begFile = "\n\t\t\t<File"; +const char* _begFileConfiguration = "\n\t\t\t\t<FileConfiguration"; +const char* _begFiles = "\n\t<Files>"; +const char* _begFilter = "\n\t\t<Filter"; +const char* _begGlobals = "\n\t<Globals>"; +const char* _begPlatform = "\n\t\t<Platform"; +const char* _begPlatforms = "\n\t<Platforms>"; +const char* _begTool3 = "\n\t\t\t<Tool"; +const char* _begTool5 = "\n\t\t\t\t\t<Tool"; +const char* _begVisualStudioProject = "\n<VisualStudioProject"; +const char* _endConfiguration = "\n\t\t</Configuration>"; +const char* _endConfigurations = "\n\t</Configurations>"; +const char* _endFile = "\n\t\t\t</File>"; +const char* _endFileConfiguration = "\n\t\t\t\t</FileConfiguration>"; +const char* _endFiles = "\n\t</Files>"; +const char* _endFilter = "\n\t\t</Filter>"; +const char* _endGlobals = "\n\t</Globals>"; +const char* _endPlatforms = "\n\t</Platforms>"; +const char* _endVisualStudioProject = "\n</VisualStudioProject>"; + +// XML Properties --------------------------------------------------- +const char* _AddModuleNamesToAssembly = "\n\t\t\t\tAddModuleNamesToAssembly=\""; +const char* _AdditionalDependencies4 = "\n\t\t\t\tAdditionalDependencies=\""; +const char* _AdditionalDependencies6 = "\n\t\t\t\t\t\tAdditionalDependencies=\""; +const char* _AdditionalIncludeDirectories = "\n\t\t\t\tAdditionalIncludeDirectories=\""; +const char* _AdditionalLibraryDirectories = "\n\t\t\t\tAdditionalLibraryDirectories=\""; +const char* _AdditionalOptions = "\n\t\t\t\tAdditionalOptions=\""; +const char* _AdditionalUsingDirectories = "\n\t\t\t\tAdditionalUsingDirectories=\""; +const char* _AssemblerListingLocation = "\n\t\t\t\tAssemblerListingLocation=\""; +const char* _AssemblerOutput = "\n\t\t\t\tAssemblerOutput=\""; +const char* _ATLMinimizesCRunTimeLibraryUsage = "\n\t\t\tATLMinimizesCRunTimeLibraryUsage=\""; +const char* _BaseAddress = "\n\t\t\t\tBaseAddress=\""; +const char* _BasicRuntimeChecks = "\n\t\t\t\tBasicRuntimeChecks=\""; +const char* _BrowseInformation = "\n\t\t\t\tBrowseInformation=\""; +const char* _BrowseInformationFile = "\n\t\t\t\tBrowseInformationFile=\""; +const char* _BufferSecurityCheck = "\n\t\t\t\tBufferSecurityCheck=\""; +const char* _BuildBrowserInformation = "\n\t\t\tBuildBrowserInformation=\""; +const char* _CPreprocessOptions = "\n\t\t\t\tCPreprocessOptions=\""; +const char* _CallingConvention = "\n\t\t\t\tCallingConvention=\""; +const char* _CharacterSet = "\n\t\t\tCharacterSet=\""; +const char* _CommandLine4 = "\n\t\t\t\tCommandLine=\""; +const char* _CommandLine6 = "\n\t\t\t\t\t\tCommandLine=\""; +const char* _CompileAs = "\n\t\t\t\tCompileAs=\""; +const char* _CompileAsManaged = "\n\t\t\t\tCompileAsManaged=\""; +const char* _CompileOnly = "\n\t\t\t\tCompileOnly=\""; +const char* _ConfigurationType = "\n\t\t\tConfigurationType=\""; +const char* _Culture = "\n\t\t\t\tCulture=\""; +const char* _DLLDataFileName = "\n\t\t\t\tDLLDataFileName=\""; +const char* _DebugInformationFormat = "\n\t\t\t\tDebugInformationFormat=\""; +const char* _DefaultCharIsUnsigned = "\n\t\t\t\tDefaultCharIsUnsigned=\""; +const char* _DefaultCharType = "\n\t\t\t\tDefaultCharType=\""; +const char* _DelayLoadDLLs = "\n\t\t\t\tDelayLoadDLLs=\""; +const char* _DeleteExtensionsOnClean = "\n\t\t\tDeleteExtensionsOnClean=\""; +const char* _Description4 = "\n\t\t\t\tDescription=\""; +const char* _Description6 = "\n\t\t\t\t\t\tDescription=\""; +const char* _Detect64BitPortabilityProblems = "\n\t\t\t\tDetect64BitPortabilityProblems=\""; +const char* _DisableLanguageExtensions = "\n\t\t\t\tDisableLanguageExtensions=\""; +const char* _DisableSpecificWarnings = "\n\t\t\t\tDisableSpecificWarnings=\""; +const char* _EnableCOMDATFolding = "\n\t\t\t\tEnableCOMDATFolding=\""; +const char* _EnableErrorChecks = "\n\t\t\t\tEnableErrorChecks=\""; +const char* _EnableFiberSafeOptimizations = "\n\t\t\t\tEnableFiberSafeOptimizations=\""; +const char* _EnableFunctionLevelLinking = "\n\t\t\t\tEnableFunctionLevelLinking=\""; +const char* _EnableIntrinsicFunctions = "\n\t\t\t\tEnableIntrinsicFunctions=\""; +const char* _EntryPointSymbol = "\n\t\t\t\tEntryPointSymbol=\""; +const char* _ErrorCheckAllocations = "\n\t\t\t\tErrorCheckAllocations=\""; +const char* _ErrorCheckBounds = "\n\t\t\t\tErrorCheckBounds=\""; +const char* _ErrorCheckEnumRange = "\n\t\t\t\tErrorCheckEnumRange=\""; +const char* _ErrorCheckRefPointers = "\n\t\t\t\tErrorCheckRefPointers=\""; +const char* _ErrorCheckStubData = "\n\t\t\t\tErrorCheckStubData=\""; +const char* _ExceptionHandling = "\n\t\t\t\tExceptionHandling=\""; +const char* _ExcludedFromBuild = "\n\t\t\t\tExcludedFromBuild=\""; +const char* _ExpandAttributedSource = "\n\t\t\t\tExpandAttributedSource=\""; +const char* _ExportNamedFunctions = "\n\t\t\t\tExportNamedFunctions=\""; +const char* _FavorSizeOrSpeed = "\n\t\t\t\tFavorSizeOrSpeed=\""; +const char* _Filter = "\n\t\t\tFilter=\""; +const char* _ForceConformanceInForLoopScope = "\n\t\t\t\tForceConformanceInForLoopScope=\""; +const char* _ForceSymbolReferences = "\n\t\t\t\tForceSymbolReferences=\""; +const char* _ForcedIncludeFiles = "\n\t\t\t\tForcedIncludeFiles=\""; +const char* _ForcedUsingFiles = "\n\t\t\t\tForcedUsingFiles=\""; +const char* _FullIncludePath = "\n\t\t\t\tFullIncludePath=\""; +const char* _FunctionOrder = "\n\t\t\t\tFunctionOrder=\""; +const char* _GenerateDebugInformation = "\n\t\t\t\tGenerateDebugInformation=\""; +const char* _GenerateMapFile = "\n\t\t\t\tGenerateMapFile=\""; +const char* _GeneratePreprocessedFile = "\n\t\t\t\tGeneratePreprocessedFile=\""; +const char* _GenerateStublessProxies = "\n\t\t\t\tGenerateStublessProxies=\""; +const char* _GenerateTypeLibrary = "\n\t\t\t\tGenerateTypeLibrary=\""; +const char* _GlobalOptimizations = "\n\t\t\t\tGlobalOptimizations=\""; +const char* _HeaderFileName = "\n\t\t\t\tHeaderFileName=\""; +const char* _HeapCommitSize = "\n\t\t\t\tHeapCommitSize=\""; +const char* _HeapReserveSize = "\n\t\t\t\tHeapReserveSize=\""; +const char* _IgnoreAllDefaultLibraries = "\n\t\t\t\tIgnoreAllDefaultLibraries=\""; +const char* _IgnoreDefaultLibraryNames = "\n\t\t\t\tIgnoreDefaultLibraryNames=\""; +const char* _IgnoreEmbeddedIDL = "\n\t\t\t\tIgnoreEmbeddedIDL=\""; +const char* _IgnoreImportLibrary = "\n\t\t\t\tIgnoreImportLibrary=\""; +const char* _IgnoreStandardIncludePath = "\n\t\t\t\tIgnoreStandardIncludePath=\""; +const char* _ImportLibrary = "\n\t\t\t\tImportLibrary=\""; +const char* _ImproveFloatingPointConsistency = "\n\t\t\t\tImproveFloatingPointConsistency=\""; +const char* _InlineFunctionExpansion = "\n\t\t\t\tInlineFunctionExpansion=\""; +const char* _InterfaceIdentifierFileName = "\n\t\t\t\tInterfaceIdentifierFileName=\""; +const char* _IntermediateDirectory = "\n\t\t\tIntermediateDirectory=\""; +const char* _KeepComments = "\n\t\t\t\tKeepComments=\""; +const char* _LargeAddressAware = "\n\t\t\t\tLargeAddressAware=\""; +const char* _LinkDLL = "\n\t\t\t\tLinkDLL=\""; +const char* _LinkIncremental = "\n\t\t\t\tLinkIncremental=\""; +const char* _LinkTimeCodeGeneration = "\n\t\t\t\tLinkTimeCodeGeneration=\""; +const char* _LinkToManagedResourceFile = "\n\t\t\t\tLinkToManagedResourceFile=\""; +const char* _MapExports = "\n\t\t\t\tMapExports=\""; +const char* _MapFileName = "\n\t\t\t\tMapFileName=\""; +const char* _MapLines = "\n\t\t\t\tMapLines =\""; +const char* _MergeSections = "\n\t\t\t\tMergeSections=\""; +const char* _MergedIDLBaseFileName = "\n\t\t\t\tMergedIDLBaseFileName=\""; +const char* _MidlCommandFile = "\n\t\t\t\tMidlCommandFile=\""; +const char* _MinimalRebuild = "\n\t\t\t\tMinimalRebuild=\""; +const char* _MkTypLibCompatible = "\n\t\t\t\tMkTypLibCompatible=\""; +const char* _ModuleDefinitionFile = "\n\t\t\t\tModuleDefinitionFile=\""; +const char* _Name1 = "\n\tName=\""; +const char* _Name2 = "\n\t\tName=\""; +const char* _Name3 = "\n\t\t\tName=\""; +const char* _Name4 = "\n\t\t\t\tName=\""; +const char* _Name5 = "\n\t\t\t\t\tName=\""; +const char* _ObjectFile = "\n\t\t\t\tObjectFile=\""; +const char* _OmitFramePointers = "\n\t\t\t\tOmitFramePointers=\""; +const char* _OpenMP = "\n\t\t\t\tOpenMP=\""; +const char* _Optimization = "\n\t\t\t\tOptimization =\""; +const char* _OptimizeForProcessor = "\n\t\t\t\tOptimizeForProcessor=\""; +const char* _OptimizeForWindows98 = "\n\t\t\t\tOptimizeForWindows98=\""; +const char* _OptimizeForWindowsApplication = "\n\t\t\t\tOptimizeForWindowsApplication=\""; +const char* _OptimizeReferences = "\n\t\t\t\tOptimizeReferences=\""; +const char* _OutputDirectory3 = "\n\t\t\tOutputDirectory=\""; +const char* _OutputDirectory4 = "\n\t\t\t\tOutputDirectory=\""; +const char* _OutputFile = "\n\t\t\t\tOutputFile=\""; +const char* _Outputs4 = "\n\t\t\t\tOutputs=\""; +const char* _Outputs6 = "\n\t\t\t\t\t\tOutputs=\""; +const char* _ParseFiles = "\n\t\t\tParseFiles=\""; +const char* _PrecompiledHeaderFile = "\n\t\t\t\tPrecompiledHeaderFile=\""; +const char* _PrecompiledHeaderThrough = "\n\t\t\t\tPrecompiledHeaderThrough=\""; +const char* _PreprocessorDefinitions = "\n\t\t\t\tPreprocessorDefinitions=\""; +const char* _PrimaryOutput = "\n\t\t\tPrimaryOutput=\""; +const char* _ProjectGUID = "\n\tProjectGUID=\""; +const char* _ProjectType = "\n\tProjectType=\"Visual C++\""; +const char* _ProgramDatabase = "\n\t\t\tProgramDatabase=\""; +const char* _ProgramDataBaseFileName = "\n\t\t\t\tProgramDataBaseFileName=\""; +const char* _ProgramDatabaseFile = "\n\t\t\t\tProgramDatabaseFile=\""; +const char* _ProxyFileName = "\n\t\t\t\tProxyFileName=\""; +const char* _RedirectOutputAndErrors = "\n\t\t\t\tRedirectOutputAndErrors=\""; +const char* _RegisterOutput = "\n\t\t\t\tRegisterOutput=\""; +const char* _RelativePath = "\n\t\t\t\tRelativePath=\""; +const char* _ResourceOnlyDLL = "\n\t\t\t\tResourceOnlyDLL=\""; +const char* _ResourceOutputFileName = "\n\t\t\t\tResourceOutputFileName=\""; +const char* _RuntimeLibrary = "\n\t\t\t\tRuntimeLibrary=\""; +const char* _RuntimeTypeInfo = "\n\t\t\t\tRuntimeTypeInfo=\""; +const char* _SccProjectName = "\n\tSccProjectName=\""; +const char* _SccLocalPath = "\n\tSccLocalPath=\""; +const char* _SetChecksum = "\n\t\t\t\tSetChecksum=\""; +const char* _ShowIncludes = "\n\t\t\t\tShowIncludes=\""; +const char* _ShowProgress = "\n\t\t\t\tShowProgress=\""; +const char* _SmallerTypeCheck = "\n\t\t\t\tSmallerTypeCheck=\""; +const char* _StackCommitSize = "\n\t\t\t\tStackCommitSize=\""; +const char* _StackReserveSize = "\n\t\t\t\tStackReserveSize=\""; +const char* _StringPooling = "\n\t\t\t\tStringPooling=\""; +const char* _StripPrivateSymbols = "\n\t\t\t\tStripPrivateSymbols=\""; +const char* _StructMemberAlignment = "\n\t\t\t\tStructMemberAlignment=\""; +const char* _SubSystem = "\n\t\t\t\tSubSystem=\""; +const char* _SupportUnloadOfDelayLoadedDLL = "\n\t\t\t\tSupportUnloadOfDelayLoadedDLL=\""; +const char* _SuppressStartupBanner = "\n\t\t\t\tSuppressStartupBanner=\""; +const char* _SwapRunFromCD = "\n\t\t\t\tSwapRunFromCD=\""; +const char* _SwapRunFromNet = "\n\t\t\t\tSwapRunFromNet=\""; +const char* _TargetEnvironment = "\n\t\t\t\tTargetEnvironment=\""; +const char* _TargetMachine = "\n\t\t\t\tTargetMachine=\""; +const char* _TerminalServerAware = "\n\t\t\t\tTerminalServerAware=\""; +const char* _ToolName = "\n\t\t\t\tName=\""; +const char* _ToolPath = "\n\t\t\t\tPath=\""; +const char* _TreatWChar_tAsBuiltInType = "\n\t\t\t\tTreatWChar_tAsBuiltInType=\""; +const char* _TurnOffAssemblyGeneration = "\n\t\t\t\tTurnOffAssemblyGeneration=\""; +const char* _TypeLibraryFile = "\n\t\t\t\tTypeLibraryFile=\""; +const char* _TypeLibraryName = "\n\t\t\t\tTypeLibraryName=\""; +const char* _TypeLibraryResourceID = "\n\t\t\t\tTypeLibraryResourceID=\""; +const char* _UndefineAllPreprocessorDefinitions = "\n\t\t\t\tUndefineAllPreprocessorDefinitions=\""; +const char* _UndefinePreprocessorDefinitions = "\n\t\t\t\tUndefinePreprocessorDefinitions=\""; +const char* _UseOfATL = "\n\t\t\tUseOfATL=\""; +const char* _UseOfMfc = "\n\t\t\tUseOfMfc=\""; +const char* _UsePrecompiledHeader = "\n\t\t\t\tUsePrecompiledHeader=\""; +const char* _ValidateParameters = "\n\t\t\t\tValidateParameters=\""; +const char* _VCCLCompilerToolName = "\n\t\t\t\tName=\"VCCLCompilerTool\""; +const char* _VCCustomBuildTool = "\n\t\t\t\t\t\tName=\"VCCustomBuildTool\""; +const char* _VCLinkerToolName = "\n\t\t\t\tName=\"VCLinkerTool\""; +const char* _VCResourceCompilerToolName = "\n\t\t\t\tName=\"VCResourceCompilerTool\""; +const char* _VCMIDLToolName = "\n\t\t\t\tName=\"VCMIDLTool\""; +const char* _Version1 = "\n\tVersion=\""; +const char* _Version4 = "\n\t\t\t\tVersion=\""; +const char* _WarnAsError = "\n\t\t\t\tWarnAsError=\""; +const char* _WarnLevel = "\n\t\t\t\tWarnLevel=\""; +const char* _WarningLevel = "\n\t\t\t\tWarningLevel=\""; +const char* _WholeProgramOptimization = "\n\t\t\t\tWholeProgramOptimization=\""; + +// Property name and value as Pairs --------------------------------- +struct TPair { + TPair( const char* n, const triState v ) : name(n), value(v) {}; + const char* name; + const triState value; +}; +struct EPair { + EPair( const char* n, const int v ) : name(n), value(v) {}; + const char* name; + const int value; +}; +struct LPair { + LPair( const char* n, const long v ) : name(n), value(v) {}; + const char* name; + const long value; +}; +struct SPair { + SPair( const char* n, const TQString& v ) : name(n), value(v) {}; + const char* name; + const TQString& value; +}; +struct XPair { + XPair( const char* n, const TQStringList& v, const char* s = "," ) : name(n), value(v), sep(s) {}; + const char* name; + const TQStringList& value; + const char* sep; +}; + +// void streamSPair( TQTextStream &strm, const char *n, const TQString &s ) + +// Streaming operators for property Pairs --------------------------- +TQTextStream &operator<<( TQTextStream &strm, const TPair &prop ) +{ + switch( prop.value ) { + case _False: + strm << prop.name << "FALSE\""; + break; + case _True: + strm << prop.name << "TRUE\""; + break; + case unset: + default: + break; + } + return strm; +} + +/* Be sure to check that each enum is not set to + default before streaming it out. Defaults seem + to not be in the XML file. +*/ +TQTextStream &operator<<( TQTextStream &strm, const EPair &prop ) +{ + strm << prop.name << prop.value << "\""; + return strm; +} + +TQTextStream &operator<<( TQTextStream &strm, const LPair &prop ) +{ + strm << prop.name << prop.value << "\""; + return strm; +} + +TQTextStream &operator<<( TQTextStream &strm, const SPair &prop ) +{ + if ( !prop.value.isEmpty() ) + strm << prop.name << TQString(prop.value).remove("\"") << "\""; + return strm; +} + +TQTextStream &operator<<( TQTextStream &strm, const XPair &prop ) +{ + if ( !prop.value.isEmpty() ) { + TQString outText = prop.value.join(prop.sep); + strm << prop.name << outText.replace('\"', """) << "\""; + } + return strm; +} + +// VCCLCompilerTool ------------------------------------------------- +VCCLCompilerTool::VCCLCompilerTool() + : AssemblerOutput( asmListingNone ), + BasicRuntimeChecks( runtimeBasicCheckNone ), + BrowseInformation( brInfoNone ), + BufferSecurityCheck( _False ), + CallingConvention( callConventionDefault ), + CompileAs( compileAsDefault ), + CompileAsManaged( managedDefault ), + CompileOnly( unset ), + DebugInformationFormat( debugDisabled ), + DefaultCharIsUnsigned( unset ), + Detect64BitPortabilityProblems( unset ), + DisableLanguageExtensions( unset ), + EnableFiberSafeOptimizations( unset ), + EnableFunctionLevelLinking( unset ), + EnableIntrinsicFunctions( unset ), + ExceptionHandling( _False ), + ExpandAttributedSource( unset ), + FavorSizeOrSpeed( favorNone ), + ForceConformanceInForLoopScope( unset ), + GeneratePreprocessedFile( preprocessNo ), + GlobalOptimizations( unset ), + IgnoreStandardIncludePath( unset ), + ImproveFloatingPointConsistency( unset ), + InlineFunctionExpansion( expandDefault ), + KeepComments( unset ), + MinimalRebuild( unset ), + OmitFramePointers( unset ), + OpenMP( unset ), + Optimization( optimizeCustom ), + OptimizeForProcessor( procOptimizeBlended ), + OptimizeForWindowsApplication( unset ), + ProgramDataBaseFileName( "" ), + RuntimeLibrary( rtSingleThreaded ), + RuntimeTypeInfo( unset ), + ShowIncludes( unset ), + SmallerTypeCheck( unset ), + StringPooling( unset ), + StructMemberAlignment( alignNotSet ), + SuppressStartupBanner( unset ), + TreatWChar_tAsBuiltInType( unset ), + TurnOffAssemblyGeneration( unset ), + UndefineAllPreprocessorDefinitions( unset ), + UsePrecompiledHeader( pchNone ), + WarnAsError( unset ), + WarningLevel( warningLevel_0 ), + WholeProgramOptimization( unset ), + config( 0 ) +{ +} + +/* + * Some values for the attribute UsePrecompiledHeader have changed from VS 2003 to VS 2005, + * see the following chart, so we need a function that transforms those values if we are + * using NET2005: + * + * Meaning 2003 2005 + * ----------------------------------------- + * Don't use PCH 0 0 + * Create PCH (/Yc) 1 1 + * Automatically generate (/YX) 2 (seems that it was removed) + * Use specific PCH (/Yu) 3 2 + * + */ +inline pchOption xformUsePrecompiledHeaderForNET2005(pchOption whatPch) +{ + DotNET compilerVersion = which_dotnet_version(); + + if (compilerVersion == NET2005) { + if (whatPch == pchGenerateAuto) whatPch = pchNone; + if (whatPch == pchUseUsingSpecific) whatPch = pchGenerateAuto; + } + return whatPch; +} + +TQTextStream &operator<<( TQTextStream &strm, const VCCLCompilerTool &tool ) +{ + strm << _begTool3; + strm << _VCCLCompilerToolName; + strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " ); + strm << XPair( _AdditionalUsingDirectories, tool.AdditionalUsingDirectories ); + strm << SPair( _AssemblerListingLocation, tool.AssemblerListingLocation ); + if ( tool.AssemblerOutput != asmListingNone ) strm << EPair( _AssemblerOutput, tool.AssemblerOutput ); + if ( tool.BasicRuntimeChecks != runtimeBasicCheckNone ) strm << EPair( _BasicRuntimeChecks, tool.BasicRuntimeChecks ); + if ( tool.BrowseInformation != brInfoNone ) strm << EPair( _BrowseInformation, tool.BrowseInformation ); + strm << SPair( _BrowseInformationFile, tool.BrowseInformationFile ); + strm << TPair( _BufferSecurityCheck, tool.BufferSecurityCheck ); + if ( tool.CallingConvention != callConventionDefault ) strm << EPair( _CallingConvention, tool.CallingConvention ); + if ( tool.CompileAs != compileAsDefault ) strm << EPair( _CompileAs, tool.CompileAs ); + if ( tool.CompileAsManaged != managedDefault ) strm << EPair( _CompileAsManaged, tool.CompileAsManaged ); + strm << TPair( _CompileOnly, tool.CompileOnly ); + if ( tool.DebugInformationFormat != debugUnknown ) strm << EPair( _DebugInformationFormat, tool.DebugInformationFormat ); + strm << TPair( _DefaultCharIsUnsigned, tool.DefaultCharIsUnsigned ); + strm << TPair( _Detect64BitPortabilityProblems, tool.Detect64BitPortabilityProblems ); + strm << TPair( _DisableLanguageExtensions, tool.DisableLanguageExtensions ); + strm << XPair( _DisableSpecificWarnings, tool.DisableSpecificWarnings ); + strm << TPair( _EnableFiberSafeOptimizations, tool.EnableFiberSafeOptimizations ); + strm << TPair( _EnableFunctionLevelLinking, tool.EnableFunctionLevelLinking ); + strm << TPair( _EnableIntrinsicFunctions, tool.EnableIntrinsicFunctions ); + strm << TPair( _ExceptionHandling, tool.ExceptionHandling ); + strm << TPair( _ExpandAttributedSource, tool.ExpandAttributedSource ); + if ( tool.FavorSizeOrSpeed != favorNone ) strm << EPair( _FavorSizeOrSpeed, tool.FavorSizeOrSpeed ); + strm << TPair( _ForceConformanceInForLoopScope, tool.ForceConformanceInForLoopScope ); + strm << XPair( _ForcedIncludeFiles, tool.ForcedIncludeFiles ); + strm << XPair( _ForcedUsingFiles, tool.ForcedUsingFiles ); + if ( tool.GeneratePreprocessedFile != preprocessUnknown)strm << EPair( _GeneratePreprocessedFile, tool.GeneratePreprocessedFile ); + strm << TPair( _GlobalOptimizations, tool.GlobalOptimizations ); + strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); + strm << TPair( _ImproveFloatingPointConsistency, tool.ImproveFloatingPointConsistency ); + if ( tool.InlineFunctionExpansion != expandDefault ) strm << EPair( _InlineFunctionExpansion, tool.InlineFunctionExpansion ); + strm << TPair( _KeepComments, tool.KeepComments ); + strm << TPair( _MinimalRebuild, tool.MinimalRebuild ); + strm << SPair( _ObjectFile, tool.ObjectFile ); + strm << TPair( _OmitFramePointers, tool.OmitFramePointers ); + if ( tool.Optimization != optimizeDefault ) strm << EPair( _Optimization, tool.Optimization ); + if ( tool.OptimizeForProcessor != procOptimizeBlended ) strm << EPair( _OptimizeForProcessor, tool.OptimizeForProcessor ); + strm << TPair( _OptimizeForWindowsApplication, tool.OptimizeForWindowsApplication ); + strm << SPair( _OutputFile, tool.OutputFile ); + strm << SPair( _PrecompiledHeaderFile, tool.PrecompiledHeaderFile ); + strm << SPair( _PrecompiledHeaderThrough, tool.PrecompiledHeaderThrough ); + strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); + if ( !tool.ProgramDataBaseFileName.isNull() ) strm << _ProgramDataBaseFileName << tool.ProgramDataBaseFileName.latin1() << "\""; + if ( tool.RuntimeLibrary != rtUnknown ) strm << EPair( _RuntimeLibrary, tool.RuntimeLibrary ); + strm << TPair( _RuntimeTypeInfo, tool.RuntimeTypeInfo ); + strm << TPair( _OpenMP, tool.OpenMP ); + strm << TPair( _ShowIncludes, tool.ShowIncludes ); + strm << TPair( _SmallerTypeCheck, tool.SmallerTypeCheck ); + strm << TPair( _StringPooling, tool.StringPooling ); + if ( tool.StructMemberAlignment != alignNotSet ) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + strm << TPair( _TreatWChar_tAsBuiltInType, tool.TreatWChar_tAsBuiltInType ); + strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); + strm << TPair( _UndefineAllPreprocessorDefinitions, tool.UndefineAllPreprocessorDefinitions ); + strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); + + if ( !tool.PrecompiledHeaderFile.isEmpty() || !tool.PrecompiledHeaderThrough.isEmpty() ) + strm << EPair( _UsePrecompiledHeader, xformUsePrecompiledHeaderForNET2005(tool.UsePrecompiledHeader) ); + + strm << TPair( _WarnAsError, tool.WarnAsError ); + if ( tool.WarningLevel != warningLevelUnknown ) strm << EPair( _WarningLevel, tool.WarningLevel ); + strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); + strm << "/>"; +return strm; +} + +bool VCCLCompilerTool::parseOption( const char* option ) +{ + // skip index 0 ('/' or '-') + char first = option[1]; + char second = option[2]; + char third = option[3]; + char fourth = option[4]; + bool found = TRUE; + + switch ( first ) { + case '?': + case 'h': + qWarning( "Generator: Option '/?', '/help': MSVC.NET projects do not support outputting help info" ); + found = FALSE; + break; + case '@': + qWarning( "Generator: Option '/@': MSVC.NET projects do not support the use of a response file" ); + found = FALSE; + break; + case 'l': + qWarning( "Generator: Option '/link': qmake generator does not support passing link options through the compiler tool" ); + found = FALSE; + break; + case 'A': + if ( second != 'I' ) { + found = FALSE; break; + } + AdditionalUsingDirectories += option+3; + break; + case 'C': + KeepComments = _True; + break; + case 'D': + PreprocessorDefinitions += option+2; + break; + case 'E': + if ( second == 'H' ) { + if ( third == 'a' + || (third == 'c' && fourth != 's') + || (third == 's' && fourth != 'c') ) { + // ExceptionHandling must be false, or it will override + // with an /EHsc option + ExceptionHandling = _False; + AdditionalOptions += option; + break; + } else if ( (third == 'c' && fourth == 's') + || (third == 's' && fourth == 'c') ) { + ExceptionHandling = _True; + AdditionalOptions += option; + break; + } + found = FALSE; break; + } + GeneratePreprocessedFile = preprocessYes; + break; + case 'F': + if ( second <= '9' && second >= '0' ) { + AdditionalOptions += option; + break; + } else { + switch ( second ) { + case 'A': + if ( third == 'c' ) { + AssemblerOutput = asmListingAsmMachine; + if ( fourth == 's' ) + AssemblerOutput = asmListingAsmMachineSrc; + } else if ( third == 's' ) { + AssemblerOutput = asmListingAsmSrc; + } else { + AssemblerOutput = asmListingAssemblyOnly; + } + break; + case 'a': + AssemblerListingLocation = option+3; + break; + case 'I': + ForcedIncludeFiles += option+3; + break; + case 'R': + BrowseInformation = brAllInfo; + BrowseInformationFile = option+3; + break; + case 'r': + BrowseInformation = brNoLocalSymbols; + BrowseInformationFile = option+3; + break; + case 'U': + ForcedUsingFiles += option+3; + break; + case 'd': + ProgramDataBaseFileName = option+3; + break; + case 'e': + OutputFile = option+3; + break; + case 'm': + AdditionalOptions += option; + break; + case 'o': + ObjectFile = option+3; + break; + case 'p': + PrecompiledHeaderFile = option+3; + break; + case 'x': + ExpandAttributedSource = _True; + break; + default: + found = FALSE; break; + } + } + break; + case 'G': + switch ( second ) { + case '3': + case '4': + qWarning( "Option '/G3' and '/G4' were phased out in Visual C++ 5.0" ); + found = FALSE; break; + case '5': + OptimizeForProcessor = procOptimizePentium; + break; + case '6': + case 'B': + OptimizeForProcessor = procOptimizePentiumProAndAbove; + break; + case 'A': + OptimizeForWindowsApplication = _True; + break; + case 'F': + StringPooling = _True; + break; + case 'H': + AdditionalOptions += option; + break; + case 'L': + WholeProgramOptimization = _True; + if ( third == '-' ) + WholeProgramOptimization = _False; + break; + case 'R': + RuntimeTypeInfo = _True; + if ( third == '-' ) + RuntimeTypeInfo = _False; + break; + case 'S': + BufferSecurityCheck = _True; + break; + case 'T': + EnableFiberSafeOptimizations = _True; + break; + case 'X': + // ExceptionHandling == true will override with + // an /EHsc option, which is correct with /GX + ExceptionHandling = _True; // Fall-through + case 'Z': + case 'e': + case 'h': + AdditionalOptions += option; + break; + case 'd': + CallingConvention = callConventionCDecl; + break; + case 'f': + StringPooling = _True; + AdditionalOptions += option; + break; + case 'm': + MinimalRebuild = _True; + if ( third == '-' ) + MinimalRebuild = _False; + break; + case 'r': + CallingConvention = callConventionFastCall; + break; + case 's': + // Warning: following [num] is not used, + // were should we put it? + BufferSecurityCheck = _True; + break; + case 'y': + EnableFunctionLevelLinking = _True; + break; + case 'z': + CallingConvention = callConventionStdCall; + break; + default: + found = FALSE; break; + } + break; + case 'H': + AdditionalOptions += option; + break; + case 'I': + AdditionalIncludeDirectories += option+2; + break; + case 'L': + if ( second == 'D' ) { + AdditionalOptions += option; + break; + } + found = FALSE; break; + case 'M': + if ( second == 'D' ) { + RuntimeLibrary = rtMultiThreadedDLL; + if ( third == 'd' ) + RuntimeLibrary = rtMultiThreadedDebugDLL; + break; + } else if ( second == 'L' ) { + RuntimeLibrary = rtSingleThreaded; + if ( third == 'd' ) + RuntimeLibrary = rtSingleThreadedDebug; + break; + } else if ( second == 'T' ) { + RuntimeLibrary = rtMultiThreaded; + if ( third == 'd' ) + RuntimeLibrary = rtMultiThreadedDebug; + break; + } + found = FALSE; break; + case 'O': + switch ( second ) { + case '1': + Optimization = optimizeMinSpace; + break; + case '2': + Optimization = optimizeMaxSpeed; + break; + case 'a': + AdditionalOptions += option; + break; + case 'b': + if ( third == '0' ) + InlineFunctionExpansion = expandDisable; + else if ( third == '1' ) + InlineFunctionExpansion = expandOnlyInline; + else if ( third == '2' ) + InlineFunctionExpansion = expandAnySuitable; + else + found = FALSE; + break; + case 'd': + Optimization = optimizeDisabled; + break; + case 'g': + GlobalOptimizations = _True; + break; + case 'i': + EnableIntrinsicFunctions = _True; + break; + case 'p': + ImproveFloatingPointConsistency = _True; + if ( third == '-' ) + ImproveFloatingPointConsistency = _False; + break; + case 's': + FavorSizeOrSpeed = favorSize; + break; + case 't': + FavorSizeOrSpeed = favorSpeed; + break; + case 'w': + AdditionalOptions += option; + break; + case 'x': + Optimization = optimizeFull; + break; + case 'y': + OmitFramePointers = _True; + if ( third == '-' ) + OmitFramePointers = _False; + break; + default: + found = FALSE; break; + } + break; + case 'P': + GeneratePreprocessedFile = preprocessYes; + break; + case 'Q': + if ( second == 'I' ) { + AdditionalOptions += option; + break; + } + found = FALSE; break; + case 'R': + if ( second == 'T' && third == 'C' ) { + if ( fourth == '1' ) + BasicRuntimeChecks = runtimeBasicCheckAll; + else if ( fourth == 'c' ) + SmallerTypeCheck = _True; + else if ( fourth == 's' ) + BasicRuntimeChecks = runtimeCheckStackFrame; + else if ( fourth == 'u' ) + BasicRuntimeChecks = runtimeCheckUninitVariables; + else + found = FALSE; break; + } + break; + case 'T': + if ( second == 'C' ) { + CompileAs = compileAsC; + } else if ( second == 'P' ) { + CompileAs = compileAsCPlusPlus; + } else { + qWarning( "Generator: Options '/Tp<filename>' and '/Tc<filename>' are not supported by qmake" ); + found = FALSE; break; + } + break; + case 'U': + UndefinePreprocessorDefinitions += option+2; + break; + case 'V': + AdditionalOptions += option; + break; + case 'W': + switch ( second ) { + case 'a': + case '4': + WarningLevel = warningLevel_4; + break; + case '3': + WarningLevel = warningLevel_3; + break; + case '2': + WarningLevel = warningLevel_2; + break; + case '1': + WarningLevel = warningLevel_1; + break; + case '0': + WarningLevel = warningLevel_0; + break; + case 'L': + AdditionalOptions += option; + break; + case 'X': + WarnAsError = _True; + break; + case 'p': + if ( third == '6' && fourth == '4' ) { + Detect64BitPortabilityProblems = _True; + break; + } + // Fallthrough + default: + found = FALSE; break; + } + break; + case 'X': + IgnoreStandardIncludePath = _True; + break; + case 'Y': + switch ( second ) { + case '\0': + case '-': + AdditionalOptions += option; + break; + case 'X': + UsePrecompiledHeader = pchGenerateAuto; + PrecompiledHeaderFile = option+3; + break; + case 'c': + UsePrecompiledHeader = pchCreateUsingSpecific; + PrecompiledHeaderFile = option+3; + break; + case 'd': + case 'l': + AdditionalOptions =+ option; + break; + case 'u': + UsePrecompiledHeader = pchUseUsingSpecific; + PrecompiledHeaderFile = option+3; + break; + default: + found = FALSE; break; + } + break; + case 'Z': + switch ( second ) { + case '7': + DebugInformationFormat = debugOldStyleInfo; + break; + case 'I': + DebugInformationFormat = debugEditAndContinue; + break; + case 'd': + DebugInformationFormat = debugLineInfoOnly; + break; + case 'i': + DebugInformationFormat = debugEnabled; + break; + case 'l': + DebugInformationFormat = debugEditAndContinue; + break; + case 'a': + DisableLanguageExtensions = _True; + break; + case 'e': + DisableLanguageExtensions = _False; + break; + case 'c': + if ( third == ':' ) { + if ( fourth == 'f' ) + ForceConformanceInForLoopScope = _True; + else if ( fourth == 'w' ) + TreatWChar_tAsBuiltInType = _True; + else + found = FALSE; + } else { + found = FALSE; break; + } + break; + case 'g': + case 'm': + case 's': + AdditionalOptions += option; + break; + case 'p': + switch ( third ) + { + case '\0': + case '1': + StructMemberAlignment = alignSingleByte; + if ( fourth == '6' ) + StructMemberAlignment = alignSixteenBytes; + break; + case '2': + StructMemberAlignment = alignTwoBytes; + break; + case '4': + StructMemberAlignment = alignFourBytes; + break; + case '8': + StructMemberAlignment = alignEightBytes; + break; + default: + found = FALSE; break; + } + break; + default: + found = FALSE; break; + } + break; + case 'c': + if ( second == '\0' ) { + CompileOnly = _True; + } else if ( second == 'l' ) { + if ( *(option+5) == 'n' ) { + CompileAsManaged = managedAssembly; + TurnOffAssemblyGeneration = _True; + } else { + CompileAsManaged = managedAssembly; + } + } else { + found = FALSE; break; + } + break; + case 'd': + if ( second != 'r' ) { + found = FALSE; break; + } + CompileAsManaged = managedAssembly; + break; + case 'n': + if ( second == 'o' && third == 'B' && fourth == 'o' ) { + AdditionalOptions += "/noBool"; + break; + } + if ( second == 'o' && third == 'l' && fourth == 'o' ) { + SuppressStartupBanner = _True; + break; + } + found = FALSE; break; + case 'o': + if ( second == 'p' && third == 'e' && fourth == 'n' ) { + OpenMP = _True; + break; + } + found = FALSE; break; + case 's': + if ( second == 'h' && third == 'o' && fourth == 'w' ) { + ShowIncludes = _True; + break; + } + found = FALSE; break; + case 'u': + UndefineAllPreprocessorDefinitions = _True; + break; + case 'v': + if ( second == 'd' || second == 'm' ) { + AdditionalOptions += option; + break; + } + found = FALSE; break; + case 'w': + switch ( second ) { + case '\0': + WarningLevel = warningLevel_0; + break; + case 'd': + DisableSpecificWarnings += option+3; + break; + default: + AdditionalOptions += option; + } + break; + default: + found = FALSE; break; + } + if( !found ) + warn_msg( WarnLogic, "Could not parse Compiler option: %s", option ); + return TRUE; +} + +// VCLinkerTool ----------------------------------------------------- +VCLinkerTool::VCLinkerTool() + : EnableCOMDATFolding( optFoldingDefault ), + GenerateDebugInformation( unset ), + GenerateMapFile( unset ), + HeapCommitSize( -1 ), + HeapReserveSize( -1 ), + IgnoreAllDefaultLibraries( unset ), + IgnoreEmbeddedIDL( unset ), + IgnoreImportLibrary( _True ), + LargeAddressAware( addrAwareDefault ), + LinkDLL( unset ), + LinkIncremental( linkIncrementalDefault ), + LinkTimeCodeGeneration( unset ), + MapExports( unset ), + MapLines( unset ), + OptimizeForWindows98( optWin98Default ), + OptimizeReferences( optReferencesDefault ), + RegisterOutput( unset ), + ResourceOnlyDLL( unset ), + SetChecksum( unset ), + ShowProgress( linkProgressNotSet ), + StackCommitSize( -1 ), + StackReserveSize( -1 ), + SubSystem( subSystemNotSet ), + SupportUnloadOfDelayLoadedDLL( unset ), + SuppressStartupBanner( unset ), + SwapRunFromCD( unset ), + SwapRunFromNet( unset ), + TargetMachine( machineNotSet ), + TerminalServerAware( termSvrAwareDefault ), + TurnOffAssemblyGeneration( unset ), + TypeLibraryResourceID( 0 ) +{ +} + +TQTextStream &operator<<( TQTextStream &strm, const VCLinkerTool &tool ) +{ + strm << _begTool3; + strm << _VCLinkerToolName; + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, " " ); + strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " ); + strm << XPair( _AddModuleNamesToAssembly, tool.AddModuleNamesToAssembly ); + strm << SPair( _BaseAddress, tool.BaseAddress ); + strm << XPair( _DelayLoadDLLs, tool.DelayLoadDLLs ); + if ( tool.EnableCOMDATFolding != optFoldingDefault ) strm << EPair( _EnableCOMDATFolding, tool.EnableCOMDATFolding ); + strm << SPair( _EntryPointSymbol, tool.EntryPointSymbol ); + strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); + strm << SPair( _FunctionOrder, tool.FunctionOrder ); + strm << TPair( _GenerateDebugInformation, tool.GenerateDebugInformation ); + strm << TPair( _GenerateMapFile, tool.GenerateMapFile ); + if ( tool.HeapCommitSize != -1 ) strm << LPair( _HeapCommitSize, tool.HeapCommitSize ); + if ( tool.HeapReserveSize != -1 ) strm << LPair( _HeapReserveSize, tool.HeapReserveSize ); + strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); + strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); + strm << TPair( _IgnoreEmbeddedIDL, tool.IgnoreEmbeddedIDL ); + strm << TPair( _IgnoreImportLibrary, tool.IgnoreImportLibrary ); + strm << SPair( _ImportLibrary, tool.ImportLibrary ); + if ( tool.LargeAddressAware != addrAwareDefault ) strm << EPair( _LargeAddressAware, tool.LargeAddressAware ); + strm << TPair( _LinkDLL, tool.LinkDLL ); + if ( tool.LinkIncremental != linkIncrementalDefault ) strm << EPair( _LinkIncremental, tool.LinkIncremental ); + strm << TPair( _LinkTimeCodeGeneration, tool.LinkTimeCodeGeneration ); + strm << SPair( _LinkToManagedResourceFile, tool.LinkToManagedResourceFile ); + strm << TPair( _MapExports, tool.MapExports ); + strm << SPair( _MapFileName, tool.MapFileName ); + strm << TPair( _MapLines, tool.MapLines ); + strm << SPair( _MergedIDLBaseFileName, tool.MergedIDLBaseFileName ); + strm << SPair( _MergeSections, tool.MergeSections ); + strm << SPair( _MidlCommandFile, tool.MidlCommandFile ); + strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); + if ( tool.OptimizeForWindows98 != optWin98Default ) strm << EPair( _OptimizeForWindows98, tool.OptimizeForWindows98 ); + if ( tool.OptimizeReferences != optReferencesDefault ) strm << EPair( _OptimizeReferences, tool.OptimizeReferences ); + strm << SPair( _OutputFile, tool.OutputFile ); + strm << _ProgramDatabaseFile << tool.ProgramDatabaseFile << "\""; + strm << TPair( _RegisterOutput, tool.RegisterOutput ); + strm << TPair( _ResourceOnlyDLL, tool.ResourceOnlyDLL ); + strm << TPair( _SetChecksum, tool.SetChecksum ); + if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); + if ( tool.StackCommitSize != -1 ) strm << LPair( _StackCommitSize, tool.StackCommitSize ); + if ( tool.StackReserveSize != -1 ) strm << LPair( _StackReserveSize, tool.StackReserveSize ); + strm << SPair( _StripPrivateSymbols, tool.StripPrivateSymbols ); + strm << EPair( _SubSystem, tool.SubSystem ); + strm << TPair( _SupportUnloadOfDelayLoadedDLL, tool.SupportUnloadOfDelayLoadedDLL ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + strm << TPair( _SwapRunFromCD, tool.SwapRunFromCD ); + strm << TPair( _SwapRunFromNet, tool.SwapRunFromNet ); + if ( tool.TargetMachine != machineNotSet ) strm << EPair( _TargetMachine, tool.TargetMachine ); + if ( tool.TerminalServerAware != termSvrAwareDefault ) strm << EPair( _TerminalServerAware, tool.TerminalServerAware ); + strm << TPair( _TurnOffAssemblyGeneration, tool.TurnOffAssemblyGeneration ); + strm << SPair( _TypeLibraryFile, tool.TypeLibraryFile ); + if ( tool.TypeLibraryResourceID != rcUseDefault ) strm << LPair( _TypeLibraryResourceID, tool.TypeLibraryResourceID ); + strm << SPair( _Version4, tool.Version ); + strm << "/>"; + return strm; +} + +// Hashing routine to do fast option lookups ---- +// Slightly rewritten to stop on ':' ',' and '\0' +// Original routine in qtranslator.cpp ---------- +static uint elfHash( const char* name ) +{ + const uchar *k; + uint h = 0; + uint g; + + if ( name ) { + k = (const uchar *) name; + while ( (*k) && + (*k)!= ':' && + (*k)!=',' && + (*k)!=' ' ) { + h = ( h << 4 ) + *k++; + if ( (g = (h & 0xf0000000)) != 0 ) + h ^= g >> 24; + h &= ~g; + } + } + if ( !h ) + h = 1; + return h; +} + +//#define USE_DISPLAY_HASH +#ifdef USE_DISPLAY_HASH +static void displayHash( const char* str ) +{ + printf( "case 0x%07x: // %s\n break;\n", elfHash(str), str ); +} +#endif + +bool VCLinkerTool::parseOption( const char* option ) +{ +#ifdef USE_DISPLAY_HASH + // Main options + displayHash( "/ALIGN" ); displayHash( "/ALLOWBIND" ); displayHash( "/ASSEMBLYMODULE" ); + displayHash( "/ASSEMBLYRESOURCE" ); displayHash( "/BASE" ); displayHash( "/DEBUG" ); + displayHash( "/DEF" ); displayHash( "/DEFAULTLIB" ); displayHash( "/DELAY" ); + displayHash( "/DELAYLOAD" ); displayHash( "/DLL" ); displayHash( "/DRIVER" ); + displayHash( "/ENTRY" ); displayHash( "/EXETYPE" ); displayHash( "/EXPORT" ); + displayHash( "/FIXED" ); displayHash( "/FORCE" ); displayHash( "/HEAP" ); + displayHash( "/IDLOUT" ); displayHash( "/IGNOREIDL" ); displayHash( "/IMPLIB" ); + displayHash( "/INCLUDE" ); displayHash( "/INCREMENTAL" ); displayHash( "/LARGEADDRESSAWARE" ); + displayHash( "/LIBPATH" ); displayHash( "/LTCG" ); displayHash( "/MACHINE" ); + displayHash( "/MAP" ); displayHash( "/MAPINFO" ); displayHash( "/MERGE" ); + displayHash( "/MIDL" ); displayHash( "/NOASSEMBLY" ); displayHash( "/NODEFAULTLIB" ); + displayHash( "/NOENTRY" ); displayHash( "/NOLOGO" ); displayHash( "/OPT" ); + displayHash( "/ORDER" ); displayHash( "/OUT" ); displayHash( "/PDB" ); + displayHash( "/PDBSTRIPPED" ); displayHash( "/RELEASE" ); displayHash( "/SECTION" ); + displayHash( "/STACK" ); displayHash( "/STUB" ); displayHash( "/SUBSYSTEM" ); + displayHash( "/SWAPRUN" ); displayHash( "/TLBID" ); displayHash( "/TLBOUT" ); + displayHash( "/TSAWARE" ); displayHash( "/VERBOSE" ); displayHash( "/VERSION" ); + displayHash( "/VXD" ); displayHash( "/WS " ); +#endif +#ifdef USE_DISPLAY_HASH + // Sub options + displayHash( "UNLOAD" ); displayHash( "NOBIND" ); displayHash( "no" ); displayHash( "NOSTATUS" ); displayHash( "STATUS" ); + displayHash( "AM33" ); displayHash( "ARM" ); displayHash( "CEE" ); displayHash( "IA64" ); displayHash( "X86" ); displayHash( "M32R" ); + displayHash( "MIPS" ); displayHash( "MIPS16" ); displayHash( "MIPSFPU" ); displayHash( "MIPSFPU16" ); displayHash( "MIPSR41XX" ); displayHash( "PPC" ); + displayHash( "SH3" ); displayHash( "SH4" ); displayHash( "SH5" ); displayHash( "THUMB" ); displayHash( "TRICORE" ); displayHash( "EXPORTS" ); + displayHash( "LINES" ); displayHash( "REF" ); displayHash( "NOREF" ); displayHash( "ICF" ); displayHash( "WIN98" ); displayHash( "NOWIN98" ); + displayHash( "CONSOLE" ); displayHash( "EFI_APPLICATION" ); displayHash( "EFI_BOOT_SERVICE_DRIVER" ); displayHash( "EFI_ROM" ); displayHash( "EFI_RUNTIME_DRIVER" ); displayHash( "NATIVE" ); + displayHash( "POSIX" ); displayHash( "WINDOWS" ); displayHash( "WINDOWSCE" ); displayHash( "NET" ); displayHash( "CD" ); displayHash( "NO" ); +#endif + bool found = TRUE; + switch ( elfHash(option) ) { + case 0x3360dbe: // /ALIGN[:number] + case 0x1485c34: // /ALLOWBIND[:NO] + case 0x6b21972: // /DEFAULTLIB:library + case 0x396ea92: // /DRIVER[:UPONLY | :WDM] + case 0xaca9d75: // /EXETYPE[:DYNAMIC | :DEV386] + case 0x3ad5444: // /EXPORT:entryname[,@ordinal[,NONAME]][,DATA] + case 0x33aec94: // /FIXED[:NO] + case 0x33b4675: // /FORCE:[MULTIPLE|UNRESOLVED] + case 0x7988f7e: // /SECTION:name,[E][R][W][S][D][K][L][P][X][,ALIGN=#] + case 0x0348992: // /STUB:filename + case 0x0034bc4: // /VXD + case 0x0034c50: // /WS + AdditionalOptions += option; + break; + case 0x679c075: // /ASSEMBLYMODULE:filename + AddModuleNamesToAssembly += option+15; + break; + case 0x062d065: // /ASSEMBLYRESOURCE:filename + LinkToManagedResourceFile = option+18; + break; + case 0x0336675: // /BASE:{address | @filename,key} + // Do we need to do a manual lookup when '@filename,key'? + // Seems BaseAddress only can contain the location... + // We don't use it in TQt, so keep it simple for now + BaseAddress = option+6; + break; + case 0x3389797: // /DEBUG + GenerateDebugInformation = _True; + break; + case 0x0033896: // /DEF:filename + ModuleDefinitionFile = option+5; + break; + case 0x338a069: // /DELAY:{UNLOAD | NOBIND} + // MS documentation does not specify what to do with + // this option, so we'll put it in AdditionalOptions + AdditionalOptions += option; + break; + case 0x06f4bf4: // /DELAYLOAD:dllname + DelayLoadDLLs += option+11; + break; + // case 0x003390c: // /DLL + // This option is not used for vcproj files + // break; + case 0x33a3979: // /ENTRY:function + EntryPointSymbol = option+7; + break; + case 0x033c960: // /HEAP:reserve[,commit] + { + TQStringList both = TQStringList::split( ",", option+6 ); + HeapReserveSize = both[0].toLong(); + if ( both.count() == 2 ) + HeapCommitSize = both[1].toLong(); + } + break; + case 0x3d91494: // /IDLOUT:[path\]filename + MergedIDLBaseFileName = option+8; + break; + case 0x345a04c: // /IGNOREIDL + IgnoreEmbeddedIDL = _True; + break; + case 0x3e250e2: // /IMPLIB:filename + ImportLibrary = option+8; + break; + case 0xe281ab5: // /INCLUDE:symbol + ForceSymbolReferences += option+9; + break; + case 0xb28103c: // /INCREMENTAL[:no] + if ( *(option+12) == ':' && + *(option+13) == 'n' ) + LinkIncremental = linkIncrementalNo; + else + LinkIncremental = linkIncrementalYes; + break; + case 0x26e4675: // /LARGEADDRESSAWARE[:no] + if ( *(option+18) == ':' && + *(option+19) == 'n' ) + LargeAddressAware = addrAwareNoLarge; + else + LargeAddressAware = addrAwareLarge; + break; + case 0x0d745c8: // /LIBPATH:dir + AdditionalLibraryDirectories += option+9; + break; + case 0x0341877: // /LTCG[:NOSTATUS|:STATUS] + config->WholeProgramOptimization = _True; + LinkTimeCodeGeneration = _True; + if ( *(option+5) == ':' && + *(option+6) == 'S' ) + ShowProgress = linkProgressAll; + break; + case 0x157cf65: // /MACHINE:{AM33|ARM|CEE|IA64|X86|M32R|MIPS|MIPS16|MIPSFPU|MIPSFPU16|MIPSR41XX|PPC|SH3|SH4|SH5|THUMB|TRICORE} + switch ( elfHash(option+9) ) { + // Very limited documentation on all options but X86, + // so we put the others in AdditionalOptions... + case 0x0046063: // AM33 + case 0x000466d: // ARM + case 0x0004795: // CEE + case 0x004d494: // IA64 + case 0x0050672: // M32R + case 0x0051e53: // MIPS + case 0x51e5646: // MIPS16 + case 0x1e57b05: // MIPSFPU + case 0x57b09a6: // MIPSFPU16 + case 0x5852738: // MIPSR41XX + case 0x0005543: // PPC + case 0x00057b3: // SH3 + case 0x00057b4: // SH4 + case 0x00057b5: // SH5 + case 0x058da12: // THUMB + case 0x96d8435: // TRICORE + AdditionalOptions += option; + break; + case 0x0005bb6: // X86 + TargetMachine = machineX86; + break; + default: + found = FALSE; + } + break; + case 0x0034160: // /MAP[:filename] + GenerateMapFile = _True; + MapFileName = option+5; + break; + case 0x164e1ef: // /MAPINFO:{EXPORTS|LINES} + if ( *(option+9) == 'E' ) + MapExports = _True; + else if ( *(option+9) == 'L' ) + MapLines = _True; + break; + case 0x341a6b5: // /MERGE:from=to + MergeSections = option+7; + break; + case 0x0341d8c: // /MIDL:@file + MidlCommandFile = option+7; + break; + case 0x84e2679: // /NOASSEMBLY + TurnOffAssemblyGeneration = _True; + break; + case 0x2b21942: // /NODEFAULTLIB[:library] + if ( *(option+13) == '\0' ) + IgnoreAllDefaultLibraries = _True; + else + IgnoreDefaultLibraryNames += option+14; + break; + case 0x33a3a39: // /NOENTRY + ResourceOnlyDLL = _True; + break; + case 0x434138f: // /NOLOGO + SuppressStartupBanner = _True; + break; + case 0x0034454: // /OPT:{REF | NOREF | ICF[=iterations] | NOICF | WIN98 | NOWIN98} + { + char third = *(option+7); + switch ( third ) { + case 'F': // REF + if ( *(option+5) == 'R' ) { + OptimizeReferences = optReferences; + } else { // ICF[=iterations] + EnableCOMDATFolding = optFolding; + // [=iterations] case is not documented + } + break; + case 'R': // NOREF + OptimizeReferences = optNoReferences; + break; + case 'I': // NOICF + EnableCOMDATFolding = optNoFolding; + break; + case 'N': // WIN98 + OptimizeForWindows98 = optWin98Yes; + break; + case 'W': // NOWIN98 + OptimizeForWindows98 = optWin98No; + break; + default: + found = FALSE; + } + } + break; + case 0x34468a2: // /ORDER:@filename + FunctionOrder = option+8; + break; + case 0x00344a4: // /OUT:filename + OutputFile = option+5; + break; + case 0x0034482: // /PDB:filename + ProgramDatabaseFile = option+5; + break; + case 0xa2ad314: // /PDBSTRIPPED:pdb_file_name + StripPrivateSymbols = option+13; + break; + case 0x6a09535: // /RELEASE + SetChecksum = _True; + break; + case 0x348857b: // /STACK:reserve[,commit] + { + TQStringList both = TQStringList::split( ",", option+7 ); + StackReserveSize = both[0].toLong(); + if ( both.count() == 2 ) + StackCommitSize = both[1].toLong(); + } + break; + case 0x78dc00d: // /SUBSYSTEM:{CONSOLE|EFI_APPLICATION|EFI_BOOT_SERVICE_DRIVER|EFI_ROM|EFI_RUNTIME_DRIVER|NATIVE|POSIX|WINDOWS|WINDOWSCE}[,major[.minor]] + { + // Split up in subsystem, and version number + TQStringList both = TQStringList::split( ",", option+11 ); + switch ( elfHash(both[0].latin1()) ) { + case 0x8438445: // CONSOLE + SubSystem = subSystemConsole; + break; + case 0xbe29493: // WINDOWS + SubSystem = subSystemWindows; + break; + // The following are undocumented, so add them to AdditionalOptions + case 0x240949e: // EFI_APPLICATION + case 0xe617652: // EFI_BOOT_SERVICE_DRIVER + case 0x9af477d: // EFI_ROM + case 0xd34df42: // EFI_RUNTIME_DRIVER + case 0x5268ea5: // NATIVE + case 0x05547e8: // POSIX + case 0x2949c95: // WINDOWSCE + AdditionalOptions += option; + break; + default: + found = FALSE; + } + } + break; + case 0x8b654de: // /SWAPRUN:{NET | CD} + if ( *(option+9) == 'N' ) + SwapRunFromNet = _True; + else if ( *(option+9) == 'C' ) + SwapRunFromCD = _True; + else + found = FALSE; + break; + case 0x34906d4: // /TLBID:id + TypeLibraryResourceID = TQString( option+7 ).toLong(); + break; + case 0x4907494: // /TLBOUT:[path\]filename + TypeLibraryFile = option+8; + break; + case 0x976b525: // /TSAWARE[:NO] + if ( *(option+8) == ':' ) + TerminalServerAware = termSvrAwareNo; + else + TerminalServerAware = termSvrAwareYes; + break; + case 0xaa67735: // /VERBOSE[:lib] + if ( *(option+9) == ':' ) { + ShowProgress = linkProgressLibs; + AdditionalOptions += option; + } else { + ShowProgress = linkProgressAll; + } + break; + case 0xaa77f7e: // /VERSION:major[.minor] + Version = option+9; + break; + default: + found = FALSE; + } + if( !found ) + warn_msg( WarnLogic, "Could not parse Linker options: %s", option ); + return found; +} + +// VCMIDLTool ------------------------------------------------------- +VCMIDLTool::VCMIDLTool() + : DefaultCharType( midlCharUnsigned ), + EnableErrorChecks( midlDisableAll ), + ErrorCheckAllocations( unset ), + ErrorCheckBounds( unset ), + ErrorCheckEnumRange( unset ), + ErrorCheckRefPointers( unset ), + ErrorCheckStubData( unset ), + GenerateStublessProxies( unset ), + GenerateTypeLibrary( unset ), + IgnoreStandardIncludePath( unset ), + MkTypLibCompatible( unset ), + StructMemberAlignment( midlAlignNotSet ), + SuppressStartupBanner( unset ), + TargetEnvironment( midlTargetNotSet ), + ValidateParameters( unset ), + WarnAsError( unset ), + WarningLevel( midlWarningLevel_0 ) +{ +} + +TQTextStream &operator<<( TQTextStream &strm, const VCMIDLTool &tool ) +{ + strm << _begTool3; + strm << _VCMIDLToolName; + strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " ); + strm << XPair( _CPreprocessOptions, tool.CPreprocessOptions ); + strm << EPair( _DefaultCharType, tool.DefaultCharType ); + strm << SPair( _DLLDataFileName, tool.DLLDataFileName ); + strm << EPair( _EnableErrorChecks, tool.EnableErrorChecks ); + strm << TPair( _ErrorCheckAllocations, tool.ErrorCheckAllocations ); + strm << TPair( _ErrorCheckBounds, tool.ErrorCheckBounds ); + strm << TPair( _ErrorCheckEnumRange, tool.ErrorCheckEnumRange ); + strm << TPair( _ErrorCheckRefPointers, tool.ErrorCheckRefPointers ); + strm << TPair( _ErrorCheckStubData, tool.ErrorCheckStubData ); + strm << XPair( _FullIncludePath, tool.FullIncludePath ); + strm << TPair( _GenerateStublessProxies, tool.GenerateStublessProxies ); + strm << TPair( _GenerateTypeLibrary, tool.GenerateTypeLibrary ); + strm << SPair( _HeaderFileName, tool.HeaderFileName ); + strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); + strm << SPair( _InterfaceIdentifierFileName, tool.InterfaceIdentifierFileName ); + strm << TPair( _MkTypLibCompatible, tool.MkTypLibCompatible ); + strm << SPair( _OutputDirectory4, tool.OutputDirectory ); + strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); + strm << SPair( _ProxyFileName, tool.ProxyFileName ); + strm << SPair( _RedirectOutputAndErrors, tool.RedirectOutputAndErrors ); + if ( tool.StructMemberAlignment != midlAlignNotSet) strm << EPair( _StructMemberAlignment, tool.StructMemberAlignment ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + if ( tool.TargetEnvironment != midlTargetNotSet ) strm << EPair( _TargetEnvironment, tool.TargetEnvironment ); + strm << SPair( _TypeLibraryName, tool.TypeLibraryName ); + strm << XPair( _UndefinePreprocessorDefinitions, tool.UndefinePreprocessorDefinitions ); + strm << TPair( _ValidateParameters, tool.ValidateParameters ); + strm << TPair( _WarnAsError, tool.WarnAsError ); + strm << EPair( _WarningLevel, tool.WarningLevel ); + strm << "/>"; + return strm; +} + +bool VCMIDLTool::parseOption( const char* option ) +{ +#ifdef USE_DISPLAY_HASH + displayHash( "/D name[=def]" ); displayHash( "/I directory-list" ); displayHash( "/Oi" ); + displayHash( "/Oic" ); displayHash( "/Oicf" ); displayHash( "/Oif" ); displayHash( "/Os" ); + displayHash( "/U name" ); displayHash( "/WX" ); displayHash( "/W{0|1|2|3|4}" ); + displayHash( "/Zp {N}" ); displayHash( "/Zs" ); displayHash( "/acf filename" ); + displayHash( "/align {N}" ); displayHash( "/app_config" ); displayHash( "/c_ext" ); + displayHash( "/char ascii7" ); displayHash( "/char signed" ); displayHash( "/char unsigned" ); + displayHash( "/client none" ); displayHash( "/client stub" ); displayHash( "/confirm" ); + displayHash( "/cpp_cmd cmd_line" ); displayHash( "/cpp_opt options" ); + displayHash( "/cstub filename" ); displayHash( "/dlldata filename" ); displayHash( "/env win32" ); + displayHash( "/env win64" ); displayHash( "/error all" ); displayHash( "/error allocation" ); + displayHash( "/error bounds_check" ); displayHash( "/error enum" ); displayHash( "/error none" ); + displayHash( "/error ref" ); displayHash( "/error stub_data" ); displayHash( "/h filename" ); + displayHash( "/header filename" ); displayHash( "/iid filename" ); displayHash( "/lcid" ); + displayHash( "/mktyplib203" ); displayHash( "/ms_ext" ); displayHash( "/ms_union" ); + displayHash( "/msc_ver <nnnn>" ); displayHash( "/newtlb" ); displayHash( "/no_cpp" ); + displayHash( "/no_def_idir" ); displayHash( "/no_default_epv" ); displayHash( "/no_format_opt" ); + displayHash( "/no_warn" ); displayHash( "/nocpp" ); displayHash( "/nologo" ); displayHash( "/notlb" ); + displayHash( "/o filename" ); displayHash( "/oldnames" ); displayHash( "/oldtlb" ); + displayHash( "/osf" ); displayHash( "/out directory" ); displayHash( "/pack {N}" ); + displayHash( "/prefix all" ); displayHash( "/prefix client" ); displayHash( "/prefix server" ); + displayHash( "/prefix switch" ); displayHash( "/protocol all" ); displayHash( "/protocol dce" ); + displayHash( "/protocol ndr64" ); displayHash( "/proxy filename" ); displayHash( "/robust" ); + displayHash( "/rpcss" ); displayHash( "/savePP" ); displayHash( "/server none" ); + displayHash( "/server stub" ); displayHash( "/sstub filename" ); displayHash( "/syntax_check" ); + displayHash( "/target {system}" ); displayHash( "/tlb filename" ); displayHash( "/use_epv" ); + displayHash( "/win32" ); displayHash( "/win64" ); +#endif + bool found = TRUE; + int offset = 0; + switch( elfHash(option) ) { + case 0x0000334: // /D name[=def] + PreprocessorDefinitions += option+3; + break; + case 0x0000339: // /I directory-list + AdditionalIncludeDirectories += option+3; + break; + case 0x0345f96: // /Oicf + case 0x00345f6: // /Oif + GenerateStublessProxies = _True; + break; + case 0x0000345: // /U name + UndefinePreprocessorDefinitions += option+3; + break; + case 0x00034c8: // /WX + WarnAsError = _True; + break; + case 0x3582fde: // /align {N} + offset = 3; // Fallthrough + case 0x0003510: // /Zp {N} + switch ( *(option+offset+4) ) { + case '1': + StructMemberAlignment = ( *(option+offset+5) == '\0' ) ? midlAlignSingleByte : midlAlignSixteenBytes; + break; + case '2': + StructMemberAlignment = midlAlignTwoBytes; + break; + case '4': + StructMemberAlignment = midlAlignFourBytes; + break; + case '8': + StructMemberAlignment = midlAlignEightBytes; + break; + default: + found = FALSE; + } + break; + case 0x0359e82: // /char {ascii7|signed|unsigned} + switch( *(option+6) ) { + case 'a': + DefaultCharType = midlCharAscii7; + break; + case 's': + DefaultCharType = midlCharSigned; + break; + case 'u': + DefaultCharType = midlCharUnsigned; + break; + default: + found = FALSE; + } + break; + case 0xa766524: // /cpp_opt options + CPreprocessOptions += option+9; + break; + case 0xb32abf1: // /dlldata filename + DLLDataFileName = option + 9; + break; + case 0x0035c56: // /env {win32|win64} + TargetEnvironment = ( *(option+8) == '6' ) ? midlTargetWin64 : midlTargetWin32; + break; + case 0x35c9962: // /error {all|allocation|bounds_check|enum|none|ref|stub_data} + EnableErrorChecks = midlEnableCustom; + switch ( *(option+7) ) { + case 'a': + if ( *(option+10) == '\0' ) + EnableErrorChecks = midlEnableAll; + else + ErrorCheckAllocations = _True; + break; + case 'b': + ErrorCheckBounds = _True; + break; + case 'e': + ErrorCheckEnumRange = _True; + break; + case 'n': + EnableErrorChecks = midlDisableAll; + break; + case 'r': + ErrorCheckRefPointers = _True; + break; + case 's': + ErrorCheckStubData = _True; + break; + default: + found = FALSE; + } + break; + case 0x5eb7af2: // /header filename + offset = 5; + case 0x0000358: // /h filename + HeaderFileName = option + offset + 3; + break; + case 0x0035ff4: // /iid filename + InterfaceIdentifierFileName = option+5; + break; + case 0x64b7933: // /mktyplib203 + MkTypLibCompatible = _True; + break; + case 0x8e0b0a2: // /no_def_idir + IgnoreStandardIncludePath = _True; + break; + case 0x65635ef: // /nologo + SuppressStartupBanner = _True; + break; + case 0x3656b22: // /notlb + GenerateTypeLibrary = _True; + break; + case 0x000035f: // /o filename + RedirectOutputAndErrors = option+3; + break; + case 0x00366c4: // /out directory + OutputDirectory = option+5; + break; + case 0x36796f9: // /proxy filename + ProxyFileName = option+7; + break; + case 0x6959c94: // /robust + ValidateParameters = _True; + break; + case 0x6a88df4: // /target {system} + if ( *(option+11) == '6' ) + TargetEnvironment = midlTargetWin64; + else + TargetEnvironment = midlTargetWin32; + break; + case 0x0036b22: // /tlb filename + TypeLibraryName = option+5; + break; + case 0x36e0162: // /win32 + TargetEnvironment = midlTargetWin32; + break; + case 0x36e0194: // /win64 + TargetEnvironment = midlTargetWin64; + break; + case 0x0003459: // /Oi + case 0x00345f3: // /Oic + case 0x0003463: // /Os + case 0x0003513: // /Zs + case 0x0035796: // /acf filename + case 0x5b1cb97: // /app_config + case 0x3595cf4: // /c_ext + case 0x5a2fc64: // /client {none|stub} + case 0xa64d3dd: // /confirm + case 0xa765b64: // /cpp_cmd cmd_line + case 0x35aabb2: // /cstub filename + case 0x03629f4: // /lcid + case 0x6495cc4: // /ms_ext + case 0x96c7a1e: // /ms_union + case 0x4996fa2: // /msc_ver <nnnn> + case 0x64ceb12: // /newtlb + case 0x6555a40: // /no_cpp + case 0xf64d6a6: // /no_default_epv + case 0x6dd9384: // /no_format_opt + case 0x556dbee: // /no_warn + case 0x3655a70: // /nocpp + case 0x2b455a3: // /oldnames + case 0x662bb12: // /oldtlb + case 0x0036696: // /osf + case 0x036679b: // /pack {N} + case 0x678bd38: // /prefix {all|client|server|switch} + case 0x96b702c: // /protocol {all|dce|ndr64} + case 0x3696aa3: // /rpcss + case 0x698ca60: // /savePP + case 0x69c9cf2: // /server {none|stub} + case 0x36aabb2: // /sstub filename + case 0xce9b12b: // /syntax_check + case 0xc9b5f16: // /use_epv + AdditionalOptions += option; + break; + default: + // /W{0|1|2|3|4} case + if ( *(option+1) == 'W' ) { + switch ( *(option+2) ) { + case '0': + WarningLevel = midlWarningLevel_0; + break; + case '1': + WarningLevel = midlWarningLevel_1; + break; + case '2': + WarningLevel = midlWarningLevel_2; + break; + case '3': + WarningLevel = midlWarningLevel_3; + break; + case '4': + WarningLevel = midlWarningLevel_4; + break; + default: + found = FALSE; + } + } + break; + } + if( !found ) + warn_msg( WarnLogic, "Could not parse MIDL option: %s", option ); + return TRUE; +} + +// VCLibrarianTool -------------------------------------------------- +VCLibrarianTool::VCLibrarianTool() + : IgnoreAllDefaultLibraries( unset ), + SuppressStartupBanner( _True ) +{ +} + +TQTextStream &operator<<( TQTextStream &strm, const VCLibrarianTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, TQString( "VCLibrarianTool" ) ); + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies ); + strm << XPair( _AdditionalLibraryDirectories, tool.AdditionalLibraryDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " ); + strm << XPair( _ExportNamedFunctions, tool.ExportNamedFunctions ); + strm << XPair( _ForceSymbolReferences, tool.ForceSymbolReferences ); + strm << TPair( _IgnoreAllDefaultLibraries, tool.IgnoreAllDefaultLibraries ); + strm << XPair( _IgnoreDefaultLibraryNames, tool.IgnoreDefaultLibraryNames ); + strm << SPair( _ModuleDefinitionFile, tool.ModuleDefinitionFile ); + strm << SPair( _OutputFile, tool.OutputFile ); + strm << TPair( _SuppressStartupBanner, tool.SuppressStartupBanner ); + strm << "/>"; + return strm; +} + +// VCCustomBuildTool ------------------------------------------------ +VCCustomBuildTool::VCCustomBuildTool() +{ + ToolName = "VCCustomBuildTool"; +} + +TQTextStream &operator<<( TQTextStream &strm, const VCCustomBuildTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, tool.ToolName ); + strm << XPair( _AdditionalDependencies4, tool.AdditionalDependencies, ";" ); + + if (which_dotnet_version() == NET2005) + strm << XPair( _CommandLine4, tool.CommandLine, "
" ); + else + strm << XPair( _CommandLine4, tool.CommandLine, "\n" ); + + strm << SPair( _Description4, tool.Description ); + strm << XPair( _Outputs4, tool.Outputs, ";" ); + strm << SPair( _ToolPath, tool.ToolPath ); + strm << "/>"; + return strm; +} + +// VCResourceCompilerTool ------------------------------------------- +VCResourceCompilerTool::VCResourceCompilerTool() + : Culture( rcUseDefault ), + IgnoreStandardIncludePath( unset ), + ShowProgress( linkProgressNotSet ) +{ + PreprocessorDefinitions = "NDEBUG"; +} + +TQTextStream &operator<<( TQTextStream &strm, const VCResourceCompilerTool &tool ) +{ + strm << _begTool3; + strm << _VCResourceCompilerToolName; + strm << SPair( _ToolPath, tool.ToolPath ); + strm << XPair( _AdditionalIncludeDirectories, tool.AdditionalIncludeDirectories ); + strm << XPair( _AdditionalOptions, tool.AdditionalOptions, " " ); + if ( tool.Culture != rcUseDefault ) strm << EPair( _Culture, tool.Culture ); + strm << XPair( _FullIncludePath, tool.FullIncludePath ); + strm << TPair( _IgnoreStandardIncludePath, tool.IgnoreStandardIncludePath ); + strm << XPair( _PreprocessorDefinitions, tool.PreprocessorDefinitions ); + strm << SPair( _ResourceOutputFileName, tool.ResourceOutputFileName ); + if ( tool.ShowProgress != linkProgressNotSet ) strm << EPair( _ShowProgress, tool.ShowProgress ); + strm << "/>"; + return strm; +} + +// VCEventTool ------------------------------------------------- +TQTextStream &operator<<( TQTextStream &strm, const VCEventTool &tool ) +{ + strm << _begTool3; + strm << SPair( _ToolName, tool.ToolName ); + strm << SPair( _ToolPath, tool.ToolPath ); + strm << SPair( _CommandLine4, tool.CommandLine ); + strm << SPair( _Description4, tool.Description ); + strm << TPair( _ExcludedFromBuild, tool.ExcludedFromBuild ); + strm << "/>"; + return strm; +} + +// VCPostBuildEventTool --------------------------------------------- +VCPostBuildEventTool::VCPostBuildEventTool() +{ + ToolName = "VCPostBuildEventTool"; +} + +// VCPreBuildEventTool ---------------------------------------------- +VCPreBuildEventTool::VCPreBuildEventTool() +{ + ToolName = "VCPreBuildEventTool"; +} + +// VCPreLinkEventTool ----------------------------------------------- +VCPreLinkEventTool::VCPreLinkEventTool() +{ + ToolName = "VCPreLinkEventTool"; +} + +// VCConfiguration -------------------------------------------------- + +VCConfiguration::VCConfiguration() + : ATLMinimizesCRunTimeLibraryUsage( unset ), + BuildBrowserInformation( unset ), + CharacterSet( charSetNotSet ), + ConfigurationType( typeApplication ), + RegisterOutput( unset ), + UseOfATL( useATLNotSet ), + UseOfMfc( useMfcStdWin ), + WholeProgramOptimization( unset ) +{ + compiler.config = this; + linker.config = this; + idl.config = this; +} + +VCConfiguration::VCConfiguration(const VCConfiguration &other) +{ + *this = other; + compiler.config = this; + linker.config = this; + idl.config = this; +} + +TQTextStream &operator<<( TQTextStream &strm, const VCConfiguration &tool ) +{ + strm << _begConfiguration; + strm << SPair( _Name3, tool.Name ); + strm << SPair( _OutputDirectory3, tool.OutputDirectory ); + strm << TPair( _ATLMinimizesCRunTimeLibraryUsage, tool.ATLMinimizesCRunTimeLibraryUsage ); + strm << TPair( _BuildBrowserInformation, tool.BuildBrowserInformation ); + if ( tool.CharacterSet != charSetNotSet) strm << EPair( _CharacterSet, tool.CharacterSet ); + strm << EPair( _ConfigurationType, tool.ConfigurationType ); + strm << SPair( _DeleteExtensionsOnClean, tool.DeleteExtensionsOnClean ); + strm << SPair( _ImportLibrary, tool.ImportLibrary ); + strm << SPair( _IntermediateDirectory, tool.IntermediateDirectory ); + strm << SPair( _PrimaryOutput, tool.PrimaryOutput ); + strm << SPair( _ProgramDatabase, tool.ProgramDatabase ); + strm << TPair( _RegisterOutput, tool.RegisterOutput ); + if ( tool.UseOfATL != useATLNotSet) strm << EPair( _UseOfATL, tool.UseOfATL ); + strm << EPair( _UseOfMfc, tool.UseOfMfc ); + strm << TPair( _WholeProgramOptimization, tool.WholeProgramOptimization ); + strm << ">"; + strm << tool.compiler; + strm << tool.custom; + if ( tool.ConfigurationType == typeStaticLibrary ) + strm << tool.librarian; + else + strm << tool.linker; + strm << tool.idl; + strm << tool.postBuild; + strm << tool.preBuild; + strm << tool.preLink; + strm << tool.resource; + strm << _endConfiguration; + return strm; +} +// VCFilter --------------------------------------------------------- +VCFilter::VCFilter() + : ParseFiles( unset ) +{ + useCustomBuildTool = FALSE; + useCompilerTool = FALSE; +} + +void VCFilter::addMOCstage( TQTextStream & /*strm*/, TQString filename ) +{ + TQString mocOutput = Project->findMocDestination( filename ); + TQString mocApp = Project->var( "QMAKE_MOC" ); + + bool inputMoc = false; + if( mocOutput.isEmpty() && filename.endsWith(".moc") ) { + // In specialcases we DO moc .cpp files + // when the result is an .moc file + mocOutput = filename; + filename = Project->findMocSource( mocOutput ); + inputMoc = true; + } + + if (mocOutput.isEmpty()) + return; + + CustomBuildTool = VCCustomBuildTool(); + useCustomBuildTool = TRUE; + CustomBuildTool.Description = "Moc'ing " + filename + "..."; + CustomBuildTool.CommandLine += (mocApp + " " + + filename + " -o " + mocOutput); + CustomBuildTool.AdditionalDependencies = mocApp; + if (inputMoc) + CustomBuildTool.AdditionalDependencies += filename; + CustomBuildTool.Outputs += mocOutput; +} + +void VCFilter::addUICstage( TQTextStream & /*strm*/, TQString str ) +{ + CustomBuildTool = VCCustomBuildTool(); + useCustomBuildTool = TRUE; + + TQString uicApp = Project->var("QMAKE_UIC"); + TQString mocApp = Project->var( "QMAKE_MOC" ); + TQString fname = str.section( '\\', -1 ); + TQString mocDir = Project->var( "MOC_DIR" ); + TQString uiDir = Project->var( "UI_DIR" ); + TQString uiHeaders; + TQString uiSources; + + // Determining the paths for the output files. + int slash = str.findRev( '\\' ); + TQString pname = ( slash != -1 ) ? str.left( slash+1 ) : TQString( ".\\" ); + if( !uiDir.isEmpty() ) { + uiHeaders = uiDir; + uiSources = uiDir; + } else { + uiHeaders = Project->var( "UI_HEADERS_DIR" ); + uiSources = Project->var( "UI_SOURCES_DIR" ); + if( uiHeaders.isEmpty() ) + uiHeaders = pname; + if( uiSources.isEmpty() ) + uiSources = pname; + } + if( !uiHeaders.endsWith( "\\" ) ) + uiHeaders += "\\"; + if( !uiSources.endsWith( "\\" ) ) + uiSources += "\\"; + + // Determine the file name. + int dot = fname.findRev( '.' ); + if( dot != -1 ) + fname.truncate( dot ); + + if ( mocDir.isEmpty() ) + mocDir = pname; + + CustomBuildTool.Description = ("Uic'ing " + str + "...\""); + CustomBuildTool.CommandLine += // Create .h from .ui file + uicApp + " " + str + " -o " + uiHeaders + fname + ".h"; + CustomBuildTool.CommandLine += // Create .cpp from .ui file + uicApp + " " + str + " -i " + fname + ".h -o " + uiSources + fname + ".cpp"; + CustomBuildTool.CommandLine += // Moc the headerfile + mocApp + " " + uiHeaders + fname + ".h -o " + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext; + + CustomBuildTool.AdditionalDependencies += mocApp; + CustomBuildTool.AdditionalDependencies += uicApp; + CustomBuildTool.Outputs += + uiHeaders + fname + ".h;" + uiSources + fname + ".cpp;" + mocDir + Option::h_moc_mod + fname + Option::h_moc_ext; +} + +void VCFilter::modifyPCHstage( TQTextStream &/*strm*/, TQString str ) +{ + bool isCFile = str.endsWith(".c"); + bool isHFile = (str.endsWith(".h") && str == Project->precompH); + + if (!isCFile && !isHFile) + return; + + CompilerTool = VCCLCompilerTool(); + useCompilerTool = TRUE; + + // Unset some default options + CompilerTool.BufferSecurityCheck = unset; + CompilerTool.DebugInformationFormat = debugUnknown; + CompilerTool.ExceptionHandling = unset; + CompilerTool.GeneratePreprocessedFile = preprocessUnknown; + CompilerTool.Optimization = optimizeDefault; + CompilerTool.ProgramDataBaseFileName = TQString::null; + CompilerTool.RuntimeLibrary = rtUnknown; + CompilerTool.WarningLevel = warningLevelUnknown; + + // Setup PCH options + CompilerTool.UsePrecompiledHeader = (isCFile ? pchNone : pchCreateUsingSpecific); + CompilerTool.PrecompiledHeaderThrough = "$(NOINHERIT)"; + CompilerTool.ForcedIncludeFiles = "$(NOINHERIT)"; +} + +bool VCFilter::addIMGstage( TQTextStream &/*strm*/, TQString str ) +{ + bool isCorH = FALSE; + if (str.endsWith(".c") || str.endsWith(".rc")) + isCorH = TRUE; + TQStringList::Iterator it; + for(it = Option::cpp_ext.begin(); it != Option::cpp_ext.end(); ++it) + if(str.endsWith(*it)) + isCorH = TRUE; + for(it = Option::h_ext.begin(); it != Option::h_ext.end(); ++it) + if(str.endsWith(*it)) + isCorH = TRUE; + + TQString collectionName = Project->project->first("QMAKE_IMAGE_COLLECTION"); + if (str.isEmpty() || isCorH || collectionName.isEmpty()) + return FALSE; + + CustomBuildTool = VCCustomBuildTool(); + useCustomBuildTool = TRUE; + + // Some projects (like designer core) may have too many images to + // call uic directly. Therefor we have to create a temporary + // file, with the image list, and call uic with the -f option. + TQString tmpFileCmd = "echo "; + TQString tmpImageFilename = ".imgcol"; + TQStringList& list = Project->project->variables()["IMAGES"]; + bool firstOutput = TRUE; + it = list.begin(); + while( it!=list.end() ) { + tmpFileCmd += (*it) + " "; + ++it; + if (tmpFileCmd.length()>250 || it==list.end()) { + CustomBuildTool.CommandLine += tmpFileCmd + + (firstOutput?"> ":">> ") + + tmpImageFilename; + tmpFileCmd = "echo "; + firstOutput = FALSE; + } + } + + TQString uicApp = Project->var("QMAKE_UIC"); + TQString commandLine = uicApp + " -embed " + Project->project->first("QMAKE_ORIG_TARGET") + + " -f .imgcol -o " + collectionName; + + // The loop below is to avoid the resulting CommandLine buffer + // from being a size of between 2071-#char_replaced and 2102, + // as this triggers a buffer overflow bug in VS2003. As we only + // the only replacement we use in this buffer is one $(QTDIR), + // we assume this can be upto 256 characters long, making the + // lower-bound to be 1814 characters. So, if the buffer is + // between 1814 and 2103 bytes, the buffer is "padded" til it's + // over 2103 bytes in size. + int totalSize = CustomBuildTool.CommandLine.join(" ").length(); + while (totalSize > 1814 && totalSize < 2103) { + CustomBuildTool.CommandLine += + "echo \"Padding\" the Custom Build Step buffer to avoid a potentional " + "buffer overflow issue with VS2003 for buffer of 1814-2103 bytes > nul"; + totalSize = CustomBuildTool.CommandLine.join(" ").length(); + } + + CustomBuildTool.Description = ("Generate imagecollection"); + CustomBuildTool.CommandLine += commandLine; + CustomBuildTool.AdditionalDependencies += uicApp; + CustomBuildTool.AdditionalDependencies += list; + CustomBuildTool.Outputs = collectionName; + CustomBuildTool.Outputs += tmpImageFilename; + return TRUE; +} + +bool VCFilter::addLexYaccStage( TQTextStream &/*strm*/, TQString str ) +{ + bool doLex = str.endsWith(".l"); + if (!doLex && !str.endsWith(".y")) + return FALSE; + + TQString fname = "$(InputName)"; + if (doLex) { + fname += Option::lex_mod + Option::cpp_ext.first(); + TQString lexpath = Project->var("QMAKE_LEX") + + Project->varGlue("QMAKE_LEXFLAGS", " ", " ", "") + " "; + + CustomBuildTool.Description = "Lex'ing $(InputFileName)"; + CustomBuildTool.CommandLine = lexpath + " $(InputFileName)"; + CustomBuildTool.CommandLine += "del " + fname; + CustomBuildTool.CommandLine += "move lex.yy.c " + fname; + CustomBuildTool.Outputs = fname; + } else { + fname +=Option::yacc_mod; + TQString yaccpath = Project->var("QMAKE_YACC") + + Project->varGlue("QMAKE_YACCFLAGS", " ", " ", "") + " "; + + CustomBuildTool.Description = "Yacc'ing $(InputFileName)"; + CustomBuildTool.CommandLine = yaccpath + " $(InputFileName)"; + CustomBuildTool.CommandLine += "del " + fname + Option::h_ext.first(); + CustomBuildTool.CommandLine += "move y.tab.h " + fname + Option::h_ext.first(); + CustomBuildTool.Outputs = fname + Option::h_ext.first(); + CustomBuildTool.CommandLine += "del " + fname + Option::cpp_ext.first(); + CustomBuildTool.CommandLine += "move y.tab.c " + fname + Option::cpp_ext.first(); + CustomBuildTool.Outputs += fname + Option::cpp_ext.first(); + } + useCustomBuildTool = TRUE; + return TRUE; +} + +TQTextStream &operator<<( TQTextStream &strm, VCFilter &tool ) +{ + if ( tool.Files.count() == 0 ) + return strm; + + strm << _begFilter; + strm << SPair( _Name3, tool.Name ); + strm << TPair( _ParseFiles, tool.ParseFiles ); + strm << SPair( _Filter, tool.Filter ); + strm << ">"; + + bool resourceBuild = FALSE; + int currentLevels = 0; + TQStringList currentDirs; + for ( TQStringList::ConstIterator it = tool.Files.begin(); it != tool.Files.end(); ++it ) { + if ( !tool.flat_files ) { + TQStringList newDirs = TQStringList::split('\\',(*it)); + newDirs.pop_back(); // Skip the filename + + int newLevels = int(newDirs.count()); + int equalLevels = 0; + for (int i = 0; i<currentLevels; i++, equalLevels++ ) + if (currentDirs[i] != newDirs[i]) + break; + int closeFilters = currentLevels - equalLevels; + int openFilters = newLevels - equalLevels; + + // close previous non-equal filter + while ( closeFilters-- ) + strm << _endFilter; + + // open new non-equal filters + newLevels = 0; + while ( openFilters-- ) { + strm << _begFilter; + strm << SPair( _Name3, newDirs[equalLevels + newLevels] ); + strm << _Filter << "\">"; // Blank filter + ++newLevels; + } + currentDirs = newDirs; + currentLevels = int(newDirs.count()); + } + + tool.useCustomBuildTool = FALSE; + tool.useCompilerTool = FALSE; + // Add UIC, MOC and PCH stages to file + if ( tool.CustomBuild == moc ) + tool.addMOCstage( strm, *it ); + else if ( tool.CustomBuild == uic ) + tool.addUICstage( strm, *it ); + else if ( tool.CustomBuild == lexyacc ) + tool.addLexYaccStage( strm, *it ); + else if ( tool.CustomBuild == resource ) { + if (!resourceBuild) + resourceBuild = tool.addIMGstage(strm, *it); + } + if (tool.Project->usePCH) + tool.modifyPCHstage( strm, *it ); + + strm << _begFile; + strm << SPair( _RelativePath, *it ); + strm << ">"; + // Output custom build and compiler options + // for all configurations + if (tool.useCustomBuildTool || tool.useCompilerTool) { + for ( uint i = 0; i < tool.Config->count(); i++ ) { + strm << _begFileConfiguration; + strm << _Name5; + strm << (*tool.Config)[i].Name; + strm << "\">"; + if (tool.useCustomBuildTool) + strm << tool.CustomBuildTool; + if (tool.useCompilerTool) + strm << tool.CompilerTool; + strm << _endFileConfiguration; + } + } + strm << _endFile; + } + // close remaining open filters, in non-flat mode + while ( !tool.flat_files && currentLevels-- ) { + strm << _endFilter; + } + strm << _endFilter; + return strm; +} + +// VCProject -------------------------------------------------------- +VCProject::VCProject() +{ + VCConfiguration conf; + Configuration += conf ; // Release + //Configuration += conf ; // Debug added later, after Release init +} + +TQTextStream &operator<<( TQTextStream &strm, const VCProject &tool ) +{ + strm << _xmlInit; + strm << _begVisualStudioProject; + strm << _ProjectType; + strm << SPair( _Version1, tool.Version ); + strm << SPair( _Name1, tool.Name ); + strm << SPair( _ProjectGUID, tool.ProjectGUID ); + strm << SPair( _SccProjectName, tool.SccProjectName ); + strm << SPair( _SccLocalPath, tool.SccLocalPath ); + strm << ">"; + strm << _begPlatforms; + strm << _begPlatform; + strm << SPair( _Name3, tool.PlatformName ); + strm << "/>"; + strm << _endPlatforms; + strm << _begConfigurations; + for ( uint i = 0; i < tool.Configuration.count(); i++ ) + strm << tool.Configuration[i]; + strm << _endConfigurations; + strm << _begFiles; + strm << (VCFilter&)tool.SourceFiles; + strm << (VCFilter&)tool.HeaderFiles; + strm << (VCFilter&)tool.MOCFiles; + strm << (VCFilter&)tool.UICFiles; + strm << (VCFilter&)tool.FormFiles; + strm << (VCFilter&)tool.TranslationFiles; + strm << (VCFilter&)tool.LexYaccFiles; + strm << (VCFilter&)tool.ResourceFiles; + strm << _endFiles; + strm << _begGlobals; + strm << _endGlobals; + strm << _endVisualStudioProject; + return strm; +} diff --git a/qmake/generators/win32/msvc_objectmodel.h b/qmake/generators/win32/msvc_objectmodel.h new file mode 100644 index 000000000..759242345 --- /dev/null +++ b/qmake/generators/win32/msvc_objectmodel.h @@ -0,0 +1,801 @@ +/**************************************************************************** +** +** Definition of VCProject class. +** +** Copyright (C) 2002-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __MSVC_OBJECTMODEL_H__ +#define __MSVC_OBJECTMODEL_H__ + +#include "project.h" +#include <qstring.h> +#include <qstringlist.h> + +enum DotNET { + NETUnknown = 0, + NET2002 = 0x70, + NET2003 = 0x71, + NET2005 = 0x80 +}; + +/* + This Object model is of course VERY simplyfied, + and does not actually follow the original MSVC + object model. However, it fulfilles the basic + needs for qmake +*/ + +/* + If a triState value is 'unset' then the + corresponding property is not in the output, + forcing the tool to utilize default values. + False/True values will be in the output... +*/ +enum customBuildCheck { + none, + moc, + uic, + lexyacc, + resource +}; +enum triState { + unset = -1, + _False = 0, + _True = 1 +}; +enum addressAwarenessType { + addrAwareDefault, + addrAwareNoLarge, + addrAwareLarge +}; +enum asmListingOption { + asmListingNone, + asmListingAssemblyOnly, + asmListingAsmMachineSrc, + asmListingAsmMachine, + asmListingAsmSrc +}; +enum basicRuntimeCheckOption { + runtimeBasicCheckNone, + runtimeCheckStackFrame, + runtimeCheckUninitVariables, + runtimeBasicCheckAll +}; +enum browseInfoOption { + brInfoNone, + brAllInfo, + brNoLocalSymbols +}; +enum callingConventionOption { + callConventionDefault = -1, + callConventionCDecl, + callConventionFastCall, + callConventionStdCall +}; +enum charSet { + charSetNotSet, + charSetUnicode, + charSetMBCS +}; +enum compileAsManagedOptions { + managedDefault = -1, + managedAssembly = 2 +}; +enum CompileAsOptions{ + compileAsDefault, + compileAsC, + compileAsCPlusPlus +}; +enum ConfigurationTypes { + typeUnknown = 0, + typeApplication = 1, + typeDynamicLibrary = 2, + typeStaticLibrary = 4, + typeGeneric = 10 +}; +enum debugOption { + debugUnknown = -1, + debugDisabled, + debugOldStyleInfo, + debugLineInfoOnly, + debugEnabled, + debugEditAndContinue +}; +enum eAppProtectionOption { + eAppProtectUnchanged, + eAppProtectLow, + eAppProtectMedium, + eAppProtectHigh +}; +enum enumResourceLangID { + rcUseDefault = 0, + rcAfrikaans = 1078, + rcAlbanian = 1052, + rcArabicAlgeria = 5121, + rcArabicBahrain = 15361, + rcArabicEgypt = 3073, + rcArabicIraq = 2049, + rcArabicJordan = 11265, + rcArabicKuwait = 13313, + rcArabicLebanon = 12289, + rcArabicLibya = 4097, + rcArabicMorocco = 6145, + rcArabicOman = 8193, + rcArabicQatar = 16385, + rcArabicSaudi = 1025, + rcArabicSyria = 10241, + rcArabicTunisia = 7169, + rcArabicUnitedArabEmirates = 14337, + rcArabicYemen = 9217, + rcBasque = 1069, + rcBulgarian = 1026, + rcByelorussian = 1059, + rcCatalan = 1027, + rcChineseHongKong = 3076, + rcChinesePRC = 2052, + rcChineseSingapore = 4100, + rcChineseTaiwan = 1028, + rcCroatian = 1050, + rcCzech = 1029, + rcDanish = 1030, + rcDutchBelgium = 2067, + rcDutchStandard = 1043, + rcEnglishAustralia = 3081, + rcEnglishBritain = 2057, + rcEnglishCanada = 4105, + RcEnglishCaribbean = 9225, + rcEnglishIreland = 6153, + rcEnglishJamaica = 8201, + rcEnglishNewZealand = 5129, + rcEnglishSouthAfrica = 7177, + rcEnglishUS = 1033, + rcEstonian = 1061, + rcFarsi = 1065, + rcFinnish = 1035, + rcFrenchBelgium = 2060, + rcFrenchCanada = 3084, + rcFrenchLuxembourg = 5132, + rcFrenchStandard = 1036, + rcFrenchSwitzerland = 4108, + rcGermanAustria = 3079, + rcGermanLichtenstein = 5127, + rcGermanLuxembourg = 4103, + rcGermanStandard = 1031, + rcGermanSwitzerland = 2055, + rcGreek = 1032, + rcHebrew = 1037, + rcHungarian = 1038, + rcIcelandic = 1039, + rcIndonesian = 1057, + rcItalianStandard = 1040, + rcItalianSwitzerland = 2064, + rcJapanese = 1041, + rcKorean = 1042, + rcKoreanJohab = 2066, + rcLatvian = 1062, + rcLithuanian = 1063, + rcNorwegianBokmal = 1044, + rcNorwegianNynorsk = 2068, + rcPolish = 1045, + rcPortugueseBrazilian = 1046, + rcPortugueseStandard = 2070, + rcRomanian = 1048, + rcRussian = 1049, + rcSerbian = 2074, + rcSlovak = 1051, + rcSpanishArgentina = 11274, + rcSpanishBolivia = 16394, + rcSpanishChile = 13322, + rcSpanishColombia = 9226, + rcSpanishCostaRica = 5130, + rcSpanishDominicanRepublic = 7178, + rcSpanishEcuador = 12298, + rcSpanishGuatemala = 4106, + rcSpanishMexico = 2058, + rcSpanishModern = 3082, + rcSpanishPanama = 6154, + rcSpanishParaguay = 15370, + rcSpanishPeru = 10250, + rcSpanishTraditional = 1034, + rcSpanishUruguay = 14346, + rcSpanishVenezuela = 8202, + rcSwedish = 1053, + rcThai = 1054, + rcTurkish = 1055, + rcUkrainian = 1058, + rcUrdu = 1056 +}; +enum enumSccEvent { + eProjectInScc, + ePreDirtyNotification +}; +enum favorSizeOrSpeedOption { + favorNone, + favorSpeed, + favorSize +}; +enum genProxyLanguage { + genProxyNative, + genProxyManaged +}; +enum inlineExpansionOption { + expandDisable, + expandOnlyInline, + expandAnySuitable, + expandDefault // Not useful number, but stops the output +}; +enum linkIncrementalType { + linkIncrementalDefault, + linkIncrementalNo, + linkIncrementalYes +}; +enum linkProgressOption { + linkProgressNotSet, + linkProgressAll, + linkProgressLibs +}; +enum machineTypeOption { + machineNotSet, + machineX86 +}; +enum midlCharOption { + midlCharUnsigned, + midlCharSigned, + midlCharAscii7 +}; +enum midlErrorCheckOption { + midlEnableCustom, + midlDisableAll, + midlEnableAll +}; +enum midlStructMemberAlignOption { + midlAlignNotSet, + midlAlignSingleByte, + midlAlignTwoBytes, + midlAlignFourBytes, + midlAlignEightBytes, + midlAlignSixteenBytes +}; +enum midlTargetEnvironment { + midlTargetNotSet, + midlTargetWin32, + midlTargetWin64 +}; +enum midlWarningLevelOption { + midlWarningLevel_0, + midlWarningLevel_1, + midlWarningLevel_2, + midlWarningLevel_3, + midlWarningLevel_4 +}; +enum optFoldingType { + optFoldingDefault, + optNoFolding, + optFolding +}; +enum optimizeOption { + optimizeDisabled, + optimizeMinSpace, + optimizeMaxSpeed, + optimizeFull, + optimizeCustom, + optimizeDefault // Not useful number, but stops the output +}; +enum optRefType { + optReferencesDefault, + optNoReferences, + optReferences +}; +enum optWin98Type { + optWin98Default, + optWin98No, + optWin98Yes +}; +enum pchOption { + pchNone, + pchCreateUsingSpecific, + pchGenerateAuto, + pchUseUsingSpecific +}; +enum preprocessOption { + preprocessUnknown = -1, + preprocessNo, + preprocessYes, + preprocessNoLineNumbers +}; +enum ProcessorOptimizeOption { + procOptimizeBlended, + procOptimizePentium, + procOptimizePentiumProAndAbove +}; +enum RemoteDebuggerType { + DbgLocal, + DbgRemote, + DbgRemoteTCPIP +}; +enum runtimeLibraryOption { + rtUnknown = -1, + rtMultiThreaded, + rtMultiThreadedDebug, + rtMultiThreadedDLL, + rtMultiThreadedDebugDLL, + rtSingleThreaded, + rtSingleThreadedDebug +}; +enum structMemberAlignOption { + alignNotSet, + alignSingleByte, + alignTwoBytes, + alignFourBytes, + alignEightBytes, + alignSixteenBytes +}; +enum subSystemOption { + subSystemNotSet, + subSystemConsole, + subSystemWindows +}; +enum termSvrAwarenessType { + termSvrAwareDefault, + termSvrAwareNo, + termSvrAwareYes +}; +enum toolSetType { + toolSetUtility, + toolSetMakefile, + toolSetLinker, + toolSetLibrarian, + toolSetAll +}; +enum TypeOfDebugger { + DbgNativeOnly, + DbgManagedOnly, + DbgMixed, + DbgAuto +}; +enum useOfATL { + useATLNotSet, + useATLStatic, + useATLDynamic +}; +enum useOfMfc { + useMfcStdWin, + useMfcStatic, + useMfcDynamic +}; +enum warningLevelOption { + warningLevelUnknown = -1, + warningLevel_0, + warningLevel_1, + warningLevel_2, + warningLevel_3, + warningLevel_4 +}; + +class VCToolBase { +protected: + // Functions + VCToolBase(){}; + virtual ~VCToolBase(){} + virtual bool parseOption( const char* option ) = 0; +public: + void parseOptions( TQStringList& options ) { + for ( TQStringList::ConstIterator it=options.begin(); (it!=options.end()); it++ ) + parseOption( (*it).latin1() ); + } +}; + +class VCConfiguration; +class VCProject; + +class VCCLCompilerTool : public VCToolBase +{ +public: + // Functions + VCCLCompilerTool(); + virtual ~VCCLCompilerTool(){} + bool parseOption( const char* option ); + + // Variables + TQStringList AdditionalIncludeDirectories; + TQStringList AdditionalOptions; + TQStringList AdditionalUsingDirectories; + TQString AssemblerListingLocation; + asmListingOption AssemblerOutput; + basicRuntimeCheckOption BasicRuntimeChecks; + browseInfoOption BrowseInformation; + TQString BrowseInformationFile; + triState BufferSecurityCheck; + callingConventionOption CallingConvention; + CompileAsOptions CompileAs; + compileAsManagedOptions CompileAsManaged; + triState CompileOnly; + debugOption DebugInformationFormat; + triState DefaultCharIsUnsigned; + triState Detect64BitPortabilityProblems; + triState DisableLanguageExtensions; + TQStringList DisableSpecificWarnings; + triState EnableFiberSafeOptimizations; + triState EnableFunctionLevelLinking; + triState EnableIntrinsicFunctions; + triState ExceptionHandling; + triState ExpandAttributedSource; + favorSizeOrSpeedOption FavorSizeOrSpeed; + triState ForceConformanceInForLoopScope; + TQStringList ForcedIncludeFiles; + TQStringList ForcedUsingFiles; + preprocessOption GeneratePreprocessedFile; + triState GlobalOptimizations; + triState IgnoreStandardIncludePath; + triState ImproveFloatingPointConsistency; + inlineExpansionOption InlineFunctionExpansion; + triState KeepComments; + triState MinimalRebuild; + TQString ObjectFile; + triState OmitFramePointers; + triState OpenMP; + optimizeOption Optimization; + ProcessorOptimizeOption OptimizeForProcessor; + triState OptimizeForWindowsApplication; + TQString OutputFile; + TQString PrecompiledHeaderFile; + TQString PrecompiledHeaderThrough; + TQStringList PreprocessorDefinitions; + TQString ProgramDataBaseFileName; + runtimeLibraryOption RuntimeLibrary; + triState RuntimeTypeInfo; + triState ShowIncludes; + triState SmallerTypeCheck; + triState StringPooling; + structMemberAlignOption StructMemberAlignment; + triState SuppressStartupBanner; + triState TreatWChar_tAsBuiltInType; + triState TurnOffAssemblyGeneration; + triState UndefineAllPreprocessorDefinitions; + TQStringList UndefinePreprocessorDefinitions; + pchOption UsePrecompiledHeader; + triState WarnAsError; + warningLevelOption WarningLevel; + triState WholeProgramOptimization; + VCConfiguration* config; +}; + +class VCLinkerTool : public VCToolBase +{ +public: + // Functions + VCLinkerTool(); + virtual ~VCLinkerTool(){} + bool parseOption( const char* option ); + + // Variables + TQStringList AdditionalDependencies; + TQStringList AdditionalLibraryDirectories; + TQStringList AdditionalOptions; + TQStringList AddModuleNamesToAssembly; + TQString BaseAddress; + TQStringList DelayLoadDLLs; + optFoldingType EnableCOMDATFolding; + TQString EntryPointSymbol; + TQStringList ForceSymbolReferences; + TQString FunctionOrder; + triState GenerateDebugInformation; + triState GenerateMapFile; + long HeapCommitSize; + long HeapReserveSize; + triState IgnoreAllDefaultLibraries; + TQStringList IgnoreDefaultLibraryNames; + triState IgnoreEmbeddedIDL; + triState IgnoreImportLibrary; + TQString ImportLibrary; + addressAwarenessType LargeAddressAware; + triState LinkDLL; + linkIncrementalType LinkIncremental; + triState LinkTimeCodeGeneration; + TQString LinkToManagedResourceFile; + triState MapExports; + TQString MapFileName; + triState MapLines; + TQString MergedIDLBaseFileName; + TQString MergeSections; // Should be list? + TQString MidlCommandFile; + TQString ModuleDefinitionFile; // Should be list? + optWin98Type OptimizeForWindows98; + optRefType OptimizeReferences; + TQString OutputFile; + TQString ProgramDatabaseFile; + triState RegisterOutput; + triState ResourceOnlyDLL; + triState SetChecksum; + linkProgressOption ShowProgress; + long StackCommitSize; + long StackReserveSize; + TQString StripPrivateSymbols; // Should be list? + subSystemOption SubSystem; + triState SupportUnloadOfDelayLoadedDLL; + triState SuppressStartupBanner; + triState SwapRunFromCD; + triState SwapRunFromNet; + machineTypeOption TargetMachine; + termSvrAwarenessType TerminalServerAware; + triState TurnOffAssemblyGeneration; + TQString TypeLibraryFile; + long TypeLibraryResourceID; + TQString Version; + VCConfiguration* config; +}; + +class VCMIDLTool : public VCToolBase +{ +public: + // Functions + VCMIDLTool(); + virtual ~VCMIDLTool(){} + bool parseOption( const char* option ); + + // Variables + TQStringList AdditionalIncludeDirectories; + TQStringList AdditionalOptions; + TQStringList CPreprocessOptions; + midlCharOption DefaultCharType; + TQString DLLDataFileName; // Should be list? + midlErrorCheckOption EnableErrorChecks; + triState ErrorCheckAllocations; + triState ErrorCheckBounds; + triState ErrorCheckEnumRange; + triState ErrorCheckRefPointers; + triState ErrorCheckStubData; + TQStringList FullIncludePath; + triState GenerateStublessProxies; + triState GenerateTypeLibrary; + TQString HeaderFileName; + triState IgnoreStandardIncludePath; + TQString InterfaceIdentifierFileName; + triState MkTypLibCompatible; + TQString OutputDirectory; + TQStringList PreprocessorDefinitions; + TQString ProxyFileName; + TQString RedirectOutputAndErrors; + midlStructMemberAlignOption StructMemberAlignment; + triState SuppressStartupBanner; + midlTargetEnvironment TargetEnvironment; + TQString TypeLibraryName; + TQStringList UndefinePreprocessorDefinitions; + triState ValidateParameters; + triState WarnAsError; + midlWarningLevelOption WarningLevel; + VCConfiguration* config; +}; + +class VCLibrarianTool : public VCToolBase +{ +public: + // Functions + VCLibrarianTool(); + virtual ~VCLibrarianTool(){} + bool parseOption( const char* ){ return FALSE; }; + + // Variables + TQStringList AdditionalDependencies; + TQStringList AdditionalLibraryDirectories; + TQStringList AdditionalOptions; + TQStringList ExportNamedFunctions; + TQStringList ForceSymbolReferences; + triState IgnoreAllDefaultLibraries; + TQStringList IgnoreDefaultLibraryNames; + TQString ModuleDefinitionFile; + TQString OutputFile; + triState SuppressStartupBanner; +}; + +class VCCustomBuildTool : public VCToolBase +{ +public: + // Functions + VCCustomBuildTool(); + virtual ~VCCustomBuildTool(){} + bool parseOption( const char* ){ return FALSE; }; + + // Variables + TQStringList AdditionalDependencies; + TQStringList CommandLine; + TQString Description; + TQStringList Outputs; + TQString ToolName; + TQString ToolPath; +}; + +class VCResourceCompilerTool : public VCToolBase +{ +public: + // Functions + VCResourceCompilerTool(); + virtual ~VCResourceCompilerTool(){} + bool parseOption( const char* ){ return FALSE; }; + + // Variables + TQStringList AdditionalIncludeDirectories; + TQStringList AdditionalOptions; + enumResourceLangID Culture; + TQStringList FullIncludePath; + triState IgnoreStandardIncludePath; + TQStringList PreprocessorDefinitions; + TQString ResourceOutputFileName; + linkProgressOption ShowProgress; + TQString ToolPath; +}; + +class VCEventTool : public VCToolBase +{ +protected: + // Functions + VCEventTool() : ExcludedFromBuild( unset ){}; + virtual ~VCEventTool(){} + bool parseOption( const char* ){ return FALSE; }; + +public: + // Variables + TQString CommandLine; + TQString Description; + triState ExcludedFromBuild; + TQString ToolName; + TQString ToolPath; +}; + +class VCPostBuildEventTool : public VCEventTool +{ +public: + VCPostBuildEventTool(); + ~VCPostBuildEventTool(){} +}; + +class VCPreBuildEventTool : public VCEventTool +{ +public: + VCPreBuildEventTool(); + ~VCPreBuildEventTool(){} +}; + +class VCPreLinkEventTool : public VCEventTool +{ +public: + VCPreLinkEventTool(); + ~VCPreLinkEventTool(){} +}; + +class VCConfiguration +{ +public: + // Functions + VCConfiguration(); + VCConfiguration(const VCConfiguration &other); + ~VCConfiguration() {} + + // Variables + triState ATLMinimizesCRunTimeLibraryUsage; + triState BuildBrowserInformation; + charSet CharacterSet; + ConfigurationTypes ConfigurationType; + TQString DeleteExtensionsOnClean; + TQString ImportLibrary; + TQString IntermediateDirectory; + TQString Name; + TQString OutputDirectory; + TQString PrimaryOutput; + TQString ProgramDatabase; + triState RegisterOutput; + useOfATL UseOfATL; + useOfMfc UseOfMfc; + triState WholeProgramOptimization; + + // XML sub-parts + VCCLCompilerTool compiler; + VCLinkerTool linker; + VCLibrarianTool librarian; + VCCustomBuildTool custom; + VCMIDLTool idl; + VCPostBuildEventTool postBuild; + VCPreBuildEventTool preBuild; + VCPreLinkEventTool preLink; + VCResourceCompilerTool resource; +}; + +class VcprojGenerator; +class VCFilter +{ +public: + // Functions + VCFilter(); + ~VCFilter(){} + void addMOCstage( TQTextStream &strm, TQString str ); + void addUICstage( TQTextStream &strm, TQString str ); + bool addIMGstage( TQTextStream &strm, TQString str ); + void modifyPCHstage( TQTextStream &strm, TQString str ); + bool addLexYaccStage( TQTextStream &strm, TQString str ); + + // Variables + TQString Name; + TQString Filter; + triState ParseFiles; + TQStringList Files; + VcprojGenerator* Project; + TQValueList<VCConfiguration> *Config; + customBuildCheck CustomBuild; + bool useCustomBuildTool; + VCCustomBuildTool CustomBuildTool; + bool useCompilerTool; + VCCLCompilerTool CompilerTool; + bool flat_files; +}; + +class VCProject +{ +public: + // Functions + VCProject(); + ~VCProject(){} + + // Variables + TQString Name; + TQString Version; + TQString ProjectGUID; + TQString SccProjectName; + TQString SccLocalPath; + TQString PlatformName; + + // XML sub-parts + TQValueList<VCConfiguration> Configuration; + VCFilter SourceFiles; + VCFilter HeaderFiles; + VCFilter MOCFiles; + VCFilter UICFiles; + VCFilter FormFiles; + VCFilter TranslationFiles; + VCFilter LexYaccFiles; + VCFilter ResourceFiles; +}; + +TQTextStream &operator<<( TQTextStream &, const VCCLCompilerTool & ); +TQTextStream &operator<<( TQTextStream &, const VCLinkerTool & ); +TQTextStream &operator<<( TQTextStream &, const VCMIDLTool & ); +TQTextStream &operator<<( TQTextStream &, const VCCustomBuildTool & ); +TQTextStream &operator<<( TQTextStream &, const VCLibrarianTool & ); +TQTextStream &operator<<( TQTextStream &, const VCResourceCompilerTool & ); +TQTextStream &operator<<( TQTextStream &, const VCEventTool & ); +TQTextStream &operator<<( TQTextStream &, const VCConfiguration & ); +TQTextStream &operator<<( TQTextStream &, VCFilter & ); +TQTextStream &operator<<( TQTextStream &, const VCProject & ); + +#endif //__MSVC_OBJECTMODEL_H__ diff --git a/qmake/generators/win32/msvc_vcproj.cpp b/qmake/generators/win32/msvc_vcproj.cpp new file mode 100644 index 000000000..f22901b14 --- /dev/null +++ b/qmake/generators/win32/msvc_vcproj.cpp @@ -0,0 +1,1541 @@ +/**************************************************************************** +** +** Implementation of VcprojGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "msvc_vcproj.h" +#include "option.h" +#include "qtmd5.h" // SG's MD5 addon +#include <qdir.h> +#include <qregexp.h> +#include <qdict.h> +#include <quuid.h> +#include <stdlib.h> +#include <qsettings.h> + +//#define DEBUG_SOLUTION_GEN +//#define DEBUG_PROJECT_GEN + +// .NET version detection ------------------------- +struct DotNetStrings { + DotNET version; + const char *versionStr; + const char *regKey; +} dotNetCombo[] = { +#ifdef Q_OS_WIN64 + {NET2005, "MSVC.NET 2005 (8.0)", "Wow6432Node\\Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"}, + {NET2005, "MSVC 2005 Express Edition(8.0)", "Wow6432Node\\Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"}, + {NET2003, "MSVC.NET 2003 (7.1)", "Wow6432Node\\Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"}, + {NET2002, "MSVC.NET 2002 (7.0)", "Wow6432Node\\Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"}, +#else + {NET2005, "MSVC.NET 2005 (8.0)", "Microsoft\\VisualStudio\\8.0\\Setup\\VC\\ProductDir"}, + {NET2005, "MSVC 2005 Express Edition(8.0)", "Microsoft\\VCExpress\\8.0\\Setup\\VC\\ProductDir"}, + {NET2003, "MSVC.NET 2003 (7.1)", "Microsoft\\VisualStudio\\7.1\\Setup\\VC\\ProductDir"}, + {NET2002, "MSVC.NET 2002 (7.0)", "Microsoft\\VisualStudio\\7.0\\Setup\\VC\\ProductDir"}, +#endif + {NETUnknown, "", ""} +}; + +DotNET which_dotnet_version() +{ +#ifndef Q_OS_WIN32 + return NET2002; // Always generate 7.0 versions on other platforms +#else + // Only search for the version once + static DotNET current_version = NETUnknown; + if(current_version != NETUnknown) + return current_version; + + // Fallback to .NET 2002 + current_version = NET2002; + + TQSettings setting; + TQStringList warnPath; + int installed = 0; + int i = 0; + for(; dotNetCombo[i].version; ++i) { + TQString path = setting.readEntry(dotNetCombo[i].regKey); + if(!path.isNull()) { + ++installed; + current_version = dotNetCombo[i].version; + warnPath += TQString("%1").arg(dotNetCombo[i].versionStr); + } + } + + if (installed < 2) + return current_version; + + // More than one version installed, search directory path + TQString paths = getenv("PATH"); + TQStringList pathlist = TQStringList::split(";", paths.lower()); + + i = installed = 0; + for(; dotNetCombo[i].version; ++i) { + TQString productPath = setting.readEntry(dotNetCombo[i].regKey).lower(); + if (productPath.isNull()) + continue; + TQStringList::iterator it; + for(it = pathlist.begin(); it != pathlist.end(); ++it) { + if((*it).contains(productPath)) { + ++installed; + current_version = dotNetCombo[i].version; + warnPath += TQString("%1 in path").arg(dotNetCombo[i].versionStr); + break; + } + } + } + + switch(installed) { + case 1: + break; + case 0: + warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio, but" + " none in your path! Fallback to lowest version (%s)", warnPath.join(", ").latin1()); + break; + default: + warn_msg(WarnLogic, "Generator: MSVC.NET: Found more than one version of Visual Studio in" + " your path! Fallback to lowest version (%s)", warnPath.join(", ").latin1()); + break; + } + + return current_version; +#endif +}; + +// Flatfile Tags ---------------------------------------------------- +const char* _slnHeader70 = "Microsoft Visual Studio Solution File, Format Version 7.00"; +const char* _slnHeader71 = "Microsoft Visual Studio Solution File, Format Version 8.00"; +const char* _slnHeader80 = "Microsoft Visual Studio Solution File, Format Version 9.00"; + // The following UUID _may_ change for later servicepacks... + // If so we need to search through the registry at + // HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\7.0\Projects + // to find the subkey that contains a "PossibleProjectExtension" + // containing "vcproj"... + // Use the hardcoded value for now so projects generated on other + // platforms are actually usable. +const char* _slnMSVCvcprojGUID = "{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}"; +const char* _slnProjectBeg = "\nProject(\""; +const char* _slnProjectMid = "\") = "; +const char* _slnProjectEnd = "\nEndProject"; +const char* _slnGlobalBeg = "\nGlobal"; +const char* _slnGlobalEnd = "\nEndGlobal"; +const char* _slnSolutionConf = "\n\tGlobalSection(SolutionConfiguration) = preSolution" + "\n\t\tConfigName.0 = Debug" + "\n\t\tConfigName.1 = Release" + "\n\tEndGlobalSection"; +const char* _slnProjDepBeg = "\n\tGlobalSection(ProjectDependencies) = postSolution"; +const char* _slnProjDepEnd = "\n\tEndGlobalSection"; +const char* _slnProjConfBeg = "\n\tGlobalSection(ProjectConfiguration) = postSolution"; +const char* _slnProjRelConfTag1 = ".Release.ActiveCfg = Release|Win32"; +const char* _slnProjRelConfTag2 = ".Release.Build.0 = Release|Win32"; +const char* _slnProjDbgConfTag1 = ".Debug.ActiveCfg = Debug|Win32"; +const char* _slnProjDbgConfTag2 = ".Debug.Build.0 = Debug|Win32"; +const char* _slnProjConfEnd = "\n\tEndGlobalSection"; +const char* _slnExtSections = "\n\tGlobalSection(ExtensibilityGlobals) = postSolution" + "\n\tEndGlobalSection" + "\n\tGlobalSection(ExtensibilityAddIns) = postSolution" + "\n\tEndGlobalSection"; +// ------------------------------------------------------------------ + +VcprojGenerator::VcprojGenerator(TQMakeProject *p) : Win32MakefileGenerator(p), init_flag(FALSE) +{ +} + +/* \internal + Generates a project file for the given profile. + Options are either a Visual Studio projectfiles, or + solutionfiles by parsing recursive projectdirectories. +*/ +bool VcprojGenerator::writeMakefile(TQTextStream &t) +{ + // Check if all retquirements are fullfilled + if(!project->variables()["QMAKE_FAILED_RETQUIREMENTS"].isEmpty()) { + fprintf(stderr, "Project file not generated because all retquirements not met:\n\t%s\n", + var("QMAKE_FAILED_RETQUIREMENTS").latin1()); + return TRUE; + } + + // Generate project file + if(project->first("TEMPLATE") == "vcapp" || + project->first("TEMPLATE") == "vclib") { + debug_msg(1, "Generator: MSVC.NET: Writing project file" ); + t << vcProject; + return TRUE; + } + // Generate solution file + else if(project->first("TEMPLATE") == "vcsubdirs") { + debug_msg(1, "Generator: MSVC.NET: Writing solution file" ); + writeSubDirs(t); + return TRUE; + } + return FALSE; + +} + +struct VcsolutionDepend { + TQString uuid; + TQString vcprojFile, orig_target, target; + ::target targetType; + bool debugBuild; + TQStringList dependencies; +}; + +TQUuid VcprojGenerator::getProjectUUID(const TQString &filename) +{ + bool validUUID = TRUE; + + // Read GUID from variable-space + TQUuid uuid = project->first("GUID"); + + // If none, create one based on the MD5 of absolute project path + if (uuid.isNull() || !filename.isNull()) { + TQString abspath = filename.isNull()?project->first("QMAKE_MAKEFILE"):filename; + qtMD5(abspath.utf8(), (unsigned char*)(&uuid)); + validUUID = !uuid.isNull(); + uuid.data4[0] = (uuid.data4[0] & 0x3F) | 0x80; // UV_DCE variant + uuid.data3 = (uuid.data3 & 0x0FFF) | (TQUuid::Name<<12); + } + + // If still not valid, generate new one, and suggest adding to .pro + if (uuid.isNull() || !validUUID) { + uuid = TQUuid::createUuid(); + fprintf(stderr, + "qmake couldn't create a GUID based on filepath, and we couldn't\nfind a valid GUID in the .pro file (Consider adding\n'GUID = %s' to the .pro file)\n", + uuid.toString().upper().latin1()); + } + + // Store GUID in variable-space + project->values("GUID") = uuid.toString().upper(); + return uuid; +} + +TQUuid VcprojGenerator::increaseUUID( const TQUuid &id ) +{ + TQUuid result( id ); + Q_LONG dataFirst = (result.data4[0] << 24) + + (result.data4[1] << 16) + + (result.data4[2] << 8) + + result.data4[3]; + Q_LONG dataLast = (result.data4[4] << 24) + + (result.data4[5] << 16) + + (result.data4[6] << 8) + + result.data4[7]; + + if ( !(dataLast++) ) + dataFirst++; + + result.data4[0] = uchar((dataFirst >> 24) & 0xff); + result.data4[1] = uchar((dataFirst >> 16) & 0xff); + result.data4[2] = uchar((dataFirst >> 8) & 0xff); + result.data4[3] = uchar( dataFirst & 0xff); + result.data4[4] = uchar((dataLast >> 24) & 0xff); + result.data4[5] = uchar((dataLast >> 16) & 0xff); + result.data4[6] = uchar((dataLast >> 8) & 0xff); + result.data4[7] = uchar( dataLast & 0xff); + return result; +} + +void VcprojGenerator::writeSubDirs(TQTextStream &t) +{ + if(project->first("TEMPLATE") == "subdirs") { + writeHeader(t); + Win32MakefileGenerator::writeSubDirs(t); + return; + } + + switch(which_dotnet_version()) { + case NET2005: + t << _slnHeader80; + break; + case NET2003: + t << _slnHeader71; + break; + case NET2002: + t << _slnHeader70; + break; + default: + t << _slnHeader70; + warn_msg(WarnLogic, "Generator: MSVC.NET: Unknown version (%d) of MSVC detected for .sln", which_dotnet_version()); + break; + } + + TQDict<VcsolutionDepend> solution_depends; + + TQPtrList<VcsolutionDepend> solution_cleanup; + solution_cleanup.setAutoDelete(TRUE); + + + TQStringList subdirs = project->variables()["SUBDIRS"]; + TQString oldpwd = TQDir::currentDirPath(); + + for(TQStringList::Iterator it = subdirs.begin(); it != subdirs.end(); ++it) { + TQFileInfo fi(Option::fixPathToLocalOS((*it), TRUE)); + if(fi.exists()) { + if(fi.isDir()) { + TQString profile = (*it); + if(!profile.endsWith(Option::dir_sep)) + profile += Option::dir_sep; + profile += fi.baseName() + ".pro"; + subdirs.append(profile); + } else { + TQMakeProject tmp_proj; + TQString dir = fi.dirPath(), fn = fi.fileName(); + if(!dir.isEmpty()) { + if(!TQDir::setCurrent(dir)) + fprintf(stderr, "Cannot find directory: %s\n", dir.latin1()); + } + if(tmp_proj.read(fn, oldpwd)) { + if(tmp_proj.first("TEMPLATE") == "vcsubdirs") { + subdirs += fileFixify(tmp_proj.variables()["SUBDIRS"]); + } else if(tmp_proj.first("TEMPLATE") == "vcapp" || tmp_proj.first("TEMPLATE") == "vclib") { + // Initialize a 'fake' project to get the correct variables + // and to be able to extract all the dependencies + VcprojGenerator tmp_vcproj(&tmp_proj); + tmp_vcproj.setNoIO(TRUE); + tmp_vcproj.init(); + if(Option::debug_level) { + TQMap<TQString, TQStringList> &vars = tmp_proj.variables(); + for(TQMap<TQString, TQStringList>::Iterator it = vars.begin(); + it != vars.end(); ++it) { + if(it.key().left(1) != "." && !it.data().isEmpty()) + debug_msg(1, "%s: %s === %s", fn.latin1(), it.key().latin1(), + it.data().join(" :: ").latin1()); + } + } + + // We assume project filename is [QMAKE_ORIG_TARGET].vcproj + TQString vcproj = fixFilename(tmp_vcproj.project->first("QMAKE_ORIG_TARGET")) + project->first("VCPROJ_EXTENSION"); + + // If file doesn't exsist, then maybe the users configuration + // doesn't allow it to be created. Skip to next... + if(!TQFile::exists(TQDir::currentDirPath() + Option::dir_sep + vcproj)) { + warn_msg(WarnLogic, "Ignored (not found) '%s'", TQString(TQDir::currentDirPath() + Option::dir_sep + vcproj).latin1() ); + goto nextfile; // # Dirty! + } + + VcsolutionDepend *newDep = new VcsolutionDepend; + newDep->vcprojFile = fileFixify(vcproj); + newDep->orig_target = tmp_proj.first("QMAKE_ORIG_TARGET"); + newDep->target = tmp_proj.first("MSVCPROJ_TARGET").section(Option::dir_sep, -1); + newDep->targetType = tmp_vcproj.projectTarget; + newDep->debugBuild = tmp_proj.isActiveConfig("debug"); + newDep->uuid = getProjectUUID(Option::fixPathToLocalOS(TQDir::currentDirPath() + TQDir::separator() + vcproj)).toString().upper(); + + // We want to store it as the .lib name. + if(newDep->target.endsWith(".dll")) + newDep->target = newDep->target.left(newDep->target.length()-3) + "lib"; + + // All projects using Forms are dependent on uic.exe + if(!tmp_proj.isEmpty("FORMS")) + newDep->dependencies << "uic.exe"; + + // Add all unknown libs to the deps + TQStringList where("QMAKE_LIBS"); + if(!tmp_proj.isEmpty("QMAKE_INTERNAL_PRL_LIBS")) + where = tmp_proj.variables()["QMAKE_INTERNAL_PRL_LIBS"]; + for(TQStringList::iterator wit = where.begin(); + wit != where.end(); ++wit) { + TQStringList &l = tmp_proj.variables()[(*wit)]; + for(TQStringList::Iterator it = l.begin(); it != l.end(); ++it) { + TQString opt = (*it); + if(!opt.startsWith("/") && // Not a switch + opt != newDep->target && // Not self + opt != "opengl32.lib" && // We don't care about these libs + opt != "glu32.lib" && // to make depgen alittle faster + opt != "kernel32.lib" && + opt != "user32.lib" && + opt != "gdi32.lib" && + opt != "comdlg32.lib" && + opt != "advapi32.lib" && + opt != "shell32.lib" && + opt != "ole32.lib" && + opt != "oleaut32.lib" && + opt != "uuid.lib" && + opt != "imm32.lib" && + opt != "winmm.lib" && + opt != "wsock32.lib" && + opt != "winspool.lib" && + opt != "delayimp.lib" ) + { + newDep->dependencies << opt.section(Option::dir_sep, -1); + } + } + } +#ifdef DEBUG_SOLUTION_GEN + qDebug( "Deps for %20s: [%s]", newDep->target.latin1(), newDep->dependencies.join(" :: " ).latin1() ); +#endif + solution_cleanup.append(newDep); + solution_depends.insert(newDep->target, newDep); + t << _slnProjectBeg << _slnMSVCvcprojGUID << _slnProjectMid + << "\"" << newDep->orig_target << "\", \"" << newDep->vcprojFile + << "\", \"" << newDep->uuid << "\""; + t << _slnProjectEnd; + } + } +nextfile: + TQDir::setCurrent(oldpwd); + } + } + } + t << _slnGlobalBeg; + t << _slnSolutionConf; + t << _slnProjDepBeg; + + // Figure out dependencies + for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { + int cnt = 0; + for(TQStringList::iterator dit = solution_cleanup.current()->dependencies.begin(); + dit != solution_cleanup.current()->dependencies.end(); + ++dit) + { + VcsolutionDepend *vc = solution_depends[*dit]; + if(vc) + t << "\n\t\t" << solution_cleanup.current()->uuid << "." << cnt++ << " = " << vc->uuid; + } + } + t << _slnProjDepEnd; + t << _slnProjConfBeg; + for(solution_cleanup.first(); solution_cleanup.current(); solution_cleanup.next()) { + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag1; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjDbgConfTag2; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag1; + t << "\n\t\t" << solution_cleanup.current()->uuid << _slnProjRelConfTag2; + } + t << _slnProjConfEnd; + t << _slnExtSections; + t << _slnGlobalEnd; +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ + +void VcprojGenerator::init() +{ + if( init_flag ) + return; + if(project->first("TEMPLATE") == "vcsubdirs") { //too much work for subdirs + init_flag = TRUE; + return; + } + + debug_msg(1, "Generator: MSVC.NET: Initializing variables" ); + +/* + // Once to be nice and clean code... + // Wouldn't life be great? + + // Are we building TQt? + bool is_qt = + ( project->first("TARGET") == "qt"TQTDLL_POSTFIX || + project->first("TARGET") == "tqt-mt"TQTDLL_POSTFIX ); + + // Are we using TQt? + bool isTQtActive = project->isActiveConfig("qt"); + + if ( isTQtActive ) { + project->variables()["CONFIG"] += "moc"; + project->variables()["CONFIG"] += "windows"; + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + + if( projectTarget == SharedLib ) + project->variables()["DEFINES"] += "QT_DLL"; + + if( project->isActiveConfig("accessibility" ) ) + project->variables()["DEFINES"] += "QT_ACCESSIBILITY_SUPPORT"; + + if ( project->isActiveConfig("plugin")) { + project->variables()["DEFINES"] += "QT_PLUGIN"; + project->variables()["CONFIG"] += "dll"; + } + + if( project->isActiveConfig("thread") ) { + project->variables()["DEFINES"] += "QT_THREAD_SUPPORT"; + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + } else { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + } + } + + if ( project->isActiveConfig("opengl") ) { + project->variables()["CONFIG"] += "windows"; // <-- Also in 'qt' above + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + + } +*/ + initOld(); // Currently calling old DSP code to set variables. CLEAN UP! + + // Figure out what we're trying to build + if ( project->first("TEMPLATE") == "vcapp" ) { + projectTarget = Application; + } else if ( project->first("TEMPLATE") == "vclib") { + if ( project->isActiveConfig( "staticlib" ) ) + projectTarget = StaticLib; + else + projectTarget = SharedLib; + } + + // Setup PCH variables + precompH = project->first("PRECOMPILED_HEADER"); + usePCH = !precompH.isEmpty() && project->isActiveConfig("precompile_header"); + if (usePCH) { + precompHFilename = TQFileInfo(precompH).fileName(); + // Created files + TQString origTarget = project->first("QMAKE_ORIG_TARGET"); + precompObj = origTarget + Option::obj_ext; + precompPch = origTarget + ".pch"; + // Add PRECOMPILED_HEADER to HEADERS + if (!project->variables()["HEADERS"].contains(precompH)) + project->variables()["HEADERS"] += precompH; + // Return to variable pool + project->variables()["PRECOMPILED_OBJECT"] = precompObj; + project->variables()["PRECOMPILED_PCH"] = precompPch; + } + + initProject(); // Fills the whole project with proper data +} + +void VcprojGenerator::initProject() +{ + // Initialize XML sub elements + // - Do this first since project elements may need + // - to know of certain configuration options + initConfiguration(); + initSourceFiles(); + initHeaderFiles(); + initMOCFiles(); + initUICFiles(); + initFormsFiles(); + initTranslationFiles(); + initLexYaccFiles(); + initResourceFiles(); + + // Own elements ----------------------------- + vcProject.Name = project->first("QMAKE_ORIG_TARGET"); + + switch(which_dotnet_version()) { + case NET2005: + vcProject.Version = "8.00"; + break; + case NET2003: + vcProject.Version = "7.10"; + break; + case NET2002: + vcProject.Version = "7.00"; + break; + default: + vcProject.Version = "7.00"; + break; + } + + vcProject.ProjectGUID = getProjectUUID().toString().upper(); + vcProject.PlatformName = ( vcProject.Configuration[0].idl.TargetEnvironment == midlTargetWin64 ? "Win64" : "Win32" ); + // These are not used by TQt, but may be used by customers + vcProject.SccProjectName = project->first("SCCPROJECTNAME"); + vcProject.SccLocalPath = project->first("SCCLOCALPATH"); +} + +void VcprojGenerator::initConfiguration() +{ + // Initialize XML sub elements + // - Do this first since main configuration elements may need + // - to know of certain compiler/linker options + initCompilerTool(); + if ( projectTarget == StaticLib ) + initLibrarianTool(); + else + initLinkerTool(); + initIDLTool(); + + // Own elements ----------------------------- + TQString temp = project->first("BuildBrowserInformation"); + switch ( projectTarget ) { + case SharedLib: + vcProject.Configuration[0].ConfigurationType = typeDynamicLibrary; + break; + case StaticLib: + vcProject.Configuration[0].ConfigurationType = typeStaticLibrary; + break; + case Application: + default: + vcProject.Configuration[0].ConfigurationType = typeApplication; + break; + } + + // Release version of the Configuration --------------- + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.Name = "Release"; + RConf.Name += ( RConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" ); + RConf.ATLMinimizesCRunTimeLibraryUsage = ( project->first("ATLMinimizesCRunTimeLibraryUsage").isEmpty() ? _False : _True ); + RConf.BuildBrowserInformation = triState( temp.isEmpty() ? (short)unset : temp.toShort() ); + temp = project->first("CharacterSet"); + RConf.CharacterSet = charSet( temp.isEmpty() ? (short)charSetNotSet : temp.toShort() ); + RConf.DeleteExtensionsOnClean = project->first("DeleteExtensionsOnClean"); + RConf.ImportLibrary = RConf.linker.ImportLibrary; + RConf.IntermediateDirectory = project->first("OBJECTS_DIR"); + RConf.OutputDirectory = "."; + RConf.PrimaryOutput = project->first("PrimaryOutput"); + RConf.WholeProgramOptimization = RConf.compiler.WholeProgramOptimization; + temp = project->first("UseOfATL"); + if ( !temp.isEmpty() ) + RConf.UseOfATL = useOfATL( temp.toShort() ); + temp = project->first("UseOfMfc"); + if ( !temp.isEmpty() ) + RConf.UseOfMfc = useOfMfc( temp.toShort() ); + + // Configuration does not need parameters from + // these sub XML items; + initCustomBuildTool(); + initPreBuildEventTools(); + initPostBuildEventTools(); + initPreLinkEventTools(); + + // Debug version of the Configuration ----------------- + VCConfiguration DConf = vcProject.Configuration[0]; // Create copy configuration for debug + DConf.Name = "Debug"; + DConf.Name += ( DConf.idl.TargetEnvironment == midlTargetWin64 ? "|Win64" : "|Win32" ); + + // Set definite values in both configurations + DConf.compiler.PreprocessorDefinitions.remove("NDEBUG"); + RConf.compiler.PreprocessorDefinitions += "NDEBUG"; + RConf.linker.GenerateDebugInformation = _False; + DConf.linker.GenerateDebugInformation = _True; + + // Modify configurations, based on TQt build + if ( !project->isActiveConfig("debug") ) { + RConf.IntermediateDirectory = + RConf.compiler.AssemblerListingLocation = + RConf.compiler.ObjectFile = "Release\\"; + RConf.librarian.OutputFile = + RConf.linker.OutputFile = RConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET"); + RConf.linker.parseOptions(project->variables()["QMAKE_LFLAGS_RELEASE"]); + RConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_RELEASE"]); + RConf.compiler.parseOptions(project->variables()["QMAKE_CXXFLAGS_RELEASE"]); + if (!project->variables()["QMAKE_CXXFLAGS_RELEASE"].contains("Gm") + && project->variables()["QMAKE_CXXFLAGS_DEBUG"].contains("Gm")) + RConf.compiler.parseOption("-Gm-"); + if (RConf.compiler.PreprocessorDefinitions.findIndex("QT_NO_DEBUG") == -1) + RConf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + } else { + DConf.IntermediateDirectory = + DConf.compiler.AssemblerListingLocation = + DConf.compiler.ObjectFile = "Debug\\"; + DConf.librarian.OutputFile = + DConf.linker.OutputFile = DConf.IntermediateDirectory + "\\" + project->first("MSVCPROJ_TARGET"); + DConf.linker.DelayLoadDLLs.clear(); + DConf.compiler.parseOptions(project->variables()["QMAKE_CFLAGS_DEBUG"]); + DConf.compiler.parseOptions(project->variables()["QMAKE_CXXFLAGS_DEBUG"]); + DConf.compiler.PreprocessorDefinitions.remove("QT_NO_DEBUG"); + } + + // Add Debug configuration to project + vcProject.Configuration += DConf; +} + +void VcprojGenerator::initCompilerTool() +{ + TQString placement = project->first("OBJECTS_DIR"); + if ( placement.isEmpty() ) + placement = ".\\"; + + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.compiler.AssemblerListingLocation = placement ; + RConf.compiler.ProgramDataBaseFileName = ".\\" ; + RConf.compiler.ObjectFile = placement ; + // PCH + if ( usePCH ) { + RConf.compiler.UsePrecompiledHeader = pchUseUsingSpecific; + RConf.compiler.PrecompiledHeaderFile = "$(IntDir)\\" + precompPch; + RConf.compiler.PrecompiledHeaderThrough = precompHFilename; + RConf.compiler.ForcedIncludeFiles = precompHFilename; + // Minimal build option triggers an Internal Compiler Error + // when used in conjunction with /FI and /Yu, so remove it + project->variables()["QMAKE_CFLAGS_DEBUG"].remove("-Gm"); + project->variables()["QMAKE_CFLAGS_DEBUG"].remove("/Gm"); + project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("-Gm"); + project->variables()["QMAKE_CXXFLAGS_DEBUG"].remove("/Gm"); + } + + if ( project->isActiveConfig("debug") ){ + // Debug version + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_DEBUG"] ); + if ( project->isActiveConfig("thread") ) { + if ( (projectTarget == Application) || (projectTarget == StaticLib) ) + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DBG"] ); + else + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLLDBG"] ); + } + } else { + // Release version + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS"] ); + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_RELEASE"] ); + RConf.compiler.PreprocessorDefinitions += "QT_NO_DEBUG"; + RConf.compiler.PreprocessorDefinitions += "NDEBUG"; + if ( project->isActiveConfig("thread") ) { + if ( (projectTarget == Application) || (projectTarget == StaticLib) ) + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT"] ); + else + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_MT_DLL"] ); + } + } + + // Common for both release and debug + if ( project->isActiveConfig("warn_off") ) + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_OFF"] ); + else if ( project->isActiveConfig("warn_on") ) + RConf.compiler.parseOptions( project->variables()["QMAKE_CXXFLAGS_WARN_ON"] ); + if ( project->isActiveConfig("windows") ) + RConf.compiler.PreprocessorDefinitions += project->variables()["MSVCPROJ_WINCONDEF"]; + + // Can this be set for ALL configs? + // If so, use qmake.conf! + if ( projectTarget == SharedLib ) + RConf.compiler.PreprocessorDefinitions += "_WINDOWS"; + + RConf.compiler.PreprocessorDefinitions += project->variables()["DEFINES"]; + RConf.compiler.PreprocessorDefinitions += project->variables()["PRL_EXPORT_DEFINES"]; + TQStringList::iterator it; + for(it=RConf.compiler.PreprocessorDefinitions.begin(); + it!=RConf.compiler.PreprocessorDefinitions.end(); + ++it) + (*it).replace('\"', """); + + RConf.compiler.parseOptions( project->variables()["MSVCPROJ_INCPATH"] ); +} + +void VcprojGenerator::initLibrarianTool() +{ + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.librarian.OutputFile = project->first( "DESTDIR" ).replace("&", "&"); + if( RConf.librarian.OutputFile.isEmpty() ) + RConf.librarian.OutputFile = ".\\"; + + if( !RConf.librarian.OutputFile.endsWith("\\") ) + RConf.librarian.OutputFile += '\\'; + + RConf.librarian.OutputFile += project->first("MSVCPROJ_TARGET"); +} + +void VcprojGenerator::initLinkerTool() +{ + VCConfiguration &RConf = vcProject.Configuration[0]; + RConf.linker.parseOptions( project->variables()["MSVCPROJ_LFLAGS"] ); + RConf.linker.AdditionalDependencies += project->variables()["MSVCPROJ_LIBS"]; + + switch ( projectTarget ) { + case Application: + RConf.linker.OutputFile = project->first( "DESTDIR" ); + break; + case SharedLib: + RConf.linker.parseOptions( project->variables()["MSVCPROJ_LIBOPTIONS"] ); + RConf.linker.OutputFile = project->first( "DESTDIR" ); + break; + case StaticLib: //unhandled - added to remove warnings.. + break; + } + + if( RConf.linker.OutputFile.isEmpty() ) + RConf.linker.OutputFile = ".\\"; + + if( !RConf.linker.OutputFile.endsWith("\\") ) + RConf.linker.OutputFile += '\\'; + + RConf.linker.OutputFile += project->first("MSVCPROJ_TARGET"); + + if ( project->isActiveConfig("debug") ){ + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_DEBUG"] ); + } else { + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_RELEASE"] ); + } + + if ( project->isActiveConfig("dll") ){ + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_QT_DLL"] ); + } + + if ( project->isActiveConfig("console") ){ + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_CONSOLE"] ); + } else { + RConf.linker.parseOptions( project->variables()["QMAKE_LFLAGS_WINDOWS"] ); + } + +} + +void VcprojGenerator::initIDLTool() +{ +} + +void VcprojGenerator::initCustomBuildTool() +{ +} + +void VcprojGenerator::initPreBuildEventTools() +{ +} + +void VcprojGenerator::initPostBuildEventTools() +{ + VCConfiguration &RConf = vcProject.Configuration[0]; + if ( !project->variables()["QMAKE_POST_LINK"].isEmpty() ) { + RConf.postBuild.Description = var("QMAKE_POST_LINK"); + RConf.postBuild.CommandLine = var("QMAKE_POST_LINK"); + RConf.postBuild.Description.replace(" && ", " && "); + RConf.postBuild.CommandLine.replace(" && ", " && "); + } + if ( !project->variables()["MSVCPROJ_COPY_DLL"].isEmpty() ) { + if ( !RConf.postBuild.CommandLine.isEmpty() ) + RConf.postBuild.CommandLine += " && "; + RConf.postBuild.Description += var("MSVCPROJ_COPY_DLL_DESC"); + RConf.postBuild.CommandLine += var("MSVCPROJ_COPY_DLL"); + } + if( project->isActiveConfig( "activeqt" ) ) { + TQString name = project->first( "QMAKE_ORIG_TARGET" ); + TQString nameext = project->first( "TARGET" ); + TQString objdir = project->first( "OBJECTS_DIR" ); + TQString idc = project->first( "QMAKE_IDC" ); + + RConf.postBuild.Description = "Finalizing ActiveTQt server..."; + if ( !RConf.postBuild.CommandLine.isEmpty() ) + RConf.postBuild.CommandLine += " && "; + + if( project->isActiveConfig( "dll" ) ) { // In process + RConf.postBuild.CommandLine += + // call idc to generate .idl file from .dll + idc + " "$(TargetPath)" -idl " + objdir + name + ".idl -version 1.0 && " + + // call midl to create implementations of the .idl file + project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + + // call idc to replace tlb... + idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + + // register server + idc + " "$(TargetPath)" /regserver"; + } else { // out of process + RConf.postBuild.CommandLine = + // call application to dump idl + ""$(TargetPath)" -dumpidl " + objdir + name + ".idl -version 1.0 && " + + // call midl to create implementations of the .idl file + project->first( "QMAKE_IDL" ) + " /nologo " + objdir + name + ".idl /tlb " + objdir + name + ".tlb && " + + // call idc to replace tlb... + idc + " "$(TargetPath)" /tlb " + objdir + name + ".tlb && " + + // call app to register + ""$(TargetPath)" -regserver"; + } + } +} + +void VcprojGenerator::initPreLinkEventTools() +{ +} + + +// ------------------------------------------------------------------ +// Helper functions to do proper sorting of the +// qstringlists, for both flat and non-flat modes. +inline bool XLessThanY( TQString &x, TQString &y, bool flat_mode ) +{ + if ( flat_mode ) { + TQString subX = x.mid( x.findRev('\\')+1 ); + TQString subY = y.mid( y.findRev('\\')+1 ); + return TQString::compare(subX, subY) < 0; + } + + int xPos = 0; + int yPos = 0; + int xSlashPos; + int ySlashPos; + for (;;) { + xSlashPos = x.find('\\', xPos); + ySlashPos = y.find('\\', yPos); + + if (xSlashPos == -1 && ySlashPos != -1) { + return FALSE; + } else if (xSlashPos != -1 && ySlashPos == -1) { + return TRUE; + } else if (xSlashPos == -1 /* && yySlashPos == -1 */) { + TQString subX = x.mid(xPos); + TQString subY = y.mid(yPos); + return TQString::compare(subX, subY) < 0; + } else { + TQString subX = x.mid(xPos, xSlashPos - xPos); + TQString subY = y.mid(yPos, ySlashPos - yPos); + int cmp = TQString::compare(subX, subY); + if (cmp != 0) + return cmp < 0; + } + xPos = xSlashPos + 1; + yPos = ySlashPos + 1; + } + return FALSE; +} +void nonflatDir_BubbleSort( TQStringList& list, bool flat_mode ) +{ + TQStringList::Iterator b = list.begin(); + TQStringList::Iterator e = list.end(); + TQStringList::Iterator last = e; + --last; // goto last + if ( last == b ) // shortcut + return; + while( b != last ) {// sort them + bool swapped = FALSE; + TQStringList::Iterator swap_pos = b; + TQStringList::Iterator x = e; + TQStringList::Iterator y = x; + --y; + TQString swap_str; + do { + --x; + --y; + if ( XLessThanY(*x,*y, flat_mode) ) { + swapped = TRUE; + swap_str = (*x); // Swap ------- + (*x) = (*y); + (*y) = swap_str; // ------------ + swap_pos = y; + } + } while( y != b ); + if ( !swapped ) + return; + b = swap_pos; + ++b; + } +} +// ------------------------------------------------------------------ + +void VcprojGenerator::initSourceFiles() +{ + vcProject.SourceFiles.flat_files = project->isActiveConfig("flat"); + vcProject.SourceFiles.Name = "Source Files"; + vcProject.SourceFiles.Filter = "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"; + vcProject.SourceFiles.Files += project->variables()["SOURCES"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.SourceFiles.Files, + vcProject.SourceFiles.flat_files ); + vcProject.SourceFiles.Project = this; + vcProject.SourceFiles.Config = &(vcProject.Configuration); + vcProject.SourceFiles.CustomBuild = none; +} + +void VcprojGenerator::initHeaderFiles() +{ + vcProject.HeaderFiles.flat_files = project->isActiveConfig("flat"); + vcProject.HeaderFiles.Name = "Header Files"; + vcProject.HeaderFiles.Filter = "h;hpp;hxx;hm;inl"; + vcProject.HeaderFiles.Files += project->variables()["HEADERS"]; + if (usePCH) { // Generated PCH cpp file + if (!vcProject.HeaderFiles.Files.contains(precompH)) + vcProject.HeaderFiles.Files += precompH; + } + nonflatDir_BubbleSort( vcProject.HeaderFiles.Files, + vcProject.HeaderFiles.flat_files ); + vcProject.HeaderFiles.Project = this; + vcProject.HeaderFiles.Config = &(vcProject.Configuration); + vcProject.HeaderFiles.CustomBuild = moc; +} + +void VcprojGenerator::initMOCFiles() +{ + vcProject.MOCFiles.flat_files = project->isActiveConfig("flat"); + vcProject.MOCFiles.Name = "Generated MOC Files"; + vcProject.MOCFiles.Filter = "cpp;c;cxx;moc"; + vcProject.MOCFiles.Files += project->variables()["SRCMOC"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.MOCFiles.Files, + vcProject.MOCFiles.flat_files ); + vcProject.MOCFiles.Project = this; + vcProject.MOCFiles.Config = &(vcProject.Configuration); + vcProject.MOCFiles.CustomBuild = moc; +} + +void VcprojGenerator::initUICFiles() +{ + vcProject.UICFiles.flat_files = project->isActiveConfig("flat"); + vcProject.UICFiles.Name = "Generated Form Files"; + vcProject.UICFiles.Filter = "cpp;c;cxx;h;hpp;hxx;"; + vcProject.UICFiles.Project = this; + vcProject.UICFiles.Files += project->variables()["UICDECLS"].gres("&", "&"); + vcProject.UICFiles.Files += project->variables()["UICIMPLS"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.UICFiles.Files, + vcProject.UICFiles.flat_files ); + vcProject.UICFiles.Config = &(vcProject.Configuration); + vcProject.UICFiles.CustomBuild = none; +} + +void VcprojGenerator::initFormsFiles() +{ + vcProject.FormFiles.flat_files = project->isActiveConfig("flat"); + vcProject.FormFiles.Name = "Forms"; + vcProject.FormFiles.ParseFiles = _False; + vcProject.FormFiles.Filter = "ui"; + vcProject.FormFiles.Files += project->variables()["FORMS"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.FormFiles.Files, + vcProject.FormFiles.flat_files ); + vcProject.FormFiles.Project = this; + vcProject.FormFiles.Config = &(vcProject.Configuration); + vcProject.FormFiles.CustomBuild = uic; +} + +void VcprojGenerator::initTranslationFiles() +{ + vcProject.TranslationFiles.flat_files = project->isActiveConfig("flat"); + vcProject.TranslationFiles.Name = "Translations Files"; + vcProject.TranslationFiles.ParseFiles = _False; + vcProject.TranslationFiles.Filter = "ts"; + vcProject.TranslationFiles.Files += project->variables()["TRANSLATIONS"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.TranslationFiles.Files, + vcProject.TranslationFiles.flat_files ); + vcProject.TranslationFiles.Project = this; + vcProject.TranslationFiles.Config = &(vcProject.Configuration); + vcProject.TranslationFiles.CustomBuild = none; +} + +void VcprojGenerator::initLexYaccFiles() +{ + vcProject.LexYaccFiles.flat_files = project->isActiveConfig("flat"); + vcProject.LexYaccFiles.Name = "Lex / Yacc Files"; + vcProject.LexYaccFiles.ParseFiles = _False; + vcProject.LexYaccFiles.Filter = "l;y"; + vcProject.LexYaccFiles.Files += project->variables()["LEXSOURCES"].gres("&", "&"); + vcProject.LexYaccFiles.Files += project->variables()["YACCSOURCES"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.LexYaccFiles.Files, + vcProject.LexYaccFiles.flat_files ); + vcProject.LexYaccFiles.Project = this; + vcProject.LexYaccFiles.Config = &(vcProject.Configuration); + vcProject.LexYaccFiles.CustomBuild = lexyacc; +} + +void VcprojGenerator::initResourceFiles() +{ + vcProject.ResourceFiles.flat_files = project->isActiveConfig("flat"); + vcProject.ResourceFiles.Name = "Resources"; + vcProject.ResourceFiles.ParseFiles = _False; + vcProject.ResourceFiles.Filter = "cpp;ico;png;jpg;jpeg;gif;xpm;bmp;rc;ts"; + if (!project->variables()["RC_FILE"].isEmpty()) + vcProject.ResourceFiles.Files += project->variables()["RC_FILE"].gres("&", "&"); + if (!project->variables()["RES_FILE"].isEmpty()) + vcProject.ResourceFiles.Files += project->variables()["RES_FILE"].gres("&", "&"); + vcProject.ResourceFiles.Files += project->variables()["QMAKE_IMAGE_COLLECTION"].gres("&", "&"); + vcProject.ResourceFiles.Files += project->variables()["IMAGES"].gres("&", "&"); + vcProject.ResourceFiles.Files += project->variables()["IDLSOURCES"].gres("&", "&"); + nonflatDir_BubbleSort( vcProject.ResourceFiles.Files, + vcProject.ResourceFiles.flat_files ); + vcProject.ResourceFiles.Project = this; + vcProject.ResourceFiles.Config = &(vcProject.Configuration); + vcProject.ResourceFiles.CustomBuild = resource; +} + +/* \internal + Sets up all needed variables from the environment and all the different caches and .conf files +*/ + +void VcprojGenerator::initOld() +{ + if( init_flag ) + return; + + init_flag = TRUE; + TQStringList::Iterator it; + + if ( project->isActiveConfig("stl") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_STL_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_STL_OFF"]; + } + if ( project->isActiveConfig("exceptions") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_EXCEPTIONS_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_EXCEPTIONS_OFF"]; + } + if ( project->isActiveConfig("rtti") ) { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_ON"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_ON"]; + } else { + project->variables()["QMAKE_CFLAGS"] += project->variables()["QMAKE_CFLAGS_RTTI_OFF"]; + project->variables()["QMAKE_CXXFLAGS"] += project->variables()["QMAKE_CXXFLAGS_RTTI_OFF"]; + } + + // this should probably not be here, but I'm using it to wrap the .t files + if(project->first("TEMPLATE") == "vcapp" ) + project->variables()["QMAKE_APP_FLAG"].append("1"); + else if(project->first("TEMPLATE") == "vclib") + project->variables()["QMAKE_LIB_FLAG"].append("1"); + if ( project->variables()["QMAKESPEC"].isEmpty() ) + project->variables()["QMAKESPEC"].append( getenv("QMAKESPEC") ); + + bool is_qt = + ( project->first("TARGET") == "qt"TQTDLL_POSTFIX || + project->first("TARGET") == "tqt-mt"TQTDLL_POSTFIX ); + + TQStringList &configs = project->variables()["CONFIG"]; + + if ( project->isActiveConfig( "shared" ) ) + project->variables()["DEFINES"].append( "QT_DLL" ); + + if ( project->isActiveConfig( "qt_dll" ) && + configs.findIndex("qt") == -1 ) + configs.append("qt"); + + if ( project->isActiveConfig( "qt" ) ) { + if ( project->isActiveConfig( "plugin" ) ) { + project->variables()["CONFIG"].append( "dll" ); + project->variables()["DEFINES"].append( "QT_PLUGIN" ); + } + if ( ( project->variables()["DEFINES"].findIndex( "QT_NODLL" ) == -1 ) && + (( project->variables()["DEFINES"].findIndex( "QT_MAKEDLL" ) != -1 || + project->variables()["DEFINES"].findIndex( "QT_DLL" ) != -1 ) || + ( getenv( "QT_DLL" ) && !getenv( "QT_NODLL" ))) ) { + project->variables()["QMAKE_QT_DLL"].append( "1" ); + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) + project->variables()["CONFIG"].append( "dll" ); + } + } + + // If we are a dll, then we cannot be a staticlib at the same time... + if ( project->isActiveConfig( "dll" ) || !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["CONFIG"].remove( "staticlib" ); + project->variables()["QMAKE_APP_OR_DLL"].append( "1" ); + } else { + project->variables()["CONFIG"].append( "staticlib" ); + } + + // If we need 'qt' and/or 'opengl', then we need windows and not console + if ( project->isActiveConfig( "qt" ) || project->isActiveConfig( "opengl" ) ) { + project->variables()["CONFIG"].append( "windows" ); + } + + // Decode version, and add it to $$MSVCPROJ_VERSION -------------- + if ( !project->variables()["VERSION"].isEmpty() ) { + TQString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + TQString major = version.left( firstDot ); + TQString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( TQRegExp( "\\." ), "" ); + project->variables()["MSVCPROJ_VERSION"].append( "/VERSION:" + major + "." + minor ); + } + + // QT ------------------------------------------------------------ + if ( project->isActiveConfig("qt") ) { + project->variables()["CONFIG"].append("moc"); + project->variables()["INCLUDEPATH"] += project->variables()["QMAKE_INCDIR_QT"]; + project->variables()["QMAKE_LIBDIR"] += project->variables()["QMAKE_LIBDIR_QT"]; + + if ( is_qt && !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + project->variables()["DEFINES"].append("QT_MAKEDLL"); + project->variables()["QMAKE_LFLAGS"].append("/BASE:0x39D00000"); + } + } else { + if(project->isActiveConfig("thread")) + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_THREAD"]; + else + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT"]; + if ( !project->variables()["QMAKE_QT_DLL"].isEmpty() ) { + int hver = findHighestVersion(project->first("QMAKE_LIBDIR_QT"), "qt"); + if( hver==-1 ) { + hver = findHighestVersion( project->first("QMAKE_LIBDIR_QT"), "tqt-mt" ); + } + + if(hver != -1) { + TQString ver; + ver.sprintf("qt%s" TQTDLL_POSTFIX "%d.lib", (project->isActiveConfig("thread") ? "-mt" : ""), hver); + TQStringList &libs = project->variables()["QMAKE_LIBS"]; + for(TQStringList::Iterator libit = libs.begin(); libit != libs.end(); ++libit) + (*libit).replace(TQRegExp("qt(-mt)?\\.lib"), ver); + } + } + if ( project->isActiveConfig( "activeqt" ) ) { + project->variables().remove("QMAKE_LIBS_QT_ENTRY"); + project->variables()["QMAKE_LIBS_QT_ENTRY"] = "qaxserver.lib"; + if ( project->isActiveConfig( "dll" ) ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + if ( !project->isActiveConfig("dll") && !project->isActiveConfig("plugin") ) { + project->variables()["QMAKE_LIBS"] +=project->variables()["QMAKE_LIBS_QT_ENTRY"]; + } + } + } + + // Set target directories ---------------------------------------- + // if ( !project->first("OBJECTS_DIR").isEmpty() ) + //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->first("OBJECTS_DIR"); + // else + //project->variables()["MSVCPROJ_OBJECTSDIR"] = project->isActiveConfig( "release" )?"Release":"Debug"; + // if ( !project->first("DESTDIR").isEmpty() ) + //project->variables()["MSVCPROJ_TARGETDIR"] = project->first("DESTDIR"); + // else + //project->variables()["MSVCPROJ_TARGETDIR"] = project->isActiveConfig( "release" )?"Release":"Debug"; + + // OPENGL -------------------------------------------------------- + if ( project->isActiveConfig("opengl") ) { + project->variables()["QMAKE_LIBS"] += project->variables()["QMAKE_LIBS_OPENGL"]; + project->variables()["QMAKE_LFLAGS"] += project->variables()["QMAKE_LFLAGS_OPENGL"]; + } + + // THREAD -------------------------------------------------------- + if ( project->isActiveConfig("thread") ) { + if(project->isActiveConfig("qt")) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_THREAD_SUPPORT" ); + if ( !project->variables()["DEFINES"].contains("QT_DLL") && is_qt + && project->first("TARGET") != "qtmain" ) + project->variables()["QMAKE_LFLAGS"].append("/NODEFAULTLIB:libc"); + } + + // ACCESSIBILITY ------------------------------------------------- + if(project->isActiveConfig("qt")) { + if ( project->isActiveConfig("accessibility" ) ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_ACCESSIBILITY_SUPPORT"); + if ( project->isActiveConfig("tablet") ) + project->variables()[is_qt ? "PRL_EXPORT_DEFINES" : "DEFINES"].append("QT_TABLET_SUPPORT"); + } + + // DLL ----------------------------------------------------------- + if ( project->isActiveConfig("dll") ) { + if ( !project->variables()["QMAKE_LIB_FLAG"].isEmpty() ) { + TQString ver_xyz(project->first("VERSION")); + ver_xyz.replace(TQRegExp("\\."), ""); + project->variables()["TARGET_EXT"].append(ver_xyz + ".dll"); + } else { + project->variables()["TARGET_EXT"].append(".dll"); + } + } + // EXE / LIB ----------------------------------------------------- + else { + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) + project->variables()["TARGET_EXT"].append(".exe"); + else + project->variables()["TARGET_EXT"].append(".lib"); + } + + project->variables()["MSVCPROJ_VER"] = "7.00"; + project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /ZI"; + + // INCREMENTAL:NO ------------------------------------------------ + if(!project->isActiveConfig("incremental")) { + project->variables()["QMAKE_LFLAGS"].append(TQString("/INCREMENTAL:no")); + if ( is_qt ) + project->variables()["MSVCPROJ_DEBUG_OPT"] = "/GZ /Zi"; + } + + // MOC ----------------------------------------------------------- + if ( project->isActiveConfig("moc") ) + setMocAware(TRUE); + + // /VERSION:x.yz ------------------------------------------------- + if ( !project->variables()["VERSION"].isEmpty() ) { + TQString version = project->variables()["VERSION"][0]; + int firstDot = version.find( "." ); + TQString major = version.left( firstDot ); + TQString minor = version.right( version.length() - firstDot - 1 ); + minor.replace( ".", "" ); + project->variables()["QMAKE_LFLAGS"].append( "/VERSION:" + major + "." + minor ); + } + + project->variables()["QMAKE_LIBS"] += project->variables()["LIBS"]; + // Update -lname to name.lib, and -Ldir to + TQStringList &libList = project->variables()["QMAKE_LIBS"]; + for( it = libList.begin(); it != libList.end(); ) { + TQString s = *it; + s.replace("&", "&"); + if( s.startsWith( "-l" ) ) { + it = libList.remove( it ); + it = libList.insert( it, s.mid( 2 ) + ".lib" ); + } else if( s.startsWith( "-L" ) ) { + project->variables()["QMAKE_LIBDIR"] += (*it).mid(2); + it = libList.remove( it ); + } else { + it++; + } + } + + // Run through all variables containing filepaths, and ----------- + // slash-slosh them correctly depending on current OS ----------- + project->variables()["QMAKE_FILETAGS"] += TQStringList::split(' ', "HEADERS SOURCES DEF_FILE RC_FILE TARGET QMAKE_LIBS DESTDIR DLLDESTDIR INCLUDEPATH"); + TQStringList &l = project->variables()["QMAKE_FILETAGS"]; + for(it = l.begin(); it != l.end(); ++it) { + TQStringList &gdmf = project->variables()[(*it)]; + for(TQStringList::Iterator inner = gdmf.begin(); inner != gdmf.end(); ++inner) + (*inner) = Option::fixPathToTargetOS((*inner), FALSE); + } + + // Get filename w/o extention ----------------------------------- + TQString msvcproj_project = ""; + TQString targetfilename = ""; + if ( project->variables()["TARGET"].count() ) { + msvcproj_project = project->variables()["TARGET"].first(); + targetfilename = msvcproj_project; + } + + // Save filename w/o extention in $$QMAKE_ORIG_TARGET ------------ + project->variables()["QMAKE_ORIG_TARGET"] = project->variables()["TARGET"]; + + // TARGET (add extention to $$TARGET) + //project->variables()["MSVCPROJ_DEFINES"].append(varGlue(".first() += project->first("TARGET_EXT"); + + // Init base class too ------------------------------------------- + MakefileGenerator::init(); + + + if ( msvcproj_project.isEmpty() ) + msvcproj_project = Option::output.name(); + + msvcproj_project = msvcproj_project.right( msvcproj_project.length() - msvcproj_project.findRev( "\\" ) - 1 ); + msvcproj_project = msvcproj_project.left( msvcproj_project.findRev( "." ) ); + msvcproj_project.replace(TQRegExp("-"), ""); + + project->variables()["MSVCPROJ_PROJECT"].append(msvcproj_project); + TQStringList &proj = project->variables()["MSVCPROJ_PROJECT"]; + + for(it = proj.begin(); it != proj.end(); ++it) + (*it).replace(TQRegExp("\\.[a-zA-Z0-9_]*$"), ""); + + // SUBSYSTEM ----------------------------------------------------- + if ( !project->variables()["QMAKE_APP_FLAG"].isEmpty() ) { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32app" + project->first( "VCPROJ_EXTENSION" ) ); + if ( project->isActiveConfig("console") ) { + project->variables()["MSVCPROJ_CONSOLE"].append("CONSOLE"); + project->variables()["MSVCPROJ_WINCONDEF"].append("_CONSOLE"); + project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0103"); + project->variables()["MSVCPROJ_SUBSYSTEM"].append("CONSOLE"); + } else { + project->variables()["MSVCPROJ_CONSOLE"].clear(); + project->variables()["MSVCPROJ_WINCONDEF"].append("_WINDOWS"); + project->variables()["MSVCPROJ_VCPROJTYPE"].append("0x0101"); + project->variables()["MSVCPROJ_SUBSYSTEM"].append("WINDOWS"); + } + } else { + if ( project->isActiveConfig("dll") ) { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32dll" + project->first( "VCPROJ_EXTENSION" ) ); + } else { + project->variables()["MSVCPROJ_TEMPLATE"].append("win32lib" + project->first( "VCPROJ_EXTENSION" ) ); + } + } + + // $$QMAKE.. -> $$MSVCPROJ.. ------------------------------------- + project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS"]; + project->variables()["MSVCPROJ_LIBS"] += project->variables()["QMAKE_LIBS_WINDOWS"]; + project->variables()["MSVCPROJ_LFLAGS" ] += project->variables()["QMAKE_LFLAGS"]; + if ( !project->variables()["QMAKE_LIBDIR"].isEmpty() ) { + TQStringList strl = project->variables()["QMAKE_LIBDIR"]; + TQStringList::iterator stri; + for ( stri = strl.begin(); stri != strl.end(); ++stri ) { + (*stri).replace("&", "&"); + if ( !(*stri).startsWith("/LIBPATH:") ) + (*stri).prepend( "/LIBPATH:" ); + } + project->variables()["MSVCPROJ_LFLAGS"] += strl; + } + project->variables()["MSVCPROJ_CXXFLAGS" ] += project->variables()["QMAKE_CXXFLAGS"]; + // We don't use this... Direct manipulation of compiler object + //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("DEFINES","/D ","" " /D ","")); + //project->variables()["MSVCPROJ_DEFINES"].append(varGlue("PRL_EXPORT_DEFINES","/D ","" " /D ","")); + TQStringList &incs = project->variables()["INCLUDEPATH"]; + for(TQStringList::Iterator incit = incs.begin(); incit != incs.end(); ++incit) { + TQString inc = (*incit); + inc.replace("&", "&"); + inc.replace(TQRegExp("\""), ""); + project->variables()["MSVCPROJ_INCPATH"].append("/I" + inc ); + } + project->variables()["MSVCPROJ_INCPATH"].append("/I" + specdir()); + + TQString dest; + project->variables()["MSVCPROJ_TARGET"] = project->first("TARGET"); + Option::fixPathToTargetOS(project->first("TARGET")); + dest = project->first("TARGET") + project->first( "TARGET_EXT" ); + if ( project->first("TARGET").startsWith("$(QTDIR)") ) + dest.replace( TQRegExp("\\$\\(QTDIR\\)"), getenv("QTDIR") ); + project->variables()["MSVCPROJ_TARGET"] = dest; + + // DLL COPY ------------------------------------------------------ + if ( project->isActiveConfig("dll") && !project->variables()["DLLDESTDIR"].isEmpty() ) { + TQStringList dlldirs = project->variables()["DLLDESTDIR"].gres("&", "&"); + TQString copydll(""); + TQStringList::Iterator dlldir; + for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ++dlldir ) { + if ( !copydll.isEmpty() ) + copydll += " && "; + copydll += "copy "$(TargetPath)" "" + *dlldir + """; + } + + TQString deststr( "Copy " + dest + " to " ); + for ( dlldir = dlldirs.begin(); dlldir != dlldirs.end(); ) { + deststr += *dlldir; + ++dlldir; + if ( dlldir != dlldirs.end() ) + deststr += ", "; + } + + project->variables()["MSVCPROJ_COPY_DLL"].append( copydll ); + project->variables()["MSVCPROJ_COPY_DLL_DESC"].append( deststr ); + } + + // ACTIVEQT ------------------------------------------------------ + if ( project->isActiveConfig("activeqt") ) { + TQString idl = project->variables()["QMAKE_IDL"].first(); + TQString idc = project->variables()["QMAKE_IDC"].first(); + TQString version = project->variables()["VERSION"].first(); + if ( version.isEmpty() ) + version = "1.0"; + + TQString objdir = project->first( "OBJECTS_DIR" ); + project->variables()["MSVCPROJ_IDLSOURCES"].append( objdir + targetfilename + ".idl" ); + if ( project->isActiveConfig( "dll" ) ) { + TQString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveTQt server...\n" + "PostBuild_Cmds=" + + idc + " %1 -idl " + objdir + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb" + + "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb" + "\tregsvr32 /s %1\n" + "# End Special Build Tool"; + + TQString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_COPY_DLL_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_COPY_DLL_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } else { + TQString regcmd = "# Begin Special Build Tool\n" + "TargetPath=" + targetfilename + "\n" + "SOURCE=$(InputPath)\n" + "PostBuild_Desc=Finalizing ActiveTQt server...\n" + "PostBuild_Cmds=" + "%1 -dumpidl " + objdir + targetfilename + ".idl -version " + version + + "\t" + idl + " /nologo " + objdir + targetfilename + ".idl /tlb " + objdir + targetfilename + ".tlb" + "\t" + idc + " %1 /tlb " + objdir + targetfilename + ".tlb" + "\t%1 -regserver\n" + "# End Special Build Tool"; + + TQString executable = project->variables()["MSVCPROJ_TARGETDIRREL"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_REGSVR_REL"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + + executable = project->variables()["MSVCPROJ_TARGETDIRDEB"].first() + "\\" + project->variables()["TARGET"].first(); + project->variables()["MSVCPROJ_REGSVR_DBG"].append( regcmd.arg(executable).arg(executable).arg(executable) ); + } + } + + if ( !project->variables()["DEF_FILE"].isEmpty() ) + project->variables()["MSVCPROJ_LFLAGS"].append("/DEF:"+project->first("DEF_FILE")); + + // FORMS --------------------------------------------------------- + TQStringList &list = project->variables()["FORMS"]; + for( it = list.begin(); it != list.end(); ++it ) { + if ( TQFile::exists( *it + ".h" ) ) + project->variables()["SOURCES"].append( *it + ".h" ); + } + + project->variables()["QMAKE_INTERNAL_PRL_LIBS"] << "MSVCPROJ_LFLAGS" << "MSVCPROJ_LIBS"; + + // Verbose output if "-d -d"... + outputVariables(); +} + +// ------------------------------------------------------------------------------------------------ +// ------------------------------------------------------------------------------------------------ + +bool VcprojGenerator::openOutput(TQFile &file) const +{ + TQString outdir; + if(!file.name().isEmpty()) { + TQFileInfo fi(file); + if(fi.isDir()) + outdir = file.name() + TQDir::separator(); + } + if(!outdir.isEmpty() || file.name().isEmpty()) { + TQString ext = project->first("VCPROJ_EXTENSION"); + if(project->first("TEMPLATE") == "vcsubdirs") + ext = project->first("VCSOLUTION_EXTENSION"); + file.setName(outdir + project->first("TARGET") + ext); + } + if(TQDir::isRelativePath(file.name())) { + file.setName( Option::fixPathToLocalOS(TQDir::currentDirPath() + Option::dir_sep + fixFilename(file.name())) ); + } + return Win32MakefileGenerator::openOutput(file); +} + +TQString VcprojGenerator::fixFilename(TQString ofile) const +{ + int slashfind = ofile.findRev('\\'); + if (slashfind == -1) { + ofile = ofile.replace('-', '_'); + } else { + int hypenfind = ofile.find('-', slashfind); + while (hypenfind != -1 && slashfind < hypenfind) { + ofile = ofile.replace(hypenfind, 1, '_'); + hypenfind = ofile.find('-', hypenfind + 1); + } + } + return ofile; +} + +TQString VcprojGenerator::findTemplate(TQString file) +{ + TQString ret; + if(!TQFile::exists((ret = file)) && + !TQFile::exists((ret = TQString(Option::mkfile::qmakespec + "/" + file))) && + !TQFile::exists((ret = TQString(getenv("QTDIR")) + "/mkspecs/win32-msvc.net/" + file)) && + !TQFile::exists((ret = (TQString(getenv("HOME")) + "/.tmake/" + file)))) + return ""; + debug_msg(1, "Generator: MSVC.NET: Found template \'%s\'", ret.latin1() ); + return ret; +} + + +void VcprojGenerator::processPrlVariable(const TQString &var, const TQStringList &l) +{ + if(var == "QMAKE_PRL_DEFINES") { + TQStringList &out = project->variables()["MSVCPROJ_DEFINES"]; + for(TQStringList::ConstIterator it = l.begin(); it != l.end(); ++it) { + if(out.findIndex((*it)) == -1) + out.append((" /D " + *it )); + } + } else { + MakefileGenerator::processPrlVariable(var, l); + } +} + +void VcprojGenerator::outputVariables() +{ +#if 0 + qDebug( "Generator: MSVC.NET: List of current variables:" ); + for ( TQMap<TQString, TQStringList>::ConstIterator it = project->variables().begin(); it != project->variables().end(); ++it) { + qDebug( "Generator: MSVC.NET: %s => %s", it.key().latin1(), it.data().join(" | ").latin1() ); + } +#endif +} diff --git a/qmake/generators/win32/msvc_vcproj.h b/qmake/generators/win32/msvc_vcproj.h new file mode 100644 index 000000000..c6ec5cb11 --- /dev/null +++ b/qmake/generators/win32/msvc_vcproj.h @@ -0,0 +1,122 @@ + +/**************************************************************************** +** +** Definition of VcprojGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __MSVC_VCPROJ_H__ +#define __MSVC_VCPROJ_H__ + +#include "winmakefile.h" +#include "msvc_objectmodel.h" + +enum target { + Application, + SharedLib, + StaticLib +}; + +struct TQUuid; +class VcprojGenerator : public Win32MakefileGenerator +{ + bool init_flag; + bool writeVcprojParts(TQTextStream &); + + bool writeMakefile(TQTextStream &); + virtual void writeSubDirs(TQTextStream &t); + TQString findTemplate(TQString file); + void init(); + +public: + VcprojGenerator(TQMakeProject *p); + ~VcprojGenerator(); + + TQString defaultMakefile() const; + virtual bool doDepends() const { return FALSE; } //never necesary + TQString precompH, precompHFilename, + precompObj, precompPch; + bool usePCH; + +protected: + virtual bool openOutput(TQFile &file) const; + virtual void processPrlVariable(const TQString &, const TQStringList &); + virtual bool findLibraries(); + virtual void outputVariables(); + TQString fixFilename(TQString ofile) const; + + void initOld(); + void initProject(); + void initConfiguration(); + void initCompilerTool(); + void initLinkerTool(); + void initLibrarianTool(); + void initIDLTool(); + void initCustomBuildTool(); + void initPreBuildEventTools(); + void initPostBuildEventTools(); + void initPreLinkEventTools(); + void initSourceFiles(); + void initHeaderFiles(); + void initMOCFiles(); + void initUICFiles(); + void initFormsFiles(); + void initTranslationFiles(); + void initLexYaccFiles(); + void initResourceFiles(); + + VCProject vcProject; + target projectTarget; + +private: + TQUuid getProjectUUID(const TQString &filename=TQString::null); + TQUuid increaseUUID(const TQUuid &id); + friend class VCFilter; +}; + +inline VcprojGenerator::~VcprojGenerator() +{ } + +inline TQString VcprojGenerator::defaultMakefile() const +{ + return project->first("TARGET") + project->first("VCPROJ_EXTENSION"); +} + +inline bool VcprojGenerator::findLibraries() +{ + return Win32MakefileGenerator::findLibraries("MSVCVCPROJ_LIBS"); +} + +#endif /* __MSVC_VCPROJ_H__ */ diff --git a/qmake/generators/win32/winmakefile.cpp b/qmake/generators/win32/winmakefile.cpp new file mode 100644 index 000000000..6c92cb747 --- /dev/null +++ b/qmake/generators/win32/winmakefile.cpp @@ -0,0 +1,487 @@ +/**************************************************************************** +** +** Implementation of Win32MakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#include "winmakefile.h" +#include "option.h" +#include "project.h" +#include "meta.h" +#include <qtextstream.h> +#include <qstring.h> +#include <qdict.h> +#include <qregexp.h> +#include <qstringlist.h> +#include <qdir.h> + + +Win32MakefileGenerator::Win32MakefileGenerator(TQMakeProject *p) : MakefileGenerator(p) +{ + +} + + +struct SubDir +{ + TQString directory, profile, target, makefile; +}; + +void +Win32MakefileGenerator::writeSubDirs(TQTextStream &t) +{ + TQPtrList<SubDir> subdirs; + { + TQStringList subdirs_in = project->variables()["SUBDIRS"]; + for(TQStringList::Iterator it = subdirs_in.begin(); it != subdirs_in.end(); ++it) { + TQString file = (*it); + file = fileFixify(file); + SubDir *sd = new SubDir; + subdirs.append(sd); + sd->makefile = "$(MAKEFILE)"; + if((*it).right(4) == ".pro") { + int slsh = file.findRev(Option::dir_sep); + if(slsh != -1) { + sd->directory = file.left(slsh+1); + sd->profile = file.mid(slsh+1); + } else { + sd->profile = file; + } + } else { + sd->directory = file; + } + while(sd->directory.right(1) == Option::dir_sep) + sd->directory = sd->directory.left(sd->directory.length() - 1); + if(!sd->profile.isEmpty()) { + TQString basename = sd->directory; + int new_slsh = basename.findRev(Option::dir_sep); + if(new_slsh != -1) + basename = basename.mid(new_slsh+1); + if(sd->profile != basename + ".pro") + sd->makefile += "." + sd->profile.left(sd->profile.length() - 4); //no need for the .pro + } + sd->target = "sub-" + (*it); + sd->target.replace('/', '-'); + sd->target.replace('.', '_'); + } + } + TQPtrListIterator<SubDir> it(subdirs); + + t << "MAKEFILE = " << (project->isEmpty("MAKEFILE") ? TQString("Makefile") : var("MAKEFILE")) << endl; + t << "QMAKE = " << (project->isEmpty("QMAKE_QMAKE") ? TQString("qmake") : var("QMAKE_QMAKE")) << endl; + t << "SUBTARGETS = "; + for( it.toFirst(); it.current(); ++it) + t << " \\\n\t\t" << it.current()->target; + t << endl << endl; + t << "all: $(MAKEFILE) $(SUBTARGETS)" << endl << endl; + + for( it.toFirst(); it.current(); ++it) { + bool have_dir = !(*it)->directory.isEmpty(); + + //make the makefile + TQString mkfile = (*it)->makefile; + if(have_dir) + mkfile.prepend((*it)->directory + Option::dir_sep); + t << mkfile << ":"; + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + t << "\n\t" << "$(QMAKE) " << (*it)->profile << " " << buildArgs(); + t << " -o " << (*it)->makefile; + if(have_dir) { + int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + t << endl; + + //now actually build + t << (*it)->target << ": " << mkfile; + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << " FORCE"; + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + t << "\n\t" << "$(MAKE)"; + t << " -f " << (*it)->makefile; + if(have_dir) { + int subLevels = it.current()->directory.contains(Option::dir_sep) + 1; + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + t << endl << endl; + } + + if (project->isActiveConfig("ordered")) { // generate dependencies + for( it.toFirst(); it.current(); ) { + TQString tar = it.current()->target; + ++it; + if (it.current()) + t << it.current()->target << ": " << tar << endl; + } + t << endl; + } + + if(project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].findIndex("qmake_all") == -1) + project->variables()["QMAKE_INTERNAL_QMAKE_DEPS"].append("qmake_all"); + writeMakeQmake(t); + + t << "qmake_all:"; + if ( !subdirs.isEmpty() ) { + for( it.toFirst(); it.current(); ++it) { + bool have_dir = !(*it)->directory.isEmpty(); + TQString subdir = (*it)->directory; + TQString profile = (*it)->profile; + int subLevels = subdir.contains(Option::dir_sep) + 1; + t << "\n\t"; + if(have_dir) + t << "cd " << subdir << "\n\t"; + int lastSlash = subdir.findRev(Option::dir_sep); + if(lastSlash != -1) + subdir = subdir.mid( lastSlash + 1 ); + t << "$(QMAKE) " + << ( !profile.isEmpty() ? profile : subdir + ".pro" ) + << " -o " << (*it)->makefile + << " " << buildArgs() << "\n\t"; + if(have_dir) { + t << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + } + } else { + // Borland make does not like empty an empty command section, so insert + // a dummy command. + t << "\n\t" << "@cd ."; + } + t << endl << endl; + + TQStringList targs; + targs << "clean" << "install_subdirs" << "mocables" << "uicables" << "uiclean" << "mocclean"; + targs += project->values("SUBDIR_TARGETS"); + for(TQStringList::Iterator targ_it = targs.begin(); targ_it != targs.end(); ++targ_it) { + t << (*targ_it) << ": qmake_all"; + TQString targ = (*targ_it); + if(targ == "install_subdirs") + targ = "install"; + else if(targ == "uninstall_subdirs") + targ = "uninstall"; + if(targ == "clean") + t << varGlue("QMAKE_CLEAN","\n\t-$(DEL_FILE) ","\n\t-$(DEL_FILE) ", ""); + if (!subdirs.isEmpty()) { + for( it.toFirst(); it.current(); ++it) { + int subLevels = (*it)->directory.contains(Option::dir_sep) + 1; + bool have_dir = !(*it)->directory.isEmpty(); + if(have_dir) + t << "\n\t" << "cd " << (*it)->directory; + TQString in_file = " -f " + (*it)->makefile; + t << "\n\t" << "$(MAKE) " << in_file << " " << targ; + if(have_dir) { + t << "\n\t" << "@cd .."; + for(int i = 1; i < subLevels; i++ ) + t << Option::dir_sep << ".."; + } + } + } else { + // Borland make does not like empty an empty command section, so + // insert a dummy command. + t << "\n\t" << "@cd ."; + } + t << endl << endl; + } + + //installations + project->variables()["INSTALLDEPS"] += "install_subdirs"; + project->variables()["UNINSTALLDEPS"] += "uninstall_subdirs"; + writeInstalls(t, "INSTALLS"); + + // user defined targets + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(TQStringList::Iterator sit = qut.begin(); sit != qut.end(); ++sit) { + TQString targ = var((*sit) + ".target"), + cmd = var((*sit) + ".commands"), deps; + if(targ.isEmpty()) + targ = (*sit); + TQStringList &deplist = project->variables()[(*sit) + ".depends"]; + for(TQStringList::Iterator dep_it = deplist.begin(); dep_it != deplist.end(); ++dep_it) { + TQString dep = var((*dep_it) + ".target"); + if(dep.isEmpty()) + dep = (*dep_it); + deps += " " + dep; + } + if(!project->variables()["QMAKE_NOFORCE"].isEmpty() && + project->variables()[(*sit) + ".CONFIG"].findIndex("phony") != -1) + deps += TQString(" ") + "FORCE"; + t << targ << ":" << deps << "\n"; + if(!cmd.isEmpty()) + t << "\t" << cmd << endl; + t << endl; + } + t << endl << endl; + + if(project->variables()["QMAKE_NOFORCE"].isEmpty()) + t << "FORCE:" << endl << endl; +} + + +int +Win32MakefileGenerator::findHighestVersion(const TQString &d, const TQString &stem) +{ + TQString bd = Option::fixPathToLocalOS(d, TRUE); + if(!TQFile::exists(bd)) + return -1; + if(!project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].isEmpty()) + return project->variables()["QMAKE_" + stem.upper() + "_VERSION_OVERRIDE"].first().toInt(); + + TQDir dir(bd); + int biggest=-1; + TQStringList entries = dir.entryList(); + TQString dllStem = stem + TQTDLL_POSTFIX; + TQRegExp regx( "(" + dllStem + "([0-9]*)).lib", FALSE ); + for(TQStringList::Iterator it = entries.begin(); it != entries.end(); ++it) { + if(regx.exactMatch((*it))) + biggest = TQMAX(biggest, (regx.cap(1) == dllStem || + regx.cap(2).isEmpty()) ? -1 : regx.cap(2).toInt()); + } + TQMakeMetaInfo libinfo; + if(libinfo.readLib(bd + dllStem)) { + if(!libinfo.isEmpty("QMAKE_PRL_VERSION")) + biggest = TQMAX(biggest, libinfo.first("QMAKE_PRL_VERSION").replace(".", "").toInt()); + } + return biggest; +} + +TQString +Win32MakefileGenerator::findDependency(const TQString &dep) +{ + { + TQStringList &qut = project->variables()["QMAKE_EXTRA_WIN_TARGETS"]; + for(TQStringList::Iterator it = qut.begin(); it != qut.end(); ++it) { + TQString targ = var((*it) + ".target"); + if(targ.isEmpty()) + targ = (*it); + if(targ.endsWith(dep)) + return targ; + } + } + { + TQStringList &quc = project->variables()["QMAKE_EXTRA_WIN_COMPILERS"]; + for(TQStringList::Iterator it = quc.begin(); it != quc.end(); ++it) { + TQString tmp_out = project->variables()[(*it) + ".output"].first(); + TQString tmp_cmd = project->variables()[(*it) + ".commands"].join(" "); + if(tmp_out.isEmpty() || tmp_cmd.isEmpty()) + continue; + TQStringList &tmp = project->variables()[(*it) + ".input"]; + for(TQStringList::Iterator it2 = tmp.begin(); it2 != tmp.end(); ++it2) { + TQStringList &inputs = project->variables()[(*it2)]; + for(TQStringList::Iterator input = inputs.begin(); input != inputs.end(); ++input) { + TQString out = tmp_out; + TQFileInfo fi(Option::fixPathToLocalOS((*input))); + out.replace("${QMAKE_FILE_BASE}", fi.baseName()); + out.replace("${QMAKE_FILE_NAME}", fi.filePath()); + if(out.endsWith(dep)) + return out; + } + } + } + } + return MakefileGenerator::findDependency(dep); +} + +bool +Win32MakefileGenerator::findLibraries(const TQString &where) +{ + + TQStringList &l = project->variables()[where]; + TQPtrList<MakefileDependDir> dirs; + { + TQStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; + for(TQStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { + TQString r = (*libpathit), l = r; + fixEnvVariables(l); + dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); + } + } + dirs.setAutoDelete(TRUE); + for(TQStringList::Iterator it = l.begin(); it != l.end(); ) { + TQChar quote; + bool modified_opt = FALSE, remove = FALSE; + TQString opt = (*it).stripWhiteSpace(); + if((opt[0] == '\'' || opt[0] == '"') && opt[(int)opt.length()-1] == opt[0]) { + quote = opt[0]; + opt = opt.mid(1, opt.length()-2); + } + if(opt.startsWith("/LIBPATH:")) { + TQString r = opt.mid(9), l = Option::fixPathToLocalOS(r); + dirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } else if(opt.startsWith("-L") || opt.startsWith("/L")) { + TQString r = opt.mid(2), l = Option::fixPathToLocalOS(r); + dirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + remove = TRUE; //we eat this switch + } else if(opt.startsWith("-l") || opt.startsWith("/l")) { + TQString lib = opt.right(opt.length() - 2), out; + if(!lib.isEmpty()) { + for(MakefileDependDir *mdd = dirs.first(); mdd; mdd = dirs.next() ) { + TQString extension; + int ver = findHighestVersion(mdd->local_dir, lib); + if(ver > 0) + extension += TQString::number(ver); + extension += ".lib"; + if(TQMakeMetaInfo::libExists(mdd->local_dir + Option::dir_sep + lib) || + TQFile::exists(mdd->local_dir + Option::dir_sep + lib + extension)) { + out = mdd->real_dir + Option::dir_sep + lib + extension; + break; + } + } + } + if(out.isEmpty()) { + remove = TRUE; //just eat it since we cannot find one.. + } else { + modified_opt = TRUE; + (*it) = out; + } + } else if(!TQFile::exists(Option::fixPathToLocalOS(opt))) { + TQPtrList<MakefileDependDir> lib_dirs; + TQString file = opt; + int slsh = file.findRev(Option::dir_sep); + if(slsh != -1) { + TQString r = file.left(slsh+1), l = r; + fixEnvVariables(l); + lib_dirs.append(new MakefileDependDir(r.replace("\"",""), l.replace("\"",""))); + file = file.right(file.length() - slsh - 1); + } else { + lib_dirs = dirs; + } +#if 0 + if (!project->variables()["QMAKE_QT_DLL"].isEmpty()) { + if(file.endsWith(".lib")) { + file = file.left(file.length() - 4); + if(!file.at(file.length()-1).isNumber()) { + for(MakefileDependDir *mdd = lib_dirs.first(); mdd; mdd = lib_dirs.next() ) { + TQString lib_tmpl(file + "%1" + ".lib"); + int ver = findHighestVersion(mdd->local_dir, file); + if(ver != -1) { + if(ver) + lib_tmpl = lib_tmpl.arg(ver); + else + lib_tmpl = lib_tmpl.arg(""); + if(slsh != -1) { + TQString dir = mdd->real_dir; + if(!dir.endsWith(Option::dir_sep)) + dir += Option::dir_sep; + lib_tmpl.prepend(dir); + } + modified_opt = TRUE; + (*it) = lib_tmpl; + break; + } + } + } + } + } +#endif + } + if(remove) { + it = l.remove(it); + } else { + if(!quote.isNull() && modified_opt) + (*it) = quote + (*it) + quote; + ++it; + } + } + return TRUE; +} + +void +Win32MakefileGenerator::processPrlFiles() +{ + TQDict<void> processed; + TQPtrList<MakefileDependDir> libdirs; + libdirs.setAutoDelete(TRUE); + { + TQStringList &libpaths = project->variables()["QMAKE_LIBDIR"]; + for(TQStringList::Iterator libpathit = libpaths.begin(); libpathit != libpaths.end(); ++libpathit) { + TQString r = (*libpathit), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } + } + for(bool ret = FALSE; TRUE; ret = FALSE) { + //read in any prl files included.. + TQStringList l_out; + TQString where = "QMAKE_LIBS"; + if(!project->isEmpty("QMAKE_INTERNAL_PRL_LIBS")) + where = project->first("QMAKE_INTERNAL_PRL_LIBS"); + TQStringList &l = project->variables()[where]; + for(TQStringList::Iterator it = l.begin(); it != l.end(); ++it) { + TQString opt = (*it); + if(opt.startsWith("/")) { + if(opt.startsWith("/LIBPATH:")) { + TQString r = opt.mid(9), l = r; + fixEnvVariables(l); + libdirs.append(new MakefileDependDir(r.replace("\"",""), + l.replace("\"",""))); + } + } else { + if(!processed[opt]) { + if(processPrlFile(opt)) { + processed.insert(opt, (void*)1); + ret = TRUE; + } else { + for(MakefileDependDir *mdd = libdirs.first(); mdd; mdd = libdirs.next() ) { + TQString prl = mdd->local_dir + Option::dir_sep + opt; + if(processed[prl]) { + break; + } else if(processPrlFile(prl)) { + processed.insert(prl, (void*)1); + ret = TRUE; + break; + } + } + } + } + } + if(!opt.isEmpty()) + l_out.append(opt); + } + if(ret) + l = l_out; + else + break; + } +} diff --git a/qmake/generators/win32/winmakefile.h b/qmake/generators/win32/winmakefile.h new file mode 100644 index 000000000..395638025 --- /dev/null +++ b/qmake/generators/win32/winmakefile.h @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Definition of Win32MakefileGenerator class. +** +** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved. +** +** This file is part of qmake. +** +** This file may be used under the terms of the GNU General +** Public License versions 2.0 or 3.0 as published by the Free +** Software Foundation and appearing in the files LICENSE.GPL2 +** and LICENSE.GPL3 included in the packaging of this file. +** Alternatively you may (at your option) use any later version +** of the GNU General Public License if such license has been +** publicly approved by Trolltech ASA (or its successors, if any) +** and the KDE Free TQt Foundation. +** +** Please review the following information to ensure GNU General +** Public Licensing retquirements will be met: +** http://trolltech.com/products/qt/licenses/licensing/opensource/. +** If you are unsure which license is appropriate for your use, please +** review the following information: +** http://trolltech.com/products/qt/licenses/licensing/licensingoverview +** or contact the sales department at [email protected]. +** +** This file may be used under the terms of the Q Public License as +** defined by Trolltech ASA and appearing in the file LICENSE.TQPL +** included in the packaging of this file. Licensees holding valid TQt +** Commercial licenses may use this file in accordance with the TQt +** Commercial License Agreement provided with the Software. +** +** This file is provided "AS IS" with NO WARRANTY OF ANY KIND, +** INCLUDING THE WARRANTIES OF DESIGN, MERCHANTABILITY AND FITNESS FOR +** A PARTICULAR PURPOSE. Trolltech reserves all rights not granted +** herein. +** +**********************************************************************/ + +#ifndef __WINMAKEFILE_H__ +#define __WINMAKEFILE_H__ + +#include "makefile.h" + +// In the TQt evaluation and educational version, we have a postfix in the +// library name (e.g. qtmteval301.dll). TQTDLL_POSTFIX is used for this. +// A script modifies these lines when building eval/edu version, so be careful +// when changing them. +#ifndef TQTDLL_POSTFIX +#define TQTDLL_POSTFIX "" +#endif + +class Win32MakefileGenerator : public MakefileGenerator +{ +protected: + virtual void writeSubDirs(TQTextStream &t); + int findHighestVersion(const TQString &dir, const TQString &stem); + bool findLibraries(const TQString &); + TQString findDependency(const TQString &); + virtual bool findLibraries(); + virtual void processPrlFiles(); + +public: + Win32MakefileGenerator(TQMakeProject *p); + ~Win32MakefileGenerator(); +}; + +inline Win32MakefileGenerator::~Win32MakefileGenerator() +{ } + +inline bool Win32MakefileGenerator::findLibraries() +{ return findLibraries("QMAKE_LIBS"); } + + + +#endif /* __WINMAKEFILE_H__ */ |