summaryrefslogtreecommitdiffstats
path: root/Source/cmGlobalGhsMultiGenerator.cxx
diff options
context:
space:
mode:
authorFred Baksik <frodak17@gmail.com>2019-04-08 13:55:34 (GMT)
committerFred Baksik <frodak17@gmail.com>2019-04-11 17:15:50 (GMT)
commit39ee9718d9a56e7b8b15f63576f042415a2771f8 (patch)
tree3a63e90cd4ced8beaf7c41756bde12a071b3bb6d /Source/cmGlobalGhsMultiGenerator.cxx
parent8d3dad9a76591ae0426335d039b8aaacb95862cd (diff)
downloadCMake-39ee9718d9a56e7b8b15f63576f042415a2771f8.zip
CMake-39ee9718d9a56e7b8b15f63576f042415a2771f8.tar.gz
CMake-39ee9718d9a56e7b8b15f63576f042415a2771f8.tar.bz2
GHS: Support add_custom_target() command
-- add new project type that runs shell scripts in proper order
Diffstat (limited to 'Source/cmGlobalGhsMultiGenerator.cxx')
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx150
1 files changed, 108 insertions, 42 deletions
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index a2138d1..2180770 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -308,8 +308,21 @@ void cmGlobalGhsMultiGenerator::WriteCustomRuleBOD(std::ostream& fout)
"}\n";
}
+void cmGlobalGhsMultiGenerator::WriteCustomTargetBOD(std::ostream& fout)
+{
+ fout << "FileTypes {\n"
+ " CmakeTarget {\n"
+ " name = \"Custom Target\"\n"
+ " action = \"&Execute\"\n"
+ " grepable = false\n"
+ " outputType = \"None\"\n"
+ " color = \"#800080\"\n"
+ " }\n"
+ "}\n";
+}
+
void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
- std::ostream& fout, cmLocalGenerator* root,
+ std::ostream& fout, std::string& ename, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
WriteFileHeader(fout);
@@ -342,13 +355,15 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(
fout << "\"" << this->OsDir << "\"" << std::endl;
}
- WriteSubProjects(fout, root, generators);
+ WriteSubProjects(fout, ename, root, generators);
}
void cmGlobalGhsMultiGenerator::WriteSubProjects(
- std::ostream& fout, cmLocalGenerator* root,
+ std::ostream& fout, std::string& ename, cmLocalGenerator* root,
std::vector<cmLocalGenerator*>& generators)
{
+ this->ExcludedTargets.clear();
+
// Collect all targets under this root generator and the transitive
// closure of their dependencies.
TargetDependSet projectTargets;
@@ -356,50 +371,75 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(
this->GetTargetSets(projectTargets, originalTargets, root, generators);
OrderedTargetDependSet orderedProjectTargets(projectTargets, "");
- // write out all the sub-projects
+ // write out all the targets for ALL target
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
for (cmGeneratorTarget const* target : orderedProjectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
+ if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
+ this->ExcludedTargets.push_back(target);
+ continue;
+ }
+ this->WriteProjectLine(fout, target, root, rootBinaryDir);
+ }
+ if (!this->ExcludedTargets.empty()) {
+ fout << "{nobuild} " << ename << " [Project]" << std::endl;
+ }
+}
- const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
- const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
- if (projName && projType) {
- cmLocalGenerator* lg = target->GetLocalGenerator();
- std::string dir = lg->GetCurrentBinaryDirectory();
- dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir);
- if (dir == ".") {
- dir.clear();
- } else {
- if (dir.back() != '/') {
- dir += "/";
- }
- }
+void cmGlobalGhsMultiGenerator::WriteExcludedProjects(
+ std::ostream& fout, cmLocalGenerator* root,
+ std::vector<cmLocalGenerator*>& generators)
+{
+ // write out all the excluded targets
+ std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
+ for (cmGeneratorTarget const* target : this->ExcludedTargets) {
+ if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
+ continue;
+ }
+ this->WriteProjectLine(fout, target, root, rootBinaryDir);
+ }
+ this->ExcludedTargets.clear();
+}
- if (cmSystemTools::IsOn(target->GetProperty("EXCLUDE_FROM_ALL"))) {
- fout << "{comment} ";
+void cmGlobalGhsMultiGenerator::WriteProjectLine(
+ std::ostream& fout, cmGeneratorTarget const* target, cmLocalGenerator* root,
+ std::string& rootBinaryDir)
+{
+ const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
+ const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
+ if (projName && projType) {
+ cmLocalGenerator* lg = target->GetLocalGenerator();
+ std::string dir = lg->GetCurrentBinaryDirectory();
+ dir = root->MaybeConvertToRelativePath(rootBinaryDir, dir.c_str());
+ if (dir == ".") {
+ dir.clear();
+ } else {
+ if (dir.back() != '/') {
+ dir += "/";
}
- std::string projFile = dir + projName + FILE_EXTENSION;
- fout << projFile;
- 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;
+ std::string projFile = dir + projName + FILE_EXTENSION;
+ fout << projFile;
+ fout << " " << projType << std::endl;
- cmGeneratedFileStream fref(fname);
- fref.SetCopyIfDifferent(true);
+ if (cmSystemTools::IsOn(target->GetProperty("GHS_REFERENCE_PROJECT"))) {
+ // create reference project
+ std::string fname = dir;
+ fname += target->GetName();
+ fname += "REF";
+ fname += FILE_EXTENSION;
- this->WriteFileHeader(fref);
- GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref);
- fref << " :reference=" << projFile << std::endl;
+ cmGeneratedFileStream fref(fname);
+ fref.SetCopyIfDifferent(true);
- fref.Close();
- }
+ this->WriteFileHeader(fref);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::REFERENCE, fref);
+ fref << " :reference=" << projFile << std::endl;
+
+ fref.Close();
}
}
}
@@ -424,11 +464,23 @@ void cmGlobalGhsMultiGenerator::Generate()
this->WriteFileHeader(frule);
this->WriteCustomRuleBOD(frule);
frule.Close();
+
+ // create custom target BOD file
+ fname = this->GetCMakeInstance()->GetHomeOutputDirectory() +
+ "/CMakeFiles/custom_target.bod";
+ cmGeneratedFileStream ftarget(fname.c_str());
+ ftarget.SetCopyIfDifferent(true);
+ this->WriteFileHeader(ftarget);
+ this->WriteCustomTargetBOD(ftarget);
+ ftarget.Close();
}
void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
+ std::string fname;
+ std::string ename;
+
if (generators.empty()) {
return;
}
@@ -437,18 +489,30 @@ void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
* with target projects. This avoid the issue where the project has
* the same name as the executable target.
*/
- std::string fname = root->GetCurrentBinaryDirectory();
+ fname = root->GetCurrentBinaryDirectory();
fname += "/";
fname += root->GetProjectName();
fname += ".top";
fname += FILE_EXTENSION;
- cmGeneratedFileStream fout(fname);
- fout.SetCopyIfDifferent(true);
-
- this->WriteTopLevelProject(fout, root, generators);
-
- fout.Close();
+ ename = root->GetProjectName();
+ ename += ".nobuild";
+ ename += FILE_EXTENSION;
+
+ cmGeneratedFileStream top(fname);
+ top.SetCopyIfDifferent(true);
+ this->WriteTopLevelProject(top, ename, root, generators);
+ top.Close();
+
+ if (!this->ExcludedTargets.empty()) {
+ ename = root->GetCurrentBinaryDirectory() + "/" + ename;
+ cmGeneratedFileStream exclude(ename);
+ exclude.SetCopyIfDifferent(true);
+ WriteFileHeader(exclude);
+ GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, exclude);
+ this->WriteExcludedProjects(exclude, root, generators);
+ exclude.Close();
+ }
}
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
@@ -543,6 +607,8 @@ void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
fout << "primaryTarget=" << tgt << std::endl;
fout << "customization=" << root->GetBinaryDirectory()
<< "/CMakeFiles/custom_rule.bod" << std::endl;
+ fout << "customization=" << root->GetBinaryDirectory()
+ << "/CMakeFiles/custom_target.bod" << std::endl;
char const* const customization =
this->GetCMakeInstance()->GetCacheDefinition("GHS_CUSTOMIZATION");