work save
This commit is contained in:
parent
fc34defe13
commit
c72afb3558
|
@ -286,7 +286,6 @@ QString Compiler::getCCompileArguments(bool checkSyntax)
|
||||||
if (
|
if (
|
||||||
(mProject && (i < mProject->options().compilerOptions.length()))
|
(mProject && (i < mProject->options().compilerOptions.length()))
|
||||||
|| (!mProject && (pOption->value > 0))) {
|
|| (!mProject && (pOption->value > 0))) {
|
||||||
|
|
||||||
int value;
|
int value;
|
||||||
if (mProject) {
|
if (mProject) {
|
||||||
value = Settings::CompilerSet::charToValue(mProject->options().compilerOptions[i]);
|
value = Settings::CompilerSet::charToValue(mProject->options().compilerOptions[i]);
|
||||||
|
@ -309,6 +308,14 @@ QString Compiler::getCCompileArguments(bool checkSyntax)
|
||||||
if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) {
|
if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) {
|
||||||
result += " "+compilerSet()->customCompileParams();
|
result += " "+compilerSet()->customCompileParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mProject) {
|
||||||
|
QString s = mProject->options().compilerCmd;
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
s.replace("_@@_", " ");
|
||||||
|
result += " "+s;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,14 +327,26 @@ QString Compiler::getCppCompileArguments(bool checkSyntax)
|
||||||
result += " -fsyntax-only";
|
result += " -fsyntax-only";
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (const PCompilerOption& pOption, compilerSet()->options()) {
|
for (int i=0;i<compilerSet()->options().size();i++) {
|
||||||
if (pOption->value > 0 && pOption->isCpp) {
|
PCompilerOption pOption = compilerSet()->options()[i];
|
||||||
if (pOption->choices.isEmpty()) {
|
// consider project specific options for the compiler, else global compiler options
|
||||||
result += " "+pOption->setting;
|
if (
|
||||||
} else if (pOption->value < pOption->choices.size()) {
|
(mProject && (i < mProject->options().compilerOptions.length()))
|
||||||
QStringList nameValue=pOption->choices[pOption->value].split('=');
|
|| (!mProject && (pOption->value > 0))) {
|
||||||
if (nameValue.count()==2) {
|
int value;
|
||||||
result += " "+pOption->setting + nameValue[1];
|
if (mProject) {
|
||||||
|
value = Settings::CompilerSet::charToValue(mProject->options().compilerOptions[i]);
|
||||||
|
} else {
|
||||||
|
value = pOption->value;
|
||||||
|
}
|
||||||
|
if (value > 0 && pOption->isCpp) {
|
||||||
|
if (pOption->choices.isEmpty()) {
|
||||||
|
result += " " + pOption->setting;
|
||||||
|
} else if (value < pOption->choices.size()) {
|
||||||
|
QStringList nameValue=pOption->choices[value].split('=');
|
||||||
|
if (nameValue.count()==2) {
|
||||||
|
result += " " + pOption->setting + nameValue[1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -336,6 +355,13 @@ QString Compiler::getCppCompileArguments(bool checkSyntax)
|
||||||
if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) {
|
if (compilerSet()->useCustomCompileParams() && !compilerSet()->customCompileParams().isEmpty()) {
|
||||||
result += " "+compilerSet()->customCompileParams();
|
result += " "+compilerSet()->customCompileParams();
|
||||||
}
|
}
|
||||||
|
if (mProject) {
|
||||||
|
QString s = mProject->options().cppCompilerCmd;
|
||||||
|
if (!s.isEmpty()) {
|
||||||
|
s.replace("_@@_", " ");
|
||||||
|
result += " "+s;
|
||||||
|
}
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -374,10 +400,18 @@ QString Compiler::getLibraryArguments(FileType fileType)
|
||||||
{
|
{
|
||||||
QString result;
|
QString result;
|
||||||
|
|
||||||
|
//Add libraries
|
||||||
foreach (const QString& folder, compilerSet()->libDirs()) {
|
foreach (const QString& folder, compilerSet()->libDirs()) {
|
||||||
result += QString(" -L\"%1\"").arg(folder);
|
result += QString(" -L\"%1\"").arg(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add libs added via project
|
||||||
|
if (mProject) {
|
||||||
|
foreach (const QString& folder, mProject->options().libs){
|
||||||
|
result += QString(" -L\"%1\"").arg(folder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Add auto links
|
//Add auto links
|
||||||
// is file and auto link enabled
|
// is file and auto link enabled
|
||||||
if (pSettings->editor().enableAutolink() && (fileType == FileType::CSource ||
|
if (pSettings->editor().enableAutolink() && (fileType == FileType::CSource ||
|
||||||
|
@ -407,27 +441,50 @@ QString Compiler::getLibraryArguments(FileType fileType)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//add compiler set link options
|
||||||
|
//options like "-static" must be added after "-lxxx"
|
||||||
|
for (int i=0;i<compilerSet()->options().size();i++) {
|
||||||
|
PCompilerOption pOption = compilerSet()->options()[i];
|
||||||
|
// consider project specific options for the compiler, else global compiler options
|
||||||
|
if (
|
||||||
|
(mProject && (i < mProject->options().compilerOptions.length()))
|
||||||
|
|| (!mProject && (pOption->value > 0))) {
|
||||||
|
int value;
|
||||||
|
if (mProject) {
|
||||||
|
value = Settings::CompilerSet::charToValue(mProject->options().compilerOptions[i]);
|
||||||
|
} else {
|
||||||
|
value = pOption->value;
|
||||||
|
}
|
||||||
|
if (value > 0 && pOption->isLinker) {
|
||||||
|
if (pOption->choices.isEmpty()) {
|
||||||
|
result += " " + pOption->setting;
|
||||||
|
} else if (value < pOption->choices.size()) {
|
||||||
|
QStringList nameValue=pOption->choices[value].split('=');
|
||||||
|
if (nameValue.count()==2) {
|
||||||
|
result += " " + pOption->setting + nameValue[1];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Add global compiler linker extras
|
// Add global compiler linker extras
|
||||||
if (compilerSet()->useCustomLinkParams() && !compilerSet()->customLinkParams().isEmpty()) {
|
if (compilerSet()->useCustomLinkParams() && !compilerSet()->customLinkParams().isEmpty()) {
|
||||||
result += " "+compilerSet()->customCompileParams();
|
result += " "+compilerSet()->customCompileParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
//options like "-static" must be added after "-lxxx"
|
if (mProject) {
|
||||||
foreach (const PCompilerOption& pOption, compilerSet()->options()) {
|
if (mProject->options().type == ProjectType::GUI) {
|
||||||
if (pOption->value > 0 && pOption->isLinker) {
|
result += " -mwindows";
|
||||||
if (pOption->choices.isEmpty()) {
|
|
||||||
result += " " + pOption->setting;
|
|
||||||
} else if (pOption->value < pOption->choices.size()) {
|
|
||||||
QStringList nameValue=pOption->choices[pOption->value].split('=');
|
|
||||||
if (nameValue.count()==2) {
|
|
||||||
result += " " + pOption->setting + nameValue[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (compilerSet()->staticLink()) {
|
if (!mProject->options().linkerCmd.isEmpty()) {
|
||||||
|
result += " " + mProject->options().linkerCmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mProject->options().staticLink)
|
||||||
|
result += " -static";
|
||||||
|
} else if (compilerSet()->staticLink()) {
|
||||||
result += " -static";
|
result += " -static";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
|
|
|
@ -96,7 +96,7 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
||||||
|
|
||||||
// Create a list of object files
|
// Create a list of object files
|
||||||
for (int i=0;i<mProject->units().count();i++) {
|
for (int i=0;i<mProject->units().count();i++) {
|
||||||
PProjectUnit unit = mProject[i];
|
PProjectUnit unit = mProject->units()[i];
|
||||||
if (!unit->compile() && !unit->link())
|
if (!unit->compile() && !unit->link())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -143,54 +143,59 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
||||||
// Get list of applicable flags
|
// Get list of applicable flags
|
||||||
QString cCompileArguments = getCCompileArguments(mOnlyCheckSyntax);
|
QString cCompileArguments = getCCompileArguments(mOnlyCheckSyntax);
|
||||||
QString cppCompileArguments = getCppCompileArguments(mOnlyCheckSyntax);
|
QString cppCompileArguments = getCppCompileArguments(mOnlyCheckSyntax);
|
||||||
QString libraryArguments = getLibraryArguments();
|
QString libraryArguments = getLibraryArguments(FileType::Project);
|
||||||
QString cIncludeArguments = getCIncludeArguments();
|
QString cIncludeArguments = getCIncludeArguments() + " " + getProjectIncludeArguments();
|
||||||
QString cppIncludeArguments = getCppIncludeArguments();
|
QString cppIncludeArguments = getCppIncludeArguments() + " " +getProjectIncludeArguments();
|
||||||
QString projectIncludeArguments = getProjectIncludeArguments();
|
|
||||||
|
if (cCompileArguments.indexOf(" -g3")>=0
|
||||||
|
|| cCompileArguments.startsWith("-g3")) {
|
||||||
|
cCompileArguments += " -D__DEBUG__";
|
||||||
|
cppCompileArguments+= " -D__DEBUG__";
|
||||||
|
}
|
||||||
|
writeln(file,"CPP = " + compilerSet()->cppCompiler());
|
||||||
|
writeln(file,"CC = " + compilerSet()->CCompiler());
|
||||||
|
writeln(file,"WINDRES = " + compilerSet()->resourceCompiler());
|
||||||
|
if (!ObjResFile.isEmpty()) {
|
||||||
|
writeln(file,"RES = " + genMakePath1(ObjResFile));
|
||||||
|
writeln(file,"OBJ = " + Objects + " $(RES)");
|
||||||
|
writeln(file,"LINKOBJ = " + LinkObjects + " $(RES)");
|
||||||
|
} else {
|
||||||
|
writeln(file,"OBJ = " + Objects);
|
||||||
|
writeln(file,"LINKOBJ = " + LinkObjects);
|
||||||
|
};
|
||||||
|
libraryArguments.replace('\\', '/');
|
||||||
|
writeln(file,"LIBS = " + libraryArguments);
|
||||||
|
cIncludeArguments.replace('\\', '/');
|
||||||
|
writeln(file,"INCS = " + cIncludeArguments);
|
||||||
|
cppIncludeArguments.replace('\\', '/');
|
||||||
|
writeln(file,"CXXINCS = " + cppIncludeArguments);
|
||||||
|
writeln(file,"BIN = " + genMakePath1(extractRelativePath(mProject->makeFileName(), mProject->executable())));
|
||||||
|
cppCompileArguments.replace('\\', '/');
|
||||||
|
writeln(file,"CXXFLAGS = $(CXXINCS) " + cppCompileArguments);
|
||||||
|
//writeln(file,"ENCODINGS = -finput-charset=utf-8 -fexec-charset='+GetSystemCharsetName);
|
||||||
|
cCompileArguments.replace('\\', '/');
|
||||||
|
writeln(file,"CFLAGS = $(INCS) " + cCompileArguments);
|
||||||
|
writeln(file, QString("RM = ") + CLEAN_PROGRAM );
|
||||||
|
if (mProject->options().usePrecompiledHeader){
|
||||||
|
writeln(file,"PCH_H = " + mProject->options().precompiledHeader );
|
||||||
|
writeln(file,"PCH = " + changeFileExt(mProject->options().precompiledHeader, GCH_EXT));
|
||||||
|
}
|
||||||
|
|
||||||
if (Pos(' -g3', fCompileParams) > 0) or (Pos('-g3', fCompileParams) = 1) then begin
|
|
||||||
Writeln(F, 'CPP = ' + fCompilerSet.gppName + ' -D__DEBUG__');
|
|
||||||
Writeln(F, 'CC = ' + fCompilerSet.gccName + ' -D__DEBUG__');
|
|
||||||
end else begin
|
|
||||||
Writeln(F, 'CPP = ' + fCompilerSet.gppName);
|
|
||||||
Writeln(F, 'CC = ' + fCompilerSet.gccName);
|
|
||||||
end;
|
|
||||||
Writeln(F, 'WINDRES = ' + fCompilerSet.windresName);
|
|
||||||
if (ObjResFile <> '') then begin
|
|
||||||
Writeln(F, 'RES = ' + GenMakePath1(ObjResFile));
|
|
||||||
Writeln(F, 'OBJ = ' + Objects + ' $(RES)');
|
|
||||||
Writeln(F, 'LINKOBJ = ' + LinkObjects + ' $(RES)');
|
|
||||||
end else begin
|
|
||||||
Writeln(F, 'OBJ = ' + Objects);
|
|
||||||
Writeln(F, 'LINKOBJ = ' + LinkObjects);
|
|
||||||
end;
|
|
||||||
Writeln(F, 'LIBS = ' + StringReplace(fLibrariesParams, '\', '/', [rfReplaceAll]));
|
|
||||||
Writeln(F, 'INCS = ' + StringReplace(fIncludesParams, '\', '/', [rfReplaceAll]));
|
|
||||||
Writeln(F, 'CXXINCS = ' + StringReplace(fCppIncludesParams, '\', '/', [rfReplaceAll]));
|
|
||||||
Writeln(F, 'BIN = ' + GenMakePath1(ExtractRelativePath(Makefile, fProject.Executable)));
|
|
||||||
Writeln(F, 'CXXFLAGS = $(CXXINCS) ' + fCppCompileParams);
|
|
||||||
Writeln(F, 'ENCODINGS = -finput-charset=utf-8 -fexec-charset='+GetSystemCharsetName);
|
|
||||||
Writeln(F, 'CFLAGS = $(INCS) ' + fCompileParams);
|
|
||||||
// Writeln(F, 'RM = ' + CLEAN_PROGRAM + ' -f'); // TODO: use del or rm?
|
|
||||||
Writeln(F, 'RM = ' + CLEAN_PROGRAM + ' /f'); // TODO: use del or rm?
|
|
||||||
if fProject.Options.UsePrecompiledHeader then begin
|
|
||||||
Writeln(F, 'PCH_H = ' + fProject.Options.PrecompiledHeader );
|
|
||||||
Writeln(F, 'PCH = ' + fProject.Options.PrecompiledHeader +'.gch' );
|
|
||||||
end;
|
|
||||||
|
|
||||||
// This needs to be put in before the clean command.
|
// This needs to be put in before the clean command.
|
||||||
if fProject.Options.typ = dptDyn then begin
|
if (mProject->options().type == ProjectType::DynamicLib) {
|
||||||
OutputFileDir := ExtractFilePath(Project.Executable);
|
QString OutputFileDir = extractFilePath(mProject->executable());
|
||||||
LibOutputFile := OutputFileDir + 'lib' + ExtractFileName(Project.Executable);
|
QString libOutputFile = includeTrailingPathDelimiter(OutputFileDir) + "lib" + extractFileName(mProject->executable());
|
||||||
if FileSamePath(LibOutputFile, Project.Directory) then
|
if (QFileInfo(libOutputFile).absoluteFilePath()
|
||||||
LibOutputFile := ExtractFileName(LibOutputFile)
|
== mProject->directory())
|
||||||
else
|
libOutputFile = extractFileName(libOutputFile);
|
||||||
LibOutputFile := ExtractRelativePath(Makefile, LibOutputFile);
|
else
|
||||||
|
libOutputFile = extractRelativePath(mProject->makeFileName(), libOutputFile);
|
||||||
|
writeln(file,"DEF = " + genMakePath1(changeFileExt(libOutputFile, DEF_EXT)));
|
||||||
|
writeln(file,"STATIC = " + genMakePath1(changeFileExt(libOutputFile, LIB_EXT)));
|
||||||
|
|
||||||
Writeln(F, 'DEF = ' + GenMakePath1(ChangeFileExt(LibOutputFile, DEF_EXT)));
|
}
|
||||||
Writeln(F, 'STATIC = ' + GenMakePath1(ChangeFileExt(LibOutputFile, LIB_EXT)));
|
writeln(file);
|
||||||
end;
|
|
||||||
Writeln(F);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectCompiler::writeln(QFile &file, const QString &s)
|
void ProjectCompiler::writeln(QFile &file, const QString &s)
|
||||||
|
|
|
@ -17,6 +17,7 @@ private:
|
||||||
void newMakeFile(QFile& file);
|
void newMakeFile(QFile& file);
|
||||||
void writeMakeHeader(QFile& file);
|
void writeMakeHeader(QFile& file);
|
||||||
void writeMakeDefines(QFile& file);
|
void writeMakeDefines(QFile& file);
|
||||||
|
void writeMakeTarget(QFile& file);
|
||||||
void writeln(QFile& file, const QString& s="");
|
void writeln(QFile& file, const QString& s="");
|
||||||
// Compiler interface
|
// Compiler interface
|
||||||
protected:
|
protected:
|
||||||
|
|
|
@ -23,6 +23,9 @@
|
||||||
#define RES_EXT "rc"
|
#define RES_EXT "rc"
|
||||||
#define H_EXT "h"
|
#define H_EXT "h"
|
||||||
#define OBJ_EXT "o"
|
#define OBJ_EXT "o"
|
||||||
|
#define DEF_EXT "def"
|
||||||
|
#define LIB_EXT "a"
|
||||||
|
#define GCH_EXT "gch"
|
||||||
#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
|
#define DEV_INTERNAL_OPEN "$__DEV_INTERNAL_OPEN"
|
||||||
|
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
|
|
Loading…
Reference in New Issue