- enhancement: Open ".def" (Module definition file) file in editor when double click it in the project view.
- enhancement: When a dll project has .def file, use it when generating the dll file.
This commit is contained in:
parent
f88898ae1e
commit
c941ae4cf8
2
NEWS.md
2
NEWS.md
|
@ -96,6 +96,8 @@ Red Panda C++ Version 2.27
|
||||||
- fix: An undefined macro is still missing the the parse result after #undef is removed.
|
- fix: An undefined macro is still missing the the parse result after #undef is removed.
|
||||||
- fix: If a class method is overloaded, only one of them is inherited by it's children.
|
- fix: If a class method is overloaded, only one of them is inherited by it's children.
|
||||||
- enhancement: Adjust function tip pos to prevent it from run outside the right window edge.
|
- enhancement: Adjust function tip pos to prevent it from run outside the right window edge.
|
||||||
|
- enhancement: Open ".def" (Module definition file) file in editor when double click it in the project view.
|
||||||
|
- enhancement: When a dll project has .def file, use it when generating the dll file.
|
||||||
|
|
||||||
Red Panda C++ Version 2.26
|
Red Panda C++ Version 2.26
|
||||||
- enhancement: Code suggestion for embedded std::vectors.
|
- enhancement: Code suggestion for embedded std::vectors.
|
||||||
|
|
|
@ -54,7 +54,8 @@ void ProjectCompiler::buildMakeFile()
|
||||||
void ProjectCompiler::createStandardMakeFile()
|
void ProjectCompiler::createStandardMakeFile()
|
||||||
{
|
{
|
||||||
QFile file(mProject->makeFileName());
|
QFile file(mProject->makeFileName());
|
||||||
newMakeFile(file);
|
bool genModuleDef;
|
||||||
|
newMakeFile(file, genModuleDef);
|
||||||
QString executable = extractRelativePath(mProject->makeFileName(), mProject->executable());
|
QString executable = extractRelativePath(mProject->makeFileName(), mProject->executable());
|
||||||
QString exeTarget = escapeFilenameForMakefileTarget(executable);
|
QString exeTarget = escapeFilenameForMakefileTarget(executable);
|
||||||
QString exeCommand = escapeArgumentForMakefileRecipe(executable, false);
|
QString exeCommand = escapeArgumentForMakefileRecipe(executable, false);
|
||||||
|
@ -84,20 +85,35 @@ void ProjectCompiler::createStaticMakeFile()
|
||||||
void ProjectCompiler::createDynamicMakeFile()
|
void ProjectCompiler::createDynamicMakeFile()
|
||||||
{
|
{
|
||||||
QFile file(mProject->makeFileName());
|
QFile file(mProject->makeFileName());
|
||||||
newMakeFile(file);
|
bool genModuleDef;
|
||||||
|
newMakeFile(file, genModuleDef);
|
||||||
QString executable = extractRelativePath(mProject->makeFileName(), mProject->executable());
|
QString executable = extractRelativePath(mProject->makeFileName(), mProject->executable());
|
||||||
QString exeTarget = escapeFilenameForMakefileTarget(executable);
|
QString exeTarget = escapeFilenameForMakefileTarget(executable);
|
||||||
QString exeCommand = escapeArgumentForMakefileRecipe(executable, false);
|
QString exeCommand = escapeArgumentForMakefileRecipe(executable, false);
|
||||||
writeln(file, exeTarget + ": $(OBJ)");
|
writeln(file, exeTarget + ": $(DEF) $(OBJ)");
|
||||||
if (mProject->options().isCpp) {
|
if (genModuleDef) {
|
||||||
writeln(file, "\t$(CXX) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
|
if (mProject->options().isCpp) {
|
||||||
|
writeln(file, "\t$(CXX) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) $(DEF) -Wl,--output-def,$(OUTPUT_DEF),--out-implib,$(STATIC)");
|
||||||
|
} else {
|
||||||
|
writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) $(DEF) -Wl,--output-def,$(OUTPUT_DEF),--out-implib,$(STATIC)");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) -Wl,--output-def,$(DEF),--out-implib,$(STATIC)");
|
if (mProject->options().isCpp) {
|
||||||
|
writeln(file, "\t$(CXX) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) $(DEF) -Wl,--out-implib,$(STATIC)");
|
||||||
|
} else {
|
||||||
|
writeln(file, "\t$(CC) -mdll $(LINKOBJ) -o " + exeCommand + " $(LIBS) $(DEF) -Wl,--out-implib,$(STATIC)");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
writeMakeObjFilesRules(file);
|
writeMakeObjFilesRules(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectCompiler::newMakeFile(QFile& file)
|
void ProjectCompiler::newMakeFile(QFile &file)
|
||||||
|
{
|
||||||
|
bool dummy;
|
||||||
|
newMakeFile(file, dummy);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectCompiler::newMakeFile(QFile& file, bool &genModuleDef)
|
||||||
{
|
{
|
||||||
// Create OBJ output directory
|
// Create OBJ output directory
|
||||||
if (!mProject->options().objectOutput.isEmpty()) {
|
if (!mProject->options().objectOutput.isEmpty()) {
|
||||||
|
@ -120,7 +136,7 @@ void ProjectCompiler::newMakeFile(QFile& file)
|
||||||
writeMakeHeader(file);
|
writeMakeHeader(file);
|
||||||
|
|
||||||
// Writes definition list
|
// Writes definition list
|
||||||
writeMakeDefines(file);
|
writeMakeDefines(file, genModuleDef);
|
||||||
|
|
||||||
// Write PHONY and all targets
|
// Write PHONY and all targets
|
||||||
writeMakeTarget(file);
|
writeMakeTarget(file);
|
||||||
|
@ -152,24 +168,25 @@ void ProjectCompiler::writeMakeHeader(QFile &file)
|
||||||
writeln(file);
|
writeln(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectCompiler::writeMakeDefines(QFile &file)
|
void ProjectCompiler::writeMakeDefines(QFile &file, bool &genModuleDef)
|
||||||
{
|
{
|
||||||
// Get list of object files
|
// Get list of object files
|
||||||
QStringList Objects;
|
QStringList Objects;
|
||||||
QStringList LinkObjects;
|
QStringList LinkObjects;
|
||||||
QStringList cleanObjects;
|
QStringList cleanObjects;
|
||||||
|
QStringList moduleDefines;
|
||||||
|
|
||||||
|
genModuleDef = false;
|
||||||
|
|
||||||
// Create a list of object files
|
// Create a list of object files
|
||||||
foreach(const PProjectUnit &unit, mProject->unitList()) {
|
foreach(const PProjectUnit &unit, mProject->unitList()) {
|
||||||
if (!unit->compile() && !unit->link())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// Only process source files
|
// Only process source files
|
||||||
QString RelativeName = extractRelativePath(mProject->directory(), unit->fileName());
|
FileType fileType = getFileType(unit->fileName());
|
||||||
FileType fileType = getFileType(RelativeName);
|
|
||||||
|
|
||||||
if (fileType == FileType::CSource || fileType == FileType::CppSource
|
if (fileType == FileType::CSource || fileType == FileType::CppSource
|
||||||
|| fileType==FileType::GAS) {
|
|| fileType==FileType::GAS) {
|
||||||
|
QString relativeName = extractRelativePath(mProject->directory(), unit->fileName());
|
||||||
if (!mProject->options().objectOutput.isEmpty()) {
|
if (!mProject->options().objectOutput.isEmpty()) {
|
||||||
// ofile = C:\MyProgram\obj\main.o
|
// ofile = C:\MyProgram\obj\main.o
|
||||||
QString fullObjFile = includeTrailingPathDelimiter(mProject->options().objectOutput)
|
QString fullObjFile = includeTrailingPathDelimiter(mProject->options().objectOutput)
|
||||||
|
@ -181,14 +198,15 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
||||||
LinkObjects << relativeObjFile;
|
LinkObjects << relativeObjFile;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Objects << changeFileExt(RelativeName, OBJ_EXT);
|
Objects << changeFileExt(relativeName, OBJ_EXT);
|
||||||
cleanObjects << localizePath(changeFileExt(RelativeName, OBJ_EXT));
|
cleanObjects << localizePath(changeFileExt(relativeName, OBJ_EXT));
|
||||||
if (unit->link())
|
if (unit->link())
|
||||||
LinkObjects << changeFileExt(RelativeName, OBJ_EXT);
|
LinkObjects << changeFileExt(relativeName, OBJ_EXT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (fileType == FileType::ModuleDef)
|
||||||
|
moduleDefines.append(extractRelativePath(mProject->makeFileName(), unit->fileName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get windres file
|
// Get windres file
|
||||||
QString objResFile;
|
QString objResFile;
|
||||||
QString cleanRes;
|
QString cleanRes;
|
||||||
|
@ -299,9 +317,12 @@ void ProjectCompiler::writeMakeDefines(QFile &file)
|
||||||
|
|
||||||
QString defFile = localizePath(changeFileExt(libOutputFile, DEF_EXT));
|
QString defFile = localizePath(changeFileExt(libOutputFile, DEF_EXT));
|
||||||
QString staticFile = localizePath(changeFileExt(libOutputFile, LIB_EXT));
|
QString staticFile = localizePath(changeFileExt(libOutputFile, LIB_EXT));
|
||||||
|
writeln(file,"DEF = " + escapeFilenamesForMakefilePrerequisite(moduleDefines));
|
||||||
|
writeln(file,"STATIC = " + escapeFilenameForMakefilePrerequisite(staticFile));
|
||||||
|
|
||||||
writeln(file,"DEF = " + escapeArgumentForMakefileVariableValue(defFile, false));
|
genModuleDef = !moduleDefines.contains(defFile);
|
||||||
writeln(file,"STATIC = " + escapeArgumentForMakefileVariableValue(staticFile, false));
|
if (genModuleDef)
|
||||||
|
writeln(file,"OUTPUT_DEF = " + escapeFilenameForMakefilePrerequisite(defFile));
|
||||||
}
|
}
|
||||||
writeln(file);
|
writeln(file);
|
||||||
}
|
}
|
||||||
|
@ -336,7 +357,7 @@ void ProjectCompiler::writeMakeClean(QFile &file)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mProject->options().type == ProjectType::DynamicLib) {
|
if (mProject->options().type == ProjectType::DynamicLib) {
|
||||||
target +=" $(DEF) $(STATIC)";
|
target +=" $(STATIC)";
|
||||||
}
|
}
|
||||||
writeln(file, QString("\t-$(RM) %1 > %2 2>&1").arg(target,NULL_FILE));
|
writeln(file, QString("\t-$(RM) %1 > %2 2>&1").arg(target,NULL_FILE));
|
||||||
writeln(file);
|
writeln(file);
|
||||||
|
|
|
@ -39,8 +39,9 @@ private:
|
||||||
void createStaticMakeFile();
|
void createStaticMakeFile();
|
||||||
void createDynamicMakeFile();
|
void createDynamicMakeFile();
|
||||||
void newMakeFile(QFile& file);
|
void newMakeFile(QFile& file);
|
||||||
|
void newMakeFile(QFile& file, bool &genModuleDef);
|
||||||
void writeMakeHeader(QFile& file);
|
void writeMakeHeader(QFile& file);
|
||||||
void writeMakeDefines(QFile& file);
|
void writeMakeDefines(QFile& file, bool &genModuleDef);
|
||||||
void writeMakeTarget(QFile& file);
|
void writeMakeTarget(QFile& file);
|
||||||
void writeMakeIncludes(QFile& file);
|
void writeMakeIncludes(QFile& file);
|
||||||
void writeMakeClean(QFile& file);
|
void writeMakeClean(QFile& file);
|
||||||
|
|
|
@ -4392,17 +4392,16 @@ void CppParser::inheritClassStatement(const PStatement& derived, bool isStruct,
|
||||||
|| statement->kind == StatementKind::skDestructor)
|
|| statement->kind == StatementKind::skDestructor)
|
||||||
continue;
|
continue;
|
||||||
if (derived->children.contains(statement->command)) {
|
if (derived->children.contains(statement->command)) {
|
||||||
// test if all children with the same name are not inherited.
|
// Check if it's overwritten(hidden) by the derived
|
||||||
// If so, it's overwrited and shouldn't inherit.
|
|
||||||
QList<PStatement> children = derived->children.values(statement->command);
|
QList<PStatement> children = derived->children.values(statement->command);
|
||||||
bool hasInherited = false;
|
bool overwritten = false;
|
||||||
foreach(const PStatement& child, children) {
|
foreach(const PStatement& child, children) {
|
||||||
if (child->isInherited()) {
|
if (!child->isInherited() && child->noNameArgs == statement->noNameArgs) {
|
||||||
hasInherited = true;
|
overwritten = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!hasInherited)
|
if (overwritten)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
StatementAccessibility m_acc;
|
StatementAccessibility m_acc;
|
||||||
|
|
|
@ -105,6 +105,9 @@ FileType getFileType(const QString &filename)
|
||||||
if (filename.endsWith(".vs",PATH_SENSITIVITY)) {
|
if (filename.endsWith(".vs",PATH_SENSITIVITY)) {
|
||||||
return FileType::VerticeShader;
|
return FileType::VerticeShader;
|
||||||
}
|
}
|
||||||
|
if (filename.endsWith(".def",PATH_SENSITIVITY)) {
|
||||||
|
return FileType::ModuleDef;
|
||||||
|
}
|
||||||
QFileInfo info(filename);
|
QFileInfo info(filename);
|
||||||
if (info.suffix().isEmpty()) {
|
if (info.suffix().isEmpty()) {
|
||||||
return FileType::Other;
|
return FileType::Other;
|
||||||
|
|
|
@ -49,6 +49,7 @@ enum class FileType{
|
||||||
Text, // text file
|
Text, // text file
|
||||||
FragmentShader,
|
FragmentShader,
|
||||||
VerticeShader,
|
VerticeShader,
|
||||||
|
ModuleDef, // Windows Module Definition
|
||||||
Other // any others
|
Other // any others
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue