VS: Prevent generated "rule" files from causing rebuilds
When we generate a ".rule" file to attach a custom command in a VS IDE project, set the file timestamp to be old enough to prevent the rule from re-running due to its timestamp.
This commit is contained in:
parent
6c6a8c5d5a
commit
fa5284f07f
|
@ -9,6 +9,7 @@
|
||||||
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
See the License for more information.
|
See the License for more information.
|
||||||
============================================================================*/
|
============================================================================*/
|
||||||
|
#include "windows.h"
|
||||||
#include "cmVisualStudio10TargetGenerator.h"
|
#include "cmVisualStudio10TargetGenerator.h"
|
||||||
#include "cmGlobalVisualStudio10Generator.h"
|
#include "cmGlobalVisualStudio10Generator.h"
|
||||||
#include "cmGeneratorTarget.h"
|
#include "cmGeneratorTarget.h"
|
||||||
|
@ -871,6 +872,9 @@ cmVisualStudio10TargetGenerator::WriteCustomRule(cmSourceFile const* source,
|
||||||
fout << "# generated from CMake\n";
|
fout << "# generated from CMake\n";
|
||||||
fout.flush();
|
fout.flush();
|
||||||
fout.close();
|
fout.close();
|
||||||
|
// Force given file to have a very old timestamp, thus
|
||||||
|
// preventing dependent rebuilds.
|
||||||
|
this->ForceOld(sourcePath);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -3458,3 +3462,26 @@ cmVisualStudio10TargetGenerator
|
||||||
this->WriteString("<None Include=\"", 2);
|
this->WriteString("<None Include=\"", 2);
|
||||||
(*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n";
|
(*this->BuildFileStream) << cmVS10EscapeXML(keyFile) << "\" />\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool cmVisualStudio10TargetGenerator::ForceOld(const std::string& source) const
|
||||||
|
{
|
||||||
|
HANDLE h = CreateFileW(
|
||||||
|
cmSystemTools::ConvertToWindowsExtendedPath(source).c_str(),
|
||||||
|
FILE_WRITE_ATTRIBUTES,
|
||||||
|
FILE_SHARE_WRITE, 0, OPEN_EXISTING,
|
||||||
|
FILE_FLAG_BACKUP_SEMANTICS, 0);
|
||||||
|
if (!h)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FILETIME const ftime_20010101 = { 3365781504, 29389701 };
|
||||||
|
if (!SetFileTime(h, &ftime_20010101, &ftime_20010101, &ftime_20010101))
|
||||||
|
{
|
||||||
|
CloseHandle(h);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(h);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
|
@ -130,6 +130,8 @@ private:
|
||||||
cmIDEFlagTable const* GetLinkFlagTable() const;
|
cmIDEFlagTable const* GetLinkFlagTable() const;
|
||||||
cmIDEFlagTable const* GetMasmFlagTable() const;
|
cmIDEFlagTable const* GetMasmFlagTable() const;
|
||||||
|
|
||||||
|
bool ForceOld(const std::string& source) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef cmVisualStudioGeneratorOptions Options;
|
typedef cmVisualStudioGeneratorOptions Options;
|
||||||
typedef std::map<std::string, Options*> OptionsMap;
|
typedef std::map<std::string, Options*> OptionsMap;
|
||||||
|
|
Loading…
Reference in New Issue