- enhancement: Auto add "lib" to the output of static/dynamic library projects, if project name don't start with "lib".

This commit is contained in:
Roy Qu 2022-12-21 09:15:39 +08:00
parent 892b987894
commit e232ce77c9
3 changed files with 19 additions and 6 deletions

View File

@ -22,6 +22,7 @@ Red Panda C++ Version 2.7
- enhancement: "Icon zoom" in options / environment / appearance - enhancement: "Icon zoom" in options / environment / appearance
- enhancement: "Line Spacing" in options / editor / font - enhancement: "Line Spacing" in options / editor / font
- enhancement: "Show whitespaces" in options / editor / font - enhancement: "Show whitespaces" in options / editor / font
- enhancement: Auto add "lib" to the output of static/dynamic library projects, if project name don't start with "lib".
Red Panda C++ Version 2.6 Red Panda C++ Version 2.6

View File

@ -70,6 +70,7 @@ void ProjectCompiler::createStaticMakeFile()
if (!mOnlyCheckSyntax) { if (!mOnlyCheckSyntax) {
writeln(file,"\tar r $(BIN) $(LINKOBJ)"); writeln(file,"\tar r $(BIN) $(LINKOBJ)");
writeln(file,"\tranlib $(BIN)"); writeln(file,"\tranlib $(BIN)");
writeln(file);
} }
writeMakeObjFilesRules(file); writeMakeObjFilesRules(file);
} }
@ -81,10 +82,11 @@ void ProjectCompiler::createDynamicMakeFile()
writeln(file,"$(BIN): $(LINKOBJ)"); writeln(file,"$(BIN): $(LINKOBJ)");
if (!mOnlyCheckSyntax) { if (!mOnlyCheckSyntax) {
if (mProject->options().isCpp) { if (mProject->options().isCpp) {
file.write("\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 { } else {
file.write("\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)");
} }
writeln(file);
} }
writeMakeObjFilesRules(file); writeMakeObjFilesRules(file);
} }
@ -261,8 +263,14 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
// This needs to be put in before the clean command. // This needs to be put in before the clean command.
if (mProject->options().type == ProjectType::DynamicLib) { if (mProject->options().type == ProjectType::DynamicLib) {
QString OutputFileDir = extractFilePath(mProject->executable()); QString outputFileDir = extractFilePath(mProject->executable());
QString libOutputFile = includeTrailingPathDelimiter(OutputFileDir) + "lib" + extractFileName(mProject->executable()); QString outputFilename = extractFileName(mProject->executable());
QString libOutputFile;
if (!outputFilename.startsWith("lib")) {
libOutputFile = includeTrailingPathDelimiter(outputFileDir) + "lib" + outputFilename;
} else {
libOutputFile = includeTrailingPathDelimiter(outputFileDir) + outputFilename;
}
if (QFileInfo(libOutputFile).absoluteFilePath() if (QFileInfo(libOutputFile).absoluteFilePath()
== mProject->directory()) == mProject->directory())
libOutputFile = extractFileName(libOutputFile); libOutputFile = extractFileName(libOutputFile);

View File

@ -129,9 +129,13 @@ QString Project::executable() const
switch(mOptions.type) { switch(mOptions.type) {
case ProjectType::StaticLib: case ProjectType::StaticLib:
exeFileName = changeFileExt(extractFileName(mFilename),STATIC_LIB_EXT); exeFileName = changeFileExt(extractFileName(mFilename),STATIC_LIB_EXT);
if (!exeFileName.startsWith("lib"))
exeFileName = "lib" + exeFileName;
break; break;
case ProjectType::DynamicLib: case ProjectType::DynamicLib:
exeFileName = changeFileExt(extractFileName(mFilename),DYNAMIC_LIB_EXT); exeFileName = changeFileExt(extractFileName(mFilename),DYNAMIC_LIB_EXT);
if (!exeFileName.startsWith("lib"))
exeFileName = "lib" + exeFileName;
break; break;
default: default:
exeFileName = changeFileExt(extractFileName(mFilename),DEFAULT_EXECUTABLE_SUFFIX); exeFileName = changeFileExt(extractFileName(mFilename),DEFAULT_EXECUTABLE_SUFFIX);