mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-02-21 11:54:15 +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;
|
return false;
|
||||||
}
|
}
|
||||||
// Write the flight code
|
// Write the flight code
|
||||||
// TODO: Only write file if modified
|
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/" + namelc + ".c", flightCode );
|
||||||
res = writeFile( flightCodePath.absolutePath() + "/" + namelc + ".c", flightCode );
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
sout << "Error: Could not write output files" << endl;
|
sout << "Error: Could not write output files" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
res = writeFile( flightCodePath.absolutePath() + "/inc/" + namelc + ".h", flightInclude );
|
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/inc/" + namelc + ".h", flightInclude );
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
sout << "Error: Could not write output files" << endl;
|
sout << "Error: Could not write output files" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Write the GCS code
|
// Write the GCS code
|
||||||
// TODO: Only write file if modified
|
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + namelc + ".cpp", gcsCode );
|
||||||
res = writeFile( gcsCodePath.absolutePath() + "/" + namelc + ".cpp", gcsCode );
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
sout << "Error: Could not write output files" << endl;
|
sout << "Error: Could not write output files" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
res = writeFile( gcsCodePath.absolutePath() + "/" + namelc + ".h", gcsInclude );
|
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + namelc + ".h", gcsInclude );
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
sout << "Error: Could not write output files" << endl;
|
sout << "Error: Could not write output files" << endl;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Write the Python code
|
// Write the Python code
|
||||||
// TODO: Only write file if modified
|
res = writeFileIfDiffrent( pythonCodePath.absolutePath() + "/" + namelc + ".py", pythonCode );
|
||||||
res = writeFile( pythonCodePath.absolutePath() + "/" + namelc + ".py", pythonCode );
|
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
sout << "Error: Could not write output files" << endl;
|
sout << "Error: Could not write output files" << endl;
|
||||||
@ -208,7 +205,7 @@ bool UAVObjectGenerator::processAll()
|
|||||||
sout << "Updating object initialization files" << endl;
|
sout << "Updating object initialization files" << endl;
|
||||||
flightInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
flightInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||||
flightInitTemplate.replace( QString("$(OBJINIT)"), flightObjInit);
|
flightInitTemplate.replace( QString("$(OBJINIT)"), flightObjInit);
|
||||||
res = writeFile( flightCodePath.absolutePath() + "/" + objectsInitFilename + ".c",
|
res = writeFileIfDiffrent( flightCodePath.absolutePath() + "/" + objectsInitFilename + ".c",
|
||||||
flightInitTemplate );
|
flightInitTemplate );
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
@ -219,7 +216,7 @@ bool UAVObjectGenerator::processAll()
|
|||||||
// Write the gcs object inialization files
|
// Write the gcs object inialization files
|
||||||
gcsInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
gcsInitTemplate.replace( QString("$(OBJINC)"), objInc);
|
||||||
gcsInitTemplate.replace( QString("$(OBJINIT)"), gcsObjInit);
|
gcsInitTemplate.replace( QString("$(OBJINIT)"), gcsObjInit);
|
||||||
res = writeFile( gcsCodePath.absolutePath() + "/" + objectsInitFilename + ".cpp",
|
res = writeFileIfDiffrent( gcsCodePath.absolutePath() + "/" + objectsInitFilename + ".cpp",
|
||||||
gcsInitTemplate );
|
gcsInitTemplate );
|
||||||
if (!res)
|
if (!res)
|
||||||
{
|
{
|
||||||
@ -264,3 +261,13 @@ bool UAVObjectGenerator::writeFile(QString name, QString& str)
|
|||||||
return true;
|
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);
|
QString readFile(QString name);
|
||||||
bool writeFile(QString name, QString& str);
|
bool writeFile(QString name, QString& str);
|
||||||
|
bool writeFileIfDiffrent(QString name, QString& str);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user