ENH: Added SYMBOLIC source file property to mark custom command outputs that are never actually created on disk. This is used by the Watcom WMake generator to generate the .SYMBOLIC mark on the files in the make system.

This commit is contained in:
Brad King 2006-10-02 10:20:53 -04:00
parent bb01a0d6ba
commit e4ec89d036
7 changed files with 51 additions and 4 deletions

View File

@ -112,7 +112,10 @@ public:
"Use of VERBATIM is recommended as it enables correct behavior. "
"When VERBATIM is not given the behavior is platform specific. "
"In the future VERBATIM may be enabled by default. The only reason "
"it is an option is to preserve compatibility with older CMake code.";
"it is an option is to preserve compatibility with older CMake code.\n"
"If the output of the custom command is not actually "
"created as a file on disk it should be marked as SYMBOLIC with "
"SET_SOURCE_FILES_PROPERTIES.";
}
cmTypeMacro(cmAddCustomCommandCommand, cmCommand);

View File

@ -31,6 +31,9 @@ int cmGlobalGenerator::s_TryCompileTimeout = 0;
cmGlobalGenerator::cmGlobalGenerator()
{
// By default the .SYMBOLIC dependency is not needed on symbolic rules.
this->NeedSymbolicMark = false;
// by default use the native paths
this->ForceUnixPaths = false;

View File

@ -156,6 +156,10 @@ public:
/** Get whether the generator should use a script for link commands. */
bool GetUseLinkScript() { return this->UseLinkScript; }
/** Get whether the generator should produce special marks on rules
producing symbolic (non-file) outputs. */
bool GetNeedSymbolicMark() { return this->NeedSymbolicMark; }
/*
* Determine what program to use for building the project.
*/
@ -210,6 +214,7 @@ protected:
const cmCustomCommandLines* commandLines,
std::vector<std::string> depends, bool depends_on_all = false);
bool NeedSymbolicMark;
bool UseLinkScript;
bool ForceUnixPaths;
bool ToolSupportsColor;

View File

@ -23,6 +23,7 @@ cmGlobalWatcomWMakeGenerator::cmGlobalWatcomWMakeGenerator()
this->FindMakeProgramFile = "CMakeFindWMake.cmake";
this->ForceUnixPaths = false;
this->ToolSupportsColor = true;
this->NeedSymbolicMark = true;
this->EmptyCommandsHack = "@cd .";
}

View File

@ -846,6 +846,17 @@ void cmMakefile::AddUtilityCommand(const char* utilityName, bool all,
escapeOldStyle);
target.GetSourceLists().push_back(force);
// The output is not actually created so mark it symbolic.
if(cmSourceFile* sf = this->GetSource(force.c_str()))
{
sf->SetProperty("SYMBOLIC", "1");
}
else
{
cmSystemTools::Error("Could not get source file entry for ",
force.c_str());
}
// Add the target to the set of targets.
cmTargets::iterator it =
this->Targets.insert(cmTargets::value_type(utilityName,target)).first;

View File

@ -862,12 +862,25 @@ void cmMakefileTargetGenerator
std::vector<std::string> depends;
this->LocalGenerator->AppendCustomDepend(depends, cc);
// Check whether we need to bother checking for a symbolic output.
bool need_symbolic = this->GlobalGenerator->GetNeedSymbolicMark();
// Write the rule.
const std::vector<std::string>& outputs = cc.GetOutputs();
std::vector<std::string>::const_iterator o = outputs.begin();
{
bool symbolic = false;
if(need_symbolic)
{
if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
o->c_str(), depends, commands,
false);
symbolic);
}
// If the rule has multiple outputs, add a rule for the extra
// outputs to just depend on the first output with no command. Also
@ -887,9 +900,17 @@ void cmMakefileTargetGenerator
}
for(++o; o != outputs.end(); ++o)
{
bool symbolic = false;
if(need_symbolic)
{
if(cmSourceFile* sf = this->Makefile->GetSource(o->c_str()))
{
symbolic = sf->GetPropertyAsBool("SYMBOLIC");
}
}
this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, 0,
o->c_str(), depends, commands,
false);
symbolic);
gg->AddMultipleOutputPair(o->c_str(), depends[0].c_str());
}
}

View File

@ -74,7 +74,10 @@ public:
"only used by Makefiles). "
"OBJECT_DEPENDS (string) adds dependencies to the object file. "
"COMPILE_FLAGS (string) is passed to the compiler as additional "
"command line arguments when the source file is compiled. ";
"command line arguments when the source file is compiled. "
"If SYMBOLIC (boolean) is set to true the build system will be "
"informed that the source file is not actually created on disk but "
"instead used as a symbolic name for a build rule.";
}