mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 04:40:56 -06:00
GHS: Support add_dependencies() command
-- use references to list target dependencies
This commit is contained in:
@@ -109,12 +109,12 @@ void cmGhsMultiTargetGenerator::Generate()
|
|||||||
|
|
||||||
void cmGhsMultiTargetGenerator::GenerateTarget()
|
void cmGhsMultiTargetGenerator::GenerateTarget()
|
||||||
{
|
{
|
||||||
// Open the filestream in copy-if-different mode.
|
// Open the target file in copy-if-different mode.
|
||||||
std::string fname = this->LocalGenerator->GetCurrentBinaryDirectory();
|
std::string fproj = this->LocalGenerator->GetCurrentBinaryDirectory();
|
||||||
fname += "/";
|
fproj += "/";
|
||||||
fname += this->Name;
|
fproj += this->Name;
|
||||||
fname += cmGlobalGhsMultiGenerator::FILE_EXTENSION;
|
fproj += cmGlobalGhsMultiGenerator::FILE_EXTENSION;
|
||||||
cmGeneratedFileStream fout(fname);
|
cmGeneratedFileStream fout(fproj);
|
||||||
fout.SetCopyIfDifferent(true);
|
fout.SetCopyIfDifferent(true);
|
||||||
|
|
||||||
this->GetGlobalGenerator()->WriteFileHeader(fout);
|
this->GetGlobalGenerator()->WriteFileHeader(fout);
|
||||||
@@ -132,9 +132,23 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
|
|||||||
this->WriteTargetLinkLine(fout, this->ConfigName);
|
this->WriteTargetLinkLine(fout, this->ConfigName);
|
||||||
this->WriteBuildEvents(fout);
|
this->WriteBuildEvents(fout);
|
||||||
}
|
}
|
||||||
this->WriteSources(fout);
|
|
||||||
this->WriteReferences(fout);
|
this->WriteReferences(fout);
|
||||||
|
this->WriteSources(fout);
|
||||||
|
|
||||||
fout.Close();
|
fout.Close();
|
||||||
|
|
||||||
|
// Open the target ref file in copy-if-different mode.
|
||||||
|
std::string fname = this->LocalGenerator->GetCurrentBinaryDirectory();
|
||||||
|
fname += "/";
|
||||||
|
fname += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
|
||||||
|
fname += "/";
|
||||||
|
fname += this->Name + "_REF" + cmGlobalGhsMultiGenerator::FILE_EXTENSION;
|
||||||
|
cmGeneratedFileStream fref(fname);
|
||||||
|
fref.SetCopyIfDifferent(true);
|
||||||
|
this->GetGlobalGenerator()->WriteFileHeader(fref);
|
||||||
|
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref);
|
||||||
|
fref << " :reference=" << fproj << std::endl;
|
||||||
|
fref.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
|
cmGlobalGhsMultiGenerator* cmGhsMultiTargetGenerator::GetGlobalGenerator()
|
||||||
@@ -489,7 +503,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
|
|||||||
|
|
||||||
/* list of known groups and the order they are displayed in a project file */
|
/* list of known groups and the order they are displayed in a project file */
|
||||||
const std::vector<std::string> standardGroups = {
|
const std::vector<std::string> standardGroups = {
|
||||||
"Header Files", "Source Files", "CMake Rules",
|
"CMake Rules", "Header Files", "Source Files",
|
||||||
"Object Files", "Object Libraries", "Resources"
|
"Object Files", "Object Libraries", "Resources"
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -667,7 +681,7 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
|
|||||||
fname += std::to_string(cmdcount++) + "_";
|
fname += std::to_string(cmdcount++) + "_";
|
||||||
fname += (sf->GetLocation()).GetName();
|
fname += (sf->GetLocation()).GetName();
|
||||||
fname += this->CmdWindowsShell ? ".bat" : ".sh";
|
fname += this->CmdWindowsShell ? ".bat" : ".sh";
|
||||||
cmGeneratedFileStream f(fname.c_str());
|
cmGeneratedFileStream f(fname);
|
||||||
f.SetCopyIfDifferent(true);
|
f.SetCopyIfDifferent(true);
|
||||||
this->WriteCustomCommandsHelper(f, ccg);
|
this->WriteCustomCommandsHelper(f, ccg);
|
||||||
f.Close();
|
f.Close();
|
||||||
@@ -727,11 +741,8 @@ void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
|
|||||||
|
|
||||||
void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout)
|
void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout)
|
||||||
{
|
{
|
||||||
// This only applies to INTEGRITY Applications
|
// FIXME - compare unordered to ordered projects
|
||||||
if (this->TagType != GhsMultiGpj::INTERGRITY_APPLICATION) {
|
// also needs transitive build order deps!
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Get the targets that this one depends upon
|
// Get the targets that this one depends upon
|
||||||
cmTargetDependSet unordered =
|
cmTargetDependSet unordered =
|
||||||
this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
|
this->GetGlobalGenerator()->GetTargetDirectDepends(this->GeneratorTarget);
|
||||||
@@ -748,9 +759,6 @@ void cmGhsMultiTargetGenerator::WriteReferences(std::ostream& fout)
|
|||||||
fout << outpath;
|
fout << outpath;
|
||||||
fout << " ";
|
fout << " ";
|
||||||
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fout);
|
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fout);
|
||||||
|
|
||||||
// Tell the global generator that a reference project needs to be created
|
|
||||||
t->Target->SetProperty("GHS_REFERENCE_PROJECT", "ON");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ void cmGlobalGhsMultiGenerator::WriteCustomTargetBOD(std::ostream& fout)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
|
void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
|
||||||
std::ostream& fout, std::string& ename, cmLocalGenerator* root,
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators)
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
WriteFileHeader(fout);
|
WriteFileHeader(fout);
|
||||||
@@ -355,64 +355,80 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
|
|||||||
fout << "\"" << this->OsDir << "\"" << std::endl;
|
fout << "\"" << this->OsDir << "\"" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
WriteSubProjects(fout, ename, root, generators);
|
WriteSubProjects(fout, root, generators);
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGhsMultiGenerator::WriteSubProjects(
|
void cmGlobalGhsMultiGenerator::WriteSubProjects(
|
||||||
std::ostream& fout, std::string& ename, cmLocalGenerator* root,
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators)
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
this->ExcludedTargets.clear();
|
this->DefaultTargets.clear();
|
||||||
|
this->ProjectTargets.clear();
|
||||||
|
|
||||||
// Collect all targets under this root generator and the transitive
|
// Collect all targets under this root generator and the transitive
|
||||||
// closure of their dependencies.
|
// closure of their dependencies.
|
||||||
|
// FIXME -- what is correct list or is it build order
|
||||||
TargetDependSet projectTargets;
|
TargetDependSet projectTargets;
|
||||||
TargetDependSet originalTargets;
|
TargetDependSet originalTargets;
|
||||||
this->GetTargetSets(projectTargets, originalTargets, root, generators);
|
this->GetTargetSets(projectTargets, originalTargets, root, generators);
|
||||||
OrderedTargetDependSet orderedProjectTargets(projectTargets, "");
|
OrderedTargetDependSet orderedProjectTargets(projectTargets, "");
|
||||||
|
|
||||||
// write out all the targets for ALL target
|
// determine the targets for ALL target
|
||||||
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
|
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
|
||||||
for (cmGeneratorTarget const* target : orderedProjectTargets) {
|
for (cmGeneratorTarget const* target : orderedProjectTargets) {
|
||||||
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
|
this->ProjectTargets.push_back(target);
|
||||||
this->ExcludedTargets.push_back(target);
|
if (!cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
|
||||||
continue;
|
this->DefaultTargets.push_back(target);
|
||||||
}
|
}
|
||||||
this->WriteProjectLine(fout, target, root, rootBinaryDir);
|
|
||||||
}
|
|
||||||
if (!this->ExcludedTargets.empty()) {
|
|
||||||
fout << "{nobuild} " << ename << " [Project]" << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fout << root->GetProjectName() << ".default" << FILE_EXTENSION
|
||||||
|
<< " [Project]" << std::endl;
|
||||||
|
fout << "{nobuild} " << root->GetProjectName() << ".target" << FILE_EXTENSION
|
||||||
|
<< " [Project]" << std::endl;
|
||||||
|
fout << "{nobuild} " << root->GetProjectName() << ".project"
|
||||||
|
<< FILE_EXTENSION << " [Project]" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGhsMultiGenerator::WriteExcludedProjects(
|
void cmGlobalGhsMultiGenerator::WriteDefaultProject(
|
||||||
std::ostream& fout, cmLocalGenerator* root,
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators)
|
std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
// write out all the excluded targets
|
// write out all the targets for this project
|
||||||
|
WriteFileHeader(fout);
|
||||||
|
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout);
|
||||||
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
|
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
|
||||||
for (cmGeneratorTarget const* target : this->ExcludedTargets) {
|
for (cmGeneratorTarget const* target : this->DefaultTargets) {
|
||||||
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
this->WriteProjectLine(fout, target, root, rootBinaryDir, false);
|
||||||
continue;
|
}
|
||||||
}
|
}
|
||||||
this->WriteProjectLine(fout, target, root, rootBinaryDir);
|
|
||||||
|
void cmGlobalGhsMultiGenerator::WriteTargetProjects(
|
||||||
|
std::ostream& fout, cmLocalGenerator* root,
|
||||||
|
std::vector<cmLocalGenerator*>& generators, bool proj)
|
||||||
|
{
|
||||||
|
// write out all the targets for this project
|
||||||
|
WriteFileHeader(fout);
|
||||||
|
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout);
|
||||||
|
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
|
||||||
|
for (cmGeneratorTarget const* target : this->ProjectTargets) {
|
||||||
|
this->WriteProjectLine(fout, target, root, rootBinaryDir, proj);
|
||||||
}
|
}
|
||||||
this->ExcludedTargets.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void cmGlobalGhsMultiGenerator::WriteProjectLine(
|
void cmGlobalGhsMultiGenerator::WriteProjectLine(
|
||||||
std::ostream& fout, cmGeneratorTarget const* target, cmLocalGenerator* root,
|
std::ostream& fout, cmGeneratorTarget const* target, cmLocalGenerator* root,
|
||||||
std::string& rootBinaryDir)
|
std::string& rootBinaryDir, bool proj)
|
||||||
{
|
{
|
||||||
const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
|
const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
|
||||||
const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
|
const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
|
||||||
if (projName && projType) {
|
if (projName && projType) {
|
||||||
cmLocalGenerator* lg = target->GetLocalGenerator();
|
cmLocalGenerator* lg = target->GetLocalGenerator();
|
||||||
std::string dir = lg->GetCurrentBinaryDirectory();
|
std::string dir = lg->GetCurrentBinaryDirectory();
|
||||||
dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
|
dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
|
||||||
if (dir == ".") {
|
if (dir == ".") {
|
||||||
dir.clear();
|
dir.clear();
|
||||||
} else {
|
} else {
|
||||||
@@ -424,23 +440,6 @@ void cmGlobalGhsMultiGenerator::WriteProjectLine(
|
|||||||
std::string projFile = dir + projName + FILE_EXTENSION;
|
std::string projFile = dir + projName + FILE_EXTENSION;
|
||||||
fout << projFile;
|
fout << projFile;
|
||||||
fout << " " << projType << std::endl;
|
fout << " " << projType << std::endl;
|
||||||
|
|
||||||
if (cmSystemTools::IsOn(target->GetProperty("GHS_REFERENCE_PROJECT"))) {
|
|
||||||
// create reference project
|
|
||||||
std::string fname = dir;
|
|
||||||
fname += target->GetName();
|
|
||||||
fname += "REF";
|
|
||||||
fname += FILE_EXTENSION;
|
|
||||||
|
|
||||||
cmGeneratedFileStream fref(fname);
|
|
||||||
fref.SetCopyIfDifferent(true);
|
|
||||||
|
|
||||||
this->WriteFileHeader(fref);
|
|
||||||
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref);
|
|
||||||
fref << " :reference=" << projFile << std::endl;
|
|
||||||
|
|
||||||
fref.Close();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -468,7 +467,7 @@ void cmGlobalGhsMultiGenerator::Generate()
|
|||||||
// create custom target BOD file
|
// create custom target BOD file
|
||||||
fname = this->GetCMakeInstance()->GetHomeOutputDirectory() +
|
fname = this->GetCMakeInstance()->GetHomeOutputDirectory() +
|
||||||
"/CMakeFiles/custom_target.bod";
|
"/CMakeFiles/custom_target.bod";
|
||||||
cmGeneratedFileStream ftarget(fname.c_str());
|
cmGeneratedFileStream ftarget(fname);
|
||||||
ftarget.SetCopyIfDifferent(true);
|
ftarget.SetCopyIfDifferent(true);
|
||||||
this->WriteFileHeader(ftarget);
|
this->WriteFileHeader(ftarget);
|
||||||
this->WriteCustomTargetBOD(ftarget);
|
this->WriteCustomTargetBOD(ftarget);
|
||||||
@@ -479,7 +478,6 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
|
|||||||
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
|
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
|
||||||
{
|
{
|
||||||
std::string fname;
|
std::string fname;
|
||||||
std::string ename;
|
|
||||||
|
|
||||||
if (generators.empty()) {
|
if (generators.empty()) {
|
||||||
return;
|
return;
|
||||||
@@ -495,24 +493,37 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
|
|||||||
fname += ".top";
|
fname += ".top";
|
||||||
fname += FILE_EXTENSION;
|
fname += FILE_EXTENSION;
|
||||||
|
|
||||||
ename = root->GetProjectName();
|
|
||||||
ename += ".nobuild";
|
|
||||||
ename += FILE_EXTENSION;
|
|
||||||
|
|
||||||
cmGeneratedFileStream top(fname);
|
cmGeneratedFileStream top(fname);
|
||||||
top.SetCopyIfDifferent(true);
|
top.SetCopyIfDifferent(true);
|
||||||
this->WriteTopLevelProject(top, ename, root, generators);
|
this->WriteTopLevelProject(top, root, generators);
|
||||||
top.Close();
|
top.Close();
|
||||||
|
|
||||||
if (!this->ExcludedTargets.empty()) {
|
fname = root->GetCurrentBinaryDirectory() + "/";
|
||||||
ename = root->GetCurrentBinaryDirectory() + "/" + ename;
|
fname += root->GetProjectName();
|
||||||
cmGeneratedFileStream exclude(ename);
|
fname += ".target";
|
||||||
exclude.SetCopyIfDifferent(true);
|
fname += FILE_EXTENSION;
|
||||||
WriteFileHeader(exclude);
|
cmGeneratedFileStream target(fname);
|
||||||
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, exclude);
|
target.SetCopyIfDifferent(true);
|
||||||
this->WriteExcludedProjects(exclude, root, generators);
|
this->WriteTargetProjects(target, root, generators, false);
|
||||||
exclude.Close();
|
target.Close();
|
||||||
}
|
|
||||||
|
fname = root->GetCurrentBinaryDirectory() + "/";
|
||||||
|
fname += root->GetProjectName();
|
||||||
|
fname += ".project";
|
||||||
|
fname += FILE_EXTENSION;
|
||||||
|
cmGeneratedFileStream project(fname);
|
||||||
|
project.SetCopyIfDifferent(true);
|
||||||
|
this->WriteTargetProjects(project, root, generators, true);
|
||||||
|
project.Close();
|
||||||
|
|
||||||
|
fname = root->GetCurrentBinaryDirectory() + "/";
|
||||||
|
fname += root->GetProjectName();
|
||||||
|
fname += ".default";
|
||||||
|
fname += FILE_EXTENSION;
|
||||||
|
cmGeneratedFileStream default_targets(fname);
|
||||||
|
default_targets.SetCopyIfDifferent(true);
|
||||||
|
this->WriteDefaultProject(default_targets, root, generators);
|
||||||
|
default_targets.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
|
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
|
||||||
|
|||||||
@@ -111,18 +111,20 @@ private:
|
|||||||
/* top-level project */
|
/* top-level project */
|
||||||
void OutputTopLevelProject(cmLocalGenerator* root,
|
void OutputTopLevelProject(cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
void WriteTopLevelProject(std::ostream& fout, std::string& ename,
|
void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root,
|
||||||
cmLocalGenerator* root,
|
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
void WriteMacros(std::ostream& fout);
|
void WriteMacros(std::ostream& fout);
|
||||||
void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
|
void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
|
||||||
void WriteSubProjects(std::ostream& fout, std::string& ename,
|
void WriteSubProjects(std::ostream& fout, cmLocalGenerator* root,
|
||||||
cmLocalGenerator* root,
|
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
void WriteExcludedProjects(std::ostream& fout, cmLocalGenerator* root,
|
void WriteTargetProjects(std::ostream& fout, cmLocalGenerator* root,
|
||||||
std::vector<cmLocalGenerator*>& generators);
|
std::vector<cmLocalGenerator*>& generators,
|
||||||
|
bool proj);
|
||||||
|
void WriteDefaultProject(std::ostream& fout, cmLocalGenerator* root,
|
||||||
|
std::vector<cmLocalGenerator*>& generators);
|
||||||
void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
|
void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
|
||||||
cmLocalGenerator* root, std::string& rootBinaryDir);
|
cmLocalGenerator* root, std::string& rootBinaryDir,
|
||||||
|
bool proj);
|
||||||
void WriteCustomRuleBOD(std::ostream& fout);
|
void WriteCustomRuleBOD(std::ostream& fout);
|
||||||
void WriteCustomTargetBOD(std::ostream& fout);
|
void WriteCustomTargetBOD(std::ostream& fout);
|
||||||
|
|
||||||
@@ -131,7 +133,8 @@ private:
|
|||||||
std::string OsDir;
|
std::string OsDir;
|
||||||
static const char* DEFAULT_BUILD_PROGRAM;
|
static const char* DEFAULT_BUILD_PROGRAM;
|
||||||
static const char* DEFAULT_TOOLSET_ROOT;
|
static const char* DEFAULT_TOOLSET_ROOT;
|
||||||
std::vector<cmGeneratorTarget const*> ExcludedTargets;
|
std::vector<cmGeneratorTarget const*> DefaultTargets;
|
||||||
|
std::vector<cmGeneratorTarget const*> ProjectTargets;
|
||||||
};
|
};
|
||||||
|
|
||||||
class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
|
class cmGlobalGhsMultiGenerator::OrderedTargetDependSet
|
||||||
|
|||||||
Reference in New Issue
Block a user