mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-20 10:54:14 +01:00
doing "TODO: Only write file if modified"
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@2098 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
a9ba6464d1
commit
f5f3b7d8e6
@ -160,36 +160,33 @@ bool UAVObjectGenerator::processAll()
|
||||
return false;
|
||||
}
|
||||
// Write the flight code
|
||||
// TODO: Only write file if modified
|
||||
res = writeFile( flightCodePath.absolutePath() + "/" + namelc + ".c", flightCode );
|
||||
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/" + namelc + ".c", flightCode );
|
||||
if (!res)
|
||||
{
|
||||
sout << "Error: Could not write output files" << endl;
|
||||
return false;
|
||||
}
|
||||
res = writeFile( flightCodePath.absolutePath() + "/inc/" + namelc + ".h", flightInclude );
|
||||
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/inc/" + namelc + ".h", flightInclude );
|
||||
if (!res)
|
||||
{
|
||||
sout << "Error: Could not write output files" << endl;
|
||||
return false;
|
||||
}
|
||||
// Write the GCS code
|
||||
// TODO: Only write file if modified
|
||||
res = writeFile( gcsCodePath.absolutePath() + "/" + namelc + ".cpp", gcsCode );
|
||||
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + namelc + ".cpp", gcsCode );
|
||||
if (!res)
|
||||
{
|
||||
sout << "Error: Could not write output files" << endl;
|
||||
return false;
|
||||
}
|
||||
res = writeFile( gcsCodePath.absolutePath() + "/" + namelc + ".h", gcsInclude );
|
||||
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + namelc + ".h", gcsInclude );
|
||||
if (!res)
|
||||
{
|
||||
sout << "Error: Could not write output files" << endl;
|
||||
return false;
|
||||
}
|
||||
// Write the Python code
|
||||
// TODO: Only write file if modified
|
||||
res = writeFile( pythonCodePath.absolutePath() + "/" + namelc + ".py", pythonCode );
|
||||
res = writeFileIfDiffrent( pythonCodePath.absolutePath() + "/" + namelc + ".py", pythonCode );
|
||||
if (!res)
|
||||
{
|
||||
sout << "Error: Could not write output files" << endl;
|
||||
@ -208,7 +205,7 @@ bool UAVObjectGenerator::processAll()
|
||||
sout << "Updating object initialization files" << endl;
|
||||
flightInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||
flightInitTemplate.replace( QString("$(OBJINIT)"), flightObjInit);
|
||||
res = writeFile( flightCodePath.absolutePath() + "/" + objectsInitFilename + ".c",
|
||||
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/" + objectsInitFilename + ".c",
|
||||
flightInitTemplate );
|
||||
if (!res)
|
||||
{
|
||||
@ -219,7 +216,7 @@ bool UAVObjectGenerator::processAll()
|
||||
// Write the gcs object inialization files
|
||||
gcsInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||
gcsInitTemplate.replace( QString("$(OBJINIT)"), gcsObjInit);
|
||||
res = writeFile( gcsCodePath.absolutePath() + "/" + objectsInitFilename + ".cpp",
|
||||
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + objectsInitFilename + ".cpp",
|
||||
gcsInitTemplate );
|
||||
if (!res)
|
||||
{
|
||||
@ -264,3 +261,13 @@ bool UAVObjectGenerator::writeFile(QString name, QString& str)
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Write contents of string to file if the content changes
|
||||
*/
|
||||
bool UAVObjectGenerator::writeFileIfDiffrent(QString name, QString& str)
|
||||
{
|
||||
if (readFile(name)==str) return true;
|
||||
return writeFile(name,str);
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,7 @@ private:
|
||||
|
||||
QString readFile(QString name);
|
||||
bool writeFile(QString name, QString& str);
|
||||
bool writeFileIfDiffrent(QString name, QString& str);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user