- fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc

This commit is contained in:
Roy Qu 2023-02-13 19:21:11 +08:00
parent d484c790a2
commit 08fdeca219
4 changed files with 21 additions and 20 deletions

View File

@ -16,6 +16,7 @@ Red Panda C++ Version 2.12
- enhancement: New GAS File in the File Menu
- change: rename "New File" to "New C/C++ File"
- change: The default disassemble style of CPU Dialog is "AT&T" now.
- fix: Can't compile files with chinese characters in filenames using winlibs mingw gcc
Red Panda C++ Version 2.11

View File

@ -665,7 +665,7 @@ void Compiler::runCommand(const QString &cmd, const QString &arguments, const Q
}
env.insert("PATH",path);
}
env.insert("LANG","en");
//env.insert("LANG","en");
env.insert("LDFLAGS","-Wl,--stack,12582912");
env.insert("CFLAGS","");
env.insert("CXXFLAGS","");

View File

@ -55,9 +55,9 @@ void ProjectCompiler::createStandardMakeFile()
file.write("$(BIN): $(OBJ)\n");
if (!mOnlyCheckSyntax) {
if (mProject->options().isCpp) {
writeln(file,"\t$(CPP) $(LINKOBJ) -o $(BIN) $(LIBS)");
writeln(file,"\t$(CPP) $(LINKOBJ) -o \"$(BIN)\" $(LIBS)");
} else
writeln(file,"\t$(CC) $(LINKOBJ) -o $(BIN) $(LIBS)");
writeln(file,"\t$(CC) $(LINKOBJ) -o \"$(BIN)\" $(LIBS)");
}
writeMakeObjFilesRules(file);
}
@ -81,9 +81,9 @@ void ProjectCompiler::createDynamicMakeFile()
writeln(file,"$(BIN): $(LINKOBJ)");
if (!mOnlyCheckSyntax) {
if (mProject->options().isCpp) {
writeln(file, "\t$(CPP) -mdll $(LINKOBJ) -o $(BIN) $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
writeln(file, "\t$(CPP) -mdll $(LINKOBJ) -o \"$(BIN)\" $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
} else {
writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o $(BIN) $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o \"$(BIN)\" $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
}
}
writeMakeObjFilesRules(file);
@ -494,17 +494,17 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
writeln(file, "\t(CC) -c " + genMakePath1(shortFileName) + " $(CFLAGS) " + encodingStr);
} else {
if (unit->compileCpp())
writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CXXFLAGS) " + encodingStr);
writeln(file, "\t$(CPP) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CXXFLAGS) " + encodingStr);
else
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr);
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CFLAGS) " + encodingStr);
}
} else if (fileType==FileType::GAS) {
if (!mOnlyCheckSyntax) {
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(CFLAGS) " + encodingStr);
writeln(file, "\t$(CC) -c " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(CFLAGS) " + encodingStr);
}
} else if (fileType==FileType::ASM) {
if (!mOnlyCheckSyntax) {
writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o " + objFileName2 + " $(ASMFLAGS) ");
writeln(file, "\t$(ASM) " + genMakePath1(shortFileName) + " -o \"" + objFileName2 + "\" $(ASMFLAGS) ");
}
}
}
@ -561,7 +561,7 @@ void ProjectCompiler::writeMakeObjFilesRules(QFile &file)
} else {
writeln(file);
writeln(file, objFileName2 + ": " + privResName2 + ' ' + resFiles);
writeln(file, "\t$(WINDRES) -i " + privResName + windresArgs + " --input-format=rc -o " + objFileName + " -O coff $(WINDRESFLAGS)"
writeln(file, "\t$(WINDRES) -i " + privResName + windresArgs + " --input-format=rc -o \"" + objFileName + "\" -O coff $(WINDRESFLAGS)"
+ ResIncludes);
}
writeln(file);

View File

@ -3021,16 +3021,6 @@ void MainWindow::onBookmarkContextMenu(const QPoint &pos)
bool MainWindow::saveLastOpens()
{
QString filename = includeTrailingPathDelimiter(pSettings->dirs().config()) + DEV_LASTOPENS_FILE;
QFile file(filename);
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
QMessageBox::critical(this,
tr("Save last open info error"),
tr("Can't open last open information file '%1' for write!")
.arg(filename),
QMessageBox::Ok);
return true;
}
QJsonObject rootObj;
if (mProject) {
rootObj["lastProject"]=mProject->filename();
@ -3071,6 +3061,16 @@ bool MainWindow::saveLastOpens()
QJsonDocument doc;
doc.setObject(rootObj);
QByteArray json = doc.toJson();
QFile file(filename);
if (!file.open(QFile::WriteOnly | QFile::Truncate)) {
QMessageBox::critical(this,
tr("Save last open info error"),
tr("Can't open last open information file '%1' for write!")
.arg(filename),
QMessageBox::Ok);
return true;
}
if (file.write(doc.toJson())!=json.count()) {
QMessageBox::critical(this,
tr("Save last open info error"),