From e232ce77c9644a46eeddb60ca03d3fd4f762a0b6 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 21 Dec 2022 09:15:39 +0800 Subject: [PATCH] - enhancement: Auto add "lib" to the output of static/dynamic library projects, if project name don't start with "lib". --- NEWS.md | 1 + RedPandaIDE/compiler/projectcompiler.cpp | 20 ++++++++++++++------ RedPandaIDE/project.cpp | 4 ++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/NEWS.md b/NEWS.md index 86b5ef58..909a0b08 100644 --- a/NEWS.md +++ b/NEWS.md @@ -22,6 +22,7 @@ Red Panda C++ Version 2.7 - enhancement: "Icon zoom" in options / environment / appearance - enhancement: "Line Spacing" 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 diff --git a/RedPandaIDE/compiler/projectcompiler.cpp b/RedPandaIDE/compiler/projectcompiler.cpp index 85e22e67..b2dee0c2 100644 --- a/RedPandaIDE/compiler/projectcompiler.cpp +++ b/RedPandaIDE/compiler/projectcompiler.cpp @@ -68,8 +68,9 @@ void ProjectCompiler::createStaticMakeFile() newMakeFile(file); writeln(file,"$(BIN): $(LINKOBJ)"); if (!mOnlyCheckSyntax) { - writeln(file,"\tar r $(BIN) $(LINKOBJ)"); - writeln(file,"\tranlib $(BIN)"); + writeln(file,"\tar r $(BIN) $(LINKOBJ)"); + writeln(file,"\tranlib $(BIN)"); + writeln(file); } writeMakeObjFilesRules(file); } @@ -81,10 +82,11 @@ void ProjectCompiler::createDynamicMakeFile() writeln(file,"$(BIN): $(LINKOBJ)"); if (!mOnlyCheckSyntax) { 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 { - 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); } @@ -261,8 +263,14 @@ void ProjectCompiler::writeMakeDefines(QFile &file) // This needs to be put in before the clean command. if (mProject->options().type == ProjectType::DynamicLib) { - QString OutputFileDir = extractFilePath(mProject->executable()); - QString libOutputFile = includeTrailingPathDelimiter(OutputFileDir) + "lib" + extractFileName(mProject->executable()); + QString outputFileDir = extractFilePath(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() == mProject->directory()) libOutputFile = extractFileName(libOutputFile); diff --git a/RedPandaIDE/project.cpp b/RedPandaIDE/project.cpp index a74fad00..ca6bdfc1 100644 --- a/RedPandaIDE/project.cpp +++ b/RedPandaIDE/project.cpp @@ -129,9 +129,13 @@ QString Project::executable() const switch(mOptions.type) { case ProjectType::StaticLib: exeFileName = changeFileExt(extractFileName(mFilename),STATIC_LIB_EXT); + if (!exeFileName.startsWith("lib")) + exeFileName = "lib" + exeFileName; break; case ProjectType::DynamicLib: exeFileName = changeFileExt(extractFileName(mFilename),DYNAMIC_LIB_EXT); + if (!exeFileName.startsWith("lib")) + exeFileName = "lib" + exeFileName; break; default: exeFileName = changeFileExt(extractFileName(mFilename),DEFAULT_EXECUTABLE_SUFFIX);