ENH: some more cleanup and changes to how custom commands are stored
This commit is contained in:
parent
ef6c5ae23e
commit
baeeb40823
|
@ -102,7 +102,6 @@ void cmGlobalUnixMakefileGenerator3::Generate()
|
||||||
|
|
||||||
// now write the support Makefiles
|
// now write the support Makefiles
|
||||||
//this->WriteBuildMakefile();
|
//this->WriteBuildMakefile();
|
||||||
this->WriteCleanMakefile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile()
|
void cmGlobalUnixMakefileGenerator3::WriteMainMakefile()
|
||||||
|
@ -382,46 +381,6 @@ void cmGlobalUnixMakefileGenerator3::WriteBuildMakefile()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalUnixMakefileGenerator3::WriteCleanMakefile()
|
|
||||||
{
|
|
||||||
unsigned int i;
|
|
||||||
|
|
||||||
// Open the output file. This should not be copy-if-different
|
|
||||||
// because the check-build-system step compares the makefile time to
|
|
||||||
// see if the build system must be regenerated.
|
|
||||||
std::string makefileName = this->GetCMakeInstance()->GetHomeOutputDirectory();
|
|
||||||
makefileName += "/clean.make";
|
|
||||||
cmGeneratedFileStream makefileStream(makefileName.c_str());
|
|
||||||
if(!makefileStream)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// get a local generator for some useful methods
|
|
||||||
cmLocalUnixMakefileGenerator3 *lg =
|
|
||||||
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[0]);
|
|
||||||
|
|
||||||
// Write the do not edit header.
|
|
||||||
lg->WriteDisclaimer(makefileStream);
|
|
||||||
lg->WriteMakeVariables(makefileStream);
|
|
||||||
|
|
||||||
// add the generic dependency
|
|
||||||
std::vector<std::string> depends;
|
|
||||||
std::vector<std::string> no_commands;
|
|
||||||
lg->WriteMakeRule(makefileStream, 0, "clean", depends, no_commands);
|
|
||||||
|
|
||||||
// include all the target depends
|
|
||||||
for (i = 0; i < m_LocalGenerators.size(); ++i)
|
|
||||||
{
|
|
||||||
cmLocalUnixMakefileGenerator3 *lg2 =
|
|
||||||
static_cast<cmLocalUnixMakefileGenerator3 *>(m_LocalGenerators[i]);
|
|
||||||
lg2->WriteMainTargetIncludes(makefileStream,"clean.make","clean");
|
|
||||||
lg2->WriteMainTargetRules(makefileStream,"clean.make","clean",true);
|
|
||||||
// add the directory based rules
|
|
||||||
lg2->WriteLocalCleanRule(makefileStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmGlobalUnixMakefileGenerator3
|
void cmGlobalUnixMakefileGenerator3
|
||||||
|
@ -451,8 +410,8 @@ void cmGlobalUnixMakefileGenerator3
|
||||||
commands, commands);
|
commands, commands);
|
||||||
|
|
||||||
// write the clean
|
// write the clean
|
||||||
commands.push_back(lg->GetRecursiveMakeCall("clean.make",0));
|
lg->WriteMakeRule(makefileStream, "The main clean target", "clean",
|
||||||
lg->WriteMakeRule(makefileStream, "default clean target", "clean", depends, commands);
|
commands, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -600,6 +559,20 @@ cmGlobalUnixMakefileGenerator3
|
||||||
depends.push_back(localName);
|
depends.push_back(localName);
|
||||||
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
|
lg->WriteMakeRule(ruleFileStream, "Convenience name for target.",
|
||||||
t->second.GetName(), depends, commands);
|
t->second.GetName(), depends, commands);
|
||||||
|
|
||||||
|
// add the clean rule
|
||||||
|
makeTargetName = localName;
|
||||||
|
makeTargetName += "/clean";
|
||||||
|
depends.clear();
|
||||||
|
commands.clear();
|
||||||
|
commands.push_back(lg->GetRecursiveMakeCall(makefileName.c_str(),
|
||||||
|
makeTargetName.c_str()));
|
||||||
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
||||||
|
makeTargetName.c_str(), depends, commands);
|
||||||
|
commands.clear();
|
||||||
|
depends.push_back(makeTargetName);
|
||||||
|
lg->WriteMakeRule(ruleFileStream, "clean rule for target.",
|
||||||
|
"clean", depends, commands);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ protected:
|
||||||
void WriteMainMakefile();
|
void WriteMainMakefile();
|
||||||
void WriteMainCMakefile();
|
void WriteMainCMakefile();
|
||||||
void WriteBuildMakefile();
|
void WriteBuildMakefile();
|
||||||
void WriteCleanMakefile();
|
|
||||||
void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream);
|
void WriteMainCMakefileLanguageRules(cmGeneratedFileStream& cmakefileStream);
|
||||||
void WriteAllRules(cmLocalUnixMakefileGenerator3 *lg,
|
void WriteAllRules(cmLocalUnixMakefileGenerator3 *lg,
|
||||||
std::ostream& makefileStream);
|
std::ostream& makefileStream);
|
||||||
|
|
|
@ -60,11 +60,6 @@ void cmLocalUnixMakefileGenerator3::Generate()
|
||||||
// Setup our configuration variables for this directory.
|
// Setup our configuration variables for this directory.
|
||||||
this->ConfigureOutputPaths();
|
this->ConfigureOutputPaths();
|
||||||
|
|
||||||
// write the custom commands, this must happen before writing the targets,
|
|
||||||
// but... it may be that it needs to happen after the TraveVSDependencies
|
|
||||||
// call
|
|
||||||
this->WriteCustomCommands();
|
|
||||||
|
|
||||||
// Generate the rule files for each target.
|
// Generate the rule files for each target.
|
||||||
cmTargets& targets = m_Makefile->GetTargets();
|
cmTargets& targets = m_Makefile->GetTargets();
|
||||||
std::string empty;
|
std::string empty;
|
||||||
|
@ -141,89 +136,39 @@ void cmLocalUnixMakefileGenerator3::FormatOutputPath(std::string& path,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void cmLocalUnixMakefileGenerator3::WriteCustomCommands()
|
void cmLocalUnixMakefileGenerator3
|
||||||
|
::WriteCustomCommands(const cmTarget &target,std::ostream& ruleFileStream,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
|
std::string tgtDir = m_Makefile->GetStartOutputDirectory();
|
||||||
|
tgtDir += "/";
|
||||||
|
tgtDir += this->GetTargetDirectory(target);
|
||||||
|
|
||||||
|
// add custom commands to the clean rules?
|
||||||
|
const char* clean_no_custom = m_Makefile->GetProperty("CLEAN_NO_CUSTOM");
|
||||||
|
bool clean = cmSystemTools::IsOff(clean_no_custom);
|
||||||
|
|
||||||
// Generate the rule files for each custom command.
|
// Generate the rule files for each custom command.
|
||||||
const std::vector<cmSourceFile*>& sources = m_Makefile->GetSourceFiles();
|
// get the classes from the source lists then add them to the groups
|
||||||
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
const std::vector<cmSourceFile*> &classes = target.GetSourceFiles();
|
||||||
i != sources.end(); ++i)
|
|
||||||
{
|
|
||||||
if(const cmCustomCommand* cc = (*i)->GetCustomCommand())
|
|
||||||
{
|
|
||||||
this->GenerateCustomRuleFile(*cc);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// generate the includes
|
|
||||||
std::string ruleFileName = "CMakeCustomRules.dir/build.make";
|
|
||||||
|
|
||||||
// Open the rule file. This should be copy-if-different because the
|
|
||||||
// rules may depend on this file itself.
|
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
|
||||||
ruleFileStream.SetCopyIfDifferent(true);
|
|
||||||
if(!ruleFileStream)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->WriteDisclaimer(ruleFileStream);
|
|
||||||
|
|
||||||
std::string relPath = this->GetHomeRelativeOutputPath();
|
|
||||||
std::string objTarget;
|
std::string objTarget;
|
||||||
for(std::set<cmStdString>::const_iterator i = m_CustomRuleFiles.begin();
|
for(std::vector<cmSourceFile*>::const_iterator i = classes.begin();
|
||||||
i != m_CustomRuleFiles.end(); ++i)
|
i != classes.end(); i++)
|
||||||
{
|
|
||||||
objTarget = relPath;
|
|
||||||
objTarget += *i;
|
|
||||||
ruleFileStream
|
|
||||||
<< m_IncludeDirective << " "
|
|
||||||
<< this->ConvertToOutputForExisting(objTarget.c_str()).c_str()
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// now do the clean
|
|
||||||
ruleFileName = "CMakeCustomRules.dir/clean.make";
|
|
||||||
|
|
||||||
// Open the rule file. This should be copy-if-different because the
|
|
||||||
// rules may depend on this file itself.
|
|
||||||
ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
|
||||||
cmGeneratedFileStream ruleFileStream2(ruleFileNameFull.c_str());
|
|
||||||
ruleFileStream2.SetCopyIfDifferent(true);
|
|
||||||
if(!ruleFileStream2)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->WriteDisclaimer(ruleFileStream2);
|
|
||||||
|
|
||||||
std::vector<std::string> cleanFiles;
|
|
||||||
for(std::vector<cmSourceFile*>::const_iterator i = sources.begin();
|
|
||||||
i != sources.end(); ++i)
|
|
||||||
{
|
{
|
||||||
if(const cmCustomCommand* cc = (*i)->GetCustomCommand())
|
if(const cmCustomCommand* cc = (*i)->GetCustomCommand())
|
||||||
{
|
{
|
||||||
cleanFiles.push_back(cc->GetOutput());
|
objTarget = this->GenerateCustomRuleFile(*cc,tgtDir.c_str());
|
||||||
|
if (clean)
|
||||||
|
{
|
||||||
|
cleanFiles.push_back
|
||||||
|
(this->Convert(cc->GetOutput(),HOME_OUTPUT,SHELL));
|
||||||
|
}
|
||||||
|
ruleFileStream
|
||||||
|
<< m_IncludeDirective << " "
|
||||||
|
<< this->ConvertToOutputForExisting(objTarget.c_str()).c_str()
|
||||||
|
<< "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cleanFiles.size())
|
|
||||||
{
|
|
||||||
std::vector<std::string> commands;
|
|
||||||
std::vector<std::string> depends;
|
|
||||||
this->AppendCleanCommand(commands, cleanFiles);
|
|
||||||
std::string dir = m_Makefile->GetStartOutputDirectory();
|
|
||||||
dir += "/CMakeCustomRules.dir/clean";
|
|
||||||
//dir = cmSystemTools::RelativePath(m_Makefile->GetHomeOutputDirectory(), dir.c_str());
|
|
||||||
//dir = cmSystemTools::ConvertToOutputPath(dir.c_str());
|
|
||||||
dir = this->Convert(dir.c_str(),HOME_OUTPUT,SHELL,false);
|
|
||||||
this->WriteMakeRule(ruleFileStream2,
|
|
||||||
"Clean the output of this custom command.",
|
|
||||||
dir.c_str(), depends, commands);
|
|
||||||
// do the include
|
|
||||||
commands.clear();
|
|
||||||
depends.push_back(dir);
|
|
||||||
this->WriteMakeRule(ruleFileStream2,
|
|
||||||
"Clean the output of this custom command.",
|
|
||||||
"clean", depends, commands);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -382,18 +327,15 @@ cmLocalUnixMakefileGenerator3
|
||||||
|
|
||||||
this->WriteMakeVariables(ruleFileStream);
|
this->WriteMakeVariables(ruleFileStream);
|
||||||
|
|
||||||
// include the custom commands rules
|
// write the custom commands for this target
|
||||||
if (m_CustomRuleFiles.size())
|
std::vector<std::string> cleanFiles;
|
||||||
|
// Look for files registered for cleaning in this directory.
|
||||||
|
if(const char* additional_clean_files =
|
||||||
|
m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES"))
|
||||||
{
|
{
|
||||||
// do the include
|
cmSystemTools::ExpandListArgument(additional_clean_files, cleanFiles);
|
||||||
std::string dir2 = m_Makefile->GetStartOutputDirectory();
|
}
|
||||||
dir2 += "/CMakeCustomRules.dir/build.make";
|
this->WriteCustomCommands(target,ruleFileStream,cleanFiles);
|
||||||
dir2 = this->Convert(dir2.c_str(),HOME_OUTPUT,MAKEFILE);
|
|
||||||
ruleFileStream
|
|
||||||
<< m_IncludeDirective << " "
|
|
||||||
<< this->ConvertToOutputForExisting(dir2.c_str()).c_str()
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Include the rule file for each object.
|
// Include the rule file for each object.
|
||||||
std::string relPath = this->GetHomeRelativeOutputPath();
|
std::string relPath = this->GetHomeRelativeOutputPath();
|
||||||
|
@ -422,23 +364,33 @@ cmLocalUnixMakefileGenerator3
|
||||||
{
|
{
|
||||||
case cmTarget::STATIC_LIBRARY:
|
case cmTarget::STATIC_LIBRARY:
|
||||||
this->WriteStaticLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
this->WriteStaticLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
||||||
target, objects, external_objects);
|
target, objects, external_objects,
|
||||||
|
cleanFiles);
|
||||||
break;
|
break;
|
||||||
case cmTarget::SHARED_LIBRARY:
|
case cmTarget::SHARED_LIBRARY:
|
||||||
this->WriteSharedLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
this->WriteSharedLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
||||||
target, objects, external_objects);
|
target, objects, external_objects,
|
||||||
|
cleanFiles);
|
||||||
break;
|
break;
|
||||||
case cmTarget::MODULE_LIBRARY:
|
case cmTarget::MODULE_LIBRARY:
|
||||||
this->WriteModuleLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
this->WriteModuleLibraryRule(ruleFileStream, ruleFileName.c_str(),
|
||||||
target, objects, external_objects);
|
target, objects, external_objects,
|
||||||
|
cleanFiles);
|
||||||
break;
|
break;
|
||||||
case cmTarget::EXECUTABLE:
|
case cmTarget::EXECUTABLE:
|
||||||
this->WriteExecutableRule(ruleFileStream, ruleFileName.c_str(),
|
this->WriteExecutableRule(ruleFileStream, ruleFileName.c_str(),
|
||||||
target, objects, external_objects);
|
target, objects, external_objects,
|
||||||
|
cleanFiles);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Write the requires target.
|
||||||
|
this->WriteTargetRequiresRule(ruleFileStream, target, objects);
|
||||||
|
|
||||||
|
// Write clean target
|
||||||
|
this->WriteTargetCleanRule(ruleFileStream, target, cleanFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -745,14 +697,10 @@ cmLocalUnixMakefileGenerator3
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
std::string
|
||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
::GenerateCustomRuleFile(const cmCustomCommand& cc)
|
::GenerateCustomRuleFile(const cmCustomCommand& cc, const char *dir)
|
||||||
{
|
{
|
||||||
// Create a directory for custom rule files.
|
|
||||||
std::string dir = "CMakeCustomRules.dir";
|
|
||||||
cmSystemTools::MakeDirectory(this->ConvertToFullPath(dir).c_str());
|
|
||||||
|
|
||||||
// Convert the output name to a relative path if possible.
|
// Convert the output name to a relative path if possible.
|
||||||
std::string output = this->Convert(cc.GetOutput(),START_OUTPUT);
|
std::string output = this->Convert(cc.GetOutput(),START_OUTPUT);
|
||||||
|
|
||||||
|
@ -768,27 +716,16 @@ cmLocalUnixMakefileGenerator3
|
||||||
ruleFileName += customName;
|
ruleFileName += customName;
|
||||||
ruleFileName += ".build.make";
|
ruleFileName += ".build.make";
|
||||||
|
|
||||||
// If this is a duplicate rule produce an error.
|
|
||||||
if(m_CustomRuleFiles.find(ruleFileName) != m_CustomRuleFiles.end())
|
|
||||||
{
|
|
||||||
cmSystemTools::Error("An output was found with multiple rules on how to build it for output: ",
|
|
||||||
cc.GetOutput());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_CustomRuleFiles.insert(ruleFileName);
|
|
||||||
|
|
||||||
// what is the relative path to the rule file
|
// what is the relative path to the rule file
|
||||||
std::string relRuleFile = this->GetHomeRelativeOutputPath();
|
std::string relRuleFile = this->Convert(ruleFileName.c_str(),HOME_OUTPUT);
|
||||||
relRuleFile += ruleFileName;
|
|
||||||
|
|
||||||
// Open the rule file. This should be copy-if-different because the
|
// Open the rule file. This should be copy-if-different because the
|
||||||
// rules may depend on this file itself.
|
// rules may depend on this file itself.
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(ruleFileName);
|
cmGeneratedFileStream ruleFileStream(ruleFileName.c_str());
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
|
||||||
ruleFileStream.SetCopyIfDifferent(true);
|
ruleFileStream.SetCopyIfDifferent(true);
|
||||||
if(!ruleFileStream)
|
if(!ruleFileStream)
|
||||||
{
|
{
|
||||||
return;
|
return relRuleFile;
|
||||||
}
|
}
|
||||||
this->WriteDisclaimer(ruleFileStream);
|
this->WriteDisclaimer(ruleFileStream);
|
||||||
ruleFileStream
|
ruleFileStream
|
||||||
|
@ -800,7 +737,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
preEcho += output;
|
preEcho += output;
|
||||||
this->AppendEcho(commands, preEcho.c_str());
|
this->AppendEcho(commands, preEcho.c_str());
|
||||||
this->AppendCustomCommand(commands, cc);
|
this->AppendCustomCommand(commands, cc);
|
||||||
|
|
||||||
// Collect the dependencies.
|
// Collect the dependencies.
|
||||||
std::vector<std::string> depends;
|
std::vector<std::string> depends;
|
||||||
this->AppendCustomDepend(depends, cc);
|
this->AppendCustomDepend(depends, cc);
|
||||||
|
@ -817,6 +754,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
this->WriteMakeRule(ruleFileStream, comment,
|
this->WriteMakeRule(ruleFileStream, comment,
|
||||||
cc.GetOutput(), depends, commands);
|
cc.GetOutput(), depends, commands);
|
||||||
|
|
||||||
|
return relRuleFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -846,18 +784,14 @@ cmLocalUnixMakefileGenerator3
|
||||||
ruleFileStream
|
ruleFileStream
|
||||||
<< "# Utility rule file for " << target.GetName() << ".\n\n";
|
<< "# Utility rule file for " << target.GetName() << ".\n\n";
|
||||||
|
|
||||||
// include the custom commands rules
|
// write the custom commands for this target
|
||||||
if (m_CustomRuleFiles.size())
|
std::vector<std::string> cleanFiles;
|
||||||
|
if(const char* additional_clean_files =
|
||||||
|
m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES"))
|
||||||
{
|
{
|
||||||
// do the include
|
cmSystemTools::ExpandListArgument(additional_clean_files, cleanFiles);
|
||||||
std::string dir2 = m_Makefile->GetStartOutputDirectory();
|
}
|
||||||
dir2 += "/CMakeCustomRules.dir/build.make";
|
this->WriteCustomCommands(target,ruleFileStream, cleanFiles);
|
||||||
dir2 = this->Convert(dir2.c_str(),HOME_OUTPUT,MAKEFILE);
|
|
||||||
ruleFileStream
|
|
||||||
<< m_IncludeDirective << " "
|
|
||||||
<< this->ConvertToOutputForExisting(dir2.c_str()).c_str()
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
// Collect the commands and dependencies.
|
// Collect the commands and dependencies.
|
||||||
std::vector<std::string> commands;
|
std::vector<std::string> commands;
|
||||||
|
@ -892,6 +826,9 @@ cmLocalUnixMakefileGenerator3
|
||||||
this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE);
|
this->Convert(buildTargetRuleName.c_str(),HOME_OUTPUT,MAKEFILE);
|
||||||
this->WriteConvenienceRule(ruleFileStream, target.GetName(),
|
this->WriteConvenienceRule(ruleFileStream, target.GetName(),
|
||||||
buildTargetRuleName.c_str());
|
buildTargetRuleName.c_str());
|
||||||
|
|
||||||
|
// Write clean target
|
||||||
|
this->WriteTargetCleanRule(ruleFileStream, target, cleanFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1082,21 +1019,6 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetIncludes(std::ostream& makefi
|
||||||
std::vector<std::string> depends;
|
std::vector<std::string> depends;
|
||||||
std::vector<std::string> no_commands;
|
std::vector<std::string> no_commands;
|
||||||
|
|
||||||
// if this is the clean rules also include the custom commands if there
|
|
||||||
// were any
|
|
||||||
const char* clean_no_custom = m_Makefile->GetProperty("CLEAN_NO_CUSTOM");
|
|
||||||
if (!strcmp(rule,"clean") && cmSystemTools::IsOff(clean_no_custom))
|
|
||||||
{
|
|
||||||
// do the include
|
|
||||||
std::string dir = m_Makefile->GetStartOutputDirectory();
|
|
||||||
dir += "/CMakeCustomRules.dir/clean.make";
|
|
||||||
dir = this->Convert(dir.c_str(),HOME_OUTPUT,MAKEFILE);
|
|
||||||
makefileStream
|
|
||||||
<< m_IncludeDirective << " "
|
|
||||||
<< this->ConvertToOutputForExisting(dir.c_str()).c_str()
|
|
||||||
<< "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
for (cmTargets::const_iterator l = m_Makefile->GetTargets().begin();
|
for (cmTargets::const_iterator l = m_Makefile->GetTargets().begin();
|
||||||
l != m_Makefile->GetTargets().end(); l++)
|
l != m_Makefile->GetTargets().end(); l++)
|
||||||
{
|
{
|
||||||
|
@ -1185,41 +1107,6 @@ void cmLocalUnixMakefileGenerator3::WriteMainTargetRules(std::ostream& makefileS
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
|
||||||
void
|
|
||||||
cmLocalUnixMakefileGenerator3
|
|
||||||
::WriteLocalCleanRule(std::ostream& makefileStream)
|
|
||||||
{
|
|
||||||
// Collect a list of extra files to clean in this directory.
|
|
||||||
std::vector<std::string> files;
|
|
||||||
|
|
||||||
// Look for files registered for cleaning in this directory.
|
|
||||||
if(const char* additional_clean_files =
|
|
||||||
m_Makefile->GetProperty("ADDITIONAL_MAKE_CLEAN_FILES"))
|
|
||||||
{
|
|
||||||
cmSystemTools::ExpandListArgument(additional_clean_files, files);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write the local clean rule for this directory.
|
|
||||||
if(!files.empty())
|
|
||||||
{
|
|
||||||
// Have extra files to clean. Write the action to remove them.
|
|
||||||
std::string cleanTarget = this->GetHomeRelativeOutputPath();
|
|
||||||
cleanTarget += "clean.local";
|
|
||||||
std::vector<std::string> no_depends;
|
|
||||||
std::vector<std::string> commands;
|
|
||||||
this->AppendCleanCommand(commands, files);
|
|
||||||
this->WriteMakeRule(makefileStream,
|
|
||||||
"Clean extra files in this directory.",
|
|
||||||
cleanTarget.c_str(), no_depends, commands);
|
|
||||||
commands.clear();
|
|
||||||
no_depends.push_back(cleanTarget);
|
|
||||||
this->WriteMakeRule(makefileStream, 0,
|
|
||||||
"clean", no_depends, commands);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
|
@ -1482,7 +1369,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects)
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
// Write the dependency generation rule.
|
// Write the dependency generation rule.
|
||||||
this->WriteTargetDependRule(ruleFileStream, target, objects);
|
this->WriteTargetDependRule(ruleFileStream, target, objects);
|
||||||
|
@ -1510,8 +1398,6 @@ cmLocalUnixMakefileGenerator3
|
||||||
objTarget += ruleFileName;
|
objTarget += ruleFileName;
|
||||||
this->AppendRuleDepend(depends, objTarget.c_str());
|
this->AppendRuleDepend(depends, objTarget.c_str());
|
||||||
|
|
||||||
std::vector<std::string> cleanFiles;
|
|
||||||
|
|
||||||
// Construct the full path to the executable that will be generated.
|
// Construct the full path to the executable that will be generated.
|
||||||
std::string targetFullPath = m_ExecutableOutputPath;
|
std::string targetFullPath = m_ExecutableOutputPath;
|
||||||
if(targetFullPath.length() == 0)
|
if(targetFullPath.length() == 0)
|
||||||
|
@ -1646,13 +1532,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
|
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
|
||||||
buildTargetRuleName.c_str());
|
buildTargetRuleName.c_str());
|
||||||
|
|
||||||
// Write clean target
|
|
||||||
cleanFiles.push_back(cleanObjs);
|
cleanFiles.push_back(cleanObjs);
|
||||||
cleanFiles.push_back(targetOutPath.c_str());
|
cleanFiles.push_back(targetOutPath.c_str());
|
||||||
this->WriteTargetCleanRule(ruleFileName, target, cleanFiles, objects, external_objects);
|
|
||||||
|
|
||||||
// Write the driving make target.
|
|
||||||
this->WriteTargetRequiresRule(ruleFileStream, target, objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1662,7 +1543,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects)
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage =
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||||
|
@ -1674,7 +1556,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
this->AppendFlags(extraFlags, target.GetProperty("STATIC_LIBRARY_FLAGS"));
|
this->AppendFlags(extraFlags, target.GetProperty("STATIC_LIBRARY_FLAGS"));
|
||||||
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
||||||
objects, external_objects,
|
objects, external_objects,
|
||||||
linkRuleVar.c_str(), extraFlags.c_str());
|
linkRuleVar.c_str(), extraFlags.c_str(),cleanFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1684,7 +1566,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects)
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage =
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||||
|
@ -1712,7 +1595,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
}
|
}
|
||||||
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
||||||
objects, external_objects,
|
objects, external_objects,
|
||||||
linkRuleVar.c_str(), extraFlags.c_str());
|
linkRuleVar.c_str(), extraFlags.c_str(), cleanFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1722,7 +1605,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects)
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
const char* linkLanguage =
|
const char* linkLanguage =
|
||||||
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
target.GetLinkerLanguage(this->GetGlobalGenerator());
|
||||||
|
@ -1736,7 +1620,7 @@ cmLocalUnixMakefileGenerator3
|
||||||
// TODO: .def files should be supported here also.
|
// TODO: .def files should be supported here also.
|
||||||
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
this->WriteLibraryRule(ruleFileStream, ruleFileName, target,
|
||||||
objects, external_objects,
|
objects, external_objects,
|
||||||
linkRuleVar.c_str(), extraFlags.c_str());
|
linkRuleVar.c_str(), extraFlags.c_str(), cleanFiles);
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -1748,7 +1632,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects,
|
const std::vector<std::string>& external_objects,
|
||||||
const char* linkRuleVar,
|
const char* linkRuleVar,
|
||||||
const char* extraFlags)
|
const char* extraFlags,
|
||||||
|
std::vector<std::string>& cleanFiles)
|
||||||
{
|
{
|
||||||
// Write the dependency generation rule.
|
// Write the dependency generation rule.
|
||||||
this->WriteTargetDependRule(ruleFileStream, target, objects);
|
this->WriteTargetDependRule(ruleFileStream, target, objects);
|
||||||
|
@ -1778,8 +1663,6 @@ cmLocalUnixMakefileGenerator3
|
||||||
objTarget += ruleFileName;
|
objTarget += ruleFileName;
|
||||||
this->AppendRuleDepend(depends, objTarget.c_str());
|
this->AppendRuleDepend(depends, objTarget.c_str());
|
||||||
|
|
||||||
std::vector<std::string> cleanFiles;
|
|
||||||
|
|
||||||
// from here up is the same for exe or lib
|
// from here up is the same for exe or lib
|
||||||
|
|
||||||
for(std::vector<std::string>::const_iterator obj = external_objects.begin();
|
for(std::vector<std::string>::const_iterator obj = external_objects.begin();
|
||||||
|
@ -1964,13 +1847,8 @@ cmLocalUnixMakefileGenerator3
|
||||||
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
|
this->WriteConvenienceRule(ruleFileStream, targetFullPath.c_str(),
|
||||||
buildTargetRuleName.c_str());
|
buildTargetRuleName.c_str());
|
||||||
|
|
||||||
// Write clean target
|
|
||||||
cleanFiles.push_back(cleanObjs);
|
cleanFiles.push_back(cleanObjs);
|
||||||
cleanFiles.push_back(targetOutPath.c_str());
|
cleanFiles.push_back(targetOutPath.c_str());
|
||||||
this->WriteTargetCleanRule(ruleFileName, target, cleanFiles, objects, external_objects);
|
|
||||||
|
|
||||||
// Write the driving make target.
|
|
||||||
this->WriteTargetRequiresRule(ruleFileStream, target, objects);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -2058,32 +1936,10 @@ cmLocalUnixMakefileGenerator3
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void
|
void
|
||||||
cmLocalUnixMakefileGenerator3
|
cmLocalUnixMakefileGenerator3
|
||||||
::WriteTargetCleanRule(const char *ruleFileName,
|
::WriteTargetCleanRule(std::ostream& ruleFileStream,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& files,
|
const std::vector<std::string>& files)
|
||||||
const std::vector<std::string>& objects,
|
|
||||||
const std::vector<std::string>& external_objects)
|
|
||||||
{
|
{
|
||||||
std::string dir = cmSystemTools::GetFilenamePath(ruleFileName);
|
|
||||||
std::string cleanFileName = dir;
|
|
||||||
cleanFileName += "/clean.make";
|
|
||||||
|
|
||||||
// Open the rule file. This should be copy-if-different because the
|
|
||||||
// rules may depend on this file itself.
|
|
||||||
std::string ruleFileNameFull = this->ConvertToFullPath(cleanFileName);
|
|
||||||
cmGeneratedFileStream ruleFileStream(ruleFileNameFull.c_str());
|
|
||||||
ruleFileStream.SetCopyIfDifferent(true);
|
|
||||||
if(!ruleFileStream)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
this->WriteDisclaimer(ruleFileStream);
|
|
||||||
|
|
||||||
std::string variableName;
|
|
||||||
std::string variableNameExternal;
|
|
||||||
this->WriteObjectsVariable(ruleFileStream, target, objects, external_objects,
|
|
||||||
variableName, variableNameExternal);
|
|
||||||
|
|
||||||
std::vector<std::string> no_depends;
|
std::vector<std::string> no_depends;
|
||||||
std::vector<std::string> commands;
|
std::vector<std::string> commands;
|
||||||
|
|
||||||
|
|
|
@ -135,7 +135,6 @@ public:
|
||||||
|
|
||||||
void WriteSpecialTargetsBottom(std::ostream& makefileStream);
|
void WriteSpecialTargetsBottom(std::ostream& makefileStream);
|
||||||
std::string GetRelativeTargetDirectory(const cmTarget& target);
|
std::string GetRelativeTargetDirectory(const cmTarget& target);
|
||||||
void WriteLocalCleanRule(std::ostream& makefileStream);
|
|
||||||
|
|
||||||
// List the files for which to check dependency integrity. Each
|
// List the files for which to check dependency integrity. Each
|
||||||
// language has its own list because integrity may be checked
|
// language has its own list because integrity may be checked
|
||||||
|
@ -172,7 +171,8 @@ protected:
|
||||||
|
|
||||||
// this is responsible for writing all of the rules for all this
|
// this is responsible for writing all of the rules for all this
|
||||||
// directories custom commands (but not utility targets)
|
// directories custom commands (but not utility targets)
|
||||||
void WriteCustomCommands();
|
void WriteCustomCommands(const cmTarget &target,std::ostream& os,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
// this method Writes the Directory informaiton files
|
// this method Writes the Directory informaiton files
|
||||||
void WriteDirectoryInformationFile();
|
void WriteDirectoryInformationFile();
|
||||||
|
@ -221,31 +221,38 @@ protected:
|
||||||
bool verbose);
|
bool verbose);
|
||||||
|
|
||||||
|
|
||||||
void GenerateCustomRuleFile(const cmCustomCommand& cc);
|
std::string GenerateCustomRuleFile(const cmCustomCommand& cc,
|
||||||
|
const char *dir);
|
||||||
|
|
||||||
// these three make some simple changes and then call WriteLibraryRule
|
// these three make some simple changes and then call WriteLibraryRule
|
||||||
void WriteStaticLibraryRule(std::ostream& ruleFileStream,
|
void WriteStaticLibraryRule(std::ostream& ruleFileStream,
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects);
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
void WriteSharedLibraryRule(std::ostream& ruleFileStream,
|
void WriteSharedLibraryRule(std::ostream& ruleFileStream,
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects);
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
void WriteModuleLibraryRule(std::ostream& ruleFileStream,
|
void WriteModuleLibraryRule(std::ostream& ruleFileStream,
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects);
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
// the main code for writing the Executable target rules
|
// the main code for writing the Executable target rules
|
||||||
void WriteExecutableRule(std::ostream& ruleFileStream,
|
void WriteExecutableRule(std::ostream& ruleFileStream,
|
||||||
const char* ruleFileName,
|
const char* ruleFileName,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects);
|
const std::vector<std::string>& external_objects,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
// the main method for writing library rules
|
// the main method for writing library rules
|
||||||
void WriteLibraryRule(std::ostream& ruleFileStream,
|
void WriteLibraryRule(std::ostream& ruleFileStream,
|
||||||
|
@ -254,7 +261,8 @@ protected:
|
||||||
const std::vector<std::string>& objects,
|
const std::vector<std::string>& objects,
|
||||||
const std::vector<std::string>& external_objects,
|
const std::vector<std::string>& external_objects,
|
||||||
const char* linkRuleVar,
|
const char* linkRuleVar,
|
||||||
const char* extraLinkFlags);
|
const char* extraLinkFlags,
|
||||||
|
std::vector<std::string>& cleanFiles);
|
||||||
|
|
||||||
void WriteLocalMakefile();
|
void WriteLocalMakefile();
|
||||||
|
|
||||||
|
@ -275,11 +283,9 @@ protected:
|
||||||
void WriteTargetDependRule(std::ostream& ruleFileStream,
|
void WriteTargetDependRule(std::ostream& ruleFileStream,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects);
|
const std::vector<std::string>& objects);
|
||||||
void WriteTargetCleanRule(const char *ruleFileName,
|
void WriteTargetCleanRule(std::ostream& ruleFileStream,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& files,
|
const std::vector<std::string>& files);
|
||||||
const std::vector<std::string>& objects,
|
|
||||||
const std::vector<std::string>& external_objects);
|
|
||||||
void WriteTargetRequiresRule(std::ostream& ruleFileStream,
|
void WriteTargetRequiresRule(std::ostream& ruleFileStream,
|
||||||
const cmTarget& target,
|
const cmTarget& target,
|
||||||
const std::vector<std::string>& objects);
|
const std::vector<std::string>& objects);
|
||||||
|
@ -332,9 +338,6 @@ private:
|
||||||
// Flag for whether echo command needs quotes.
|
// Flag for whether echo command needs quotes.
|
||||||
bool m_EchoNeedsQuote;
|
bool m_EchoNeedsQuote;
|
||||||
|
|
||||||
// Set of custom rule files that have been generated.
|
|
||||||
std::set<cmStdString> m_CustomRuleFiles;
|
|
||||||
|
|
||||||
// Set of object file names that will be built in this directory.
|
// Set of object file names that will be built in this directory.
|
||||||
std::set<cmStdString> m_ObjectFiles;
|
std::set<cmStdString> m_ObjectFiles;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue