GHS: Rearrange project files in binary directory

The top level project and the target projects are all in the same
directory so they are easier to find and looks nicer in the GUI.

All of the ancillary project files are located in the target
subdirectory.
This commit is contained in:
Fred Baksik
2022-03-16 16:24:59 -04:00
parent edff0f6a1d
commit 724b5491ef
2 changed files with 28 additions and 32 deletions

View File

@@ -107,12 +107,6 @@ void cmGhsMultiTargetGenerator::Generate()
return;
}
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
this->Name);
this->GeneratorTarget->Target->SetProperty(
"GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
this->GenerateTarget();
}
@@ -121,7 +115,14 @@ void cmGhsMultiTargetGenerator::GenerateTarget()
// Open the target file in copy-if-different mode.
std::string fproj =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
'/', this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME", fproj);
this->GeneratorTarget->Target->SetProperty(
"GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
cmGeneratedFileStream fout(fproj);
fout.SetCopyIfDifferent(true);
@@ -155,10 +156,16 @@ void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
{
std::string outpath;
/* Determine paths from the target project file to where the output artifacts
* need to be located.
*/
if (this->TagType != GhsMultiGpj::SUBPROJECT) {
// set target binary file destination
outpath = this->GeneratorTarget->GetDirectory(config);
outpath = this->LocalGenerator->MaybeRelativeToCurBinDir(outpath);
std::string binpath = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
outpath = cmSystemTools::RelativePath(
binpath, this->GeneratorTarget->GetDirectory(config));
/* clang-format off */
fout << " :binDirRelative=\"" << outpath << "\"\n"
" -o \"" << this->TargetNameReal << "\"\n";
@@ -166,7 +173,7 @@ void cmGhsMultiTargetGenerator::WriteTargetSpecifics(std::ostream& fout,
}
// set target object file destination
outpath = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
outpath = ".";
fout << " :outputDirRelative=\"" << outpath << "\"\n";
}
@@ -576,11 +583,12 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
// Open the filestream in copy-if-different mode.
std::string gname = sg;
cmsys::SystemTools::ReplaceString(gname, "\\", "_");
std::string lpath = cmStrCat(
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
std::string lpath =
cmStrCat(gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
std::string fpath = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/', lpath);
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
lpath);
cmGeneratedFileStream* f = new cmGeneratedFileStream(fpath);
f->SetCopyIfDifferent(true);
gfiles.push_back(f);

View File

@@ -328,8 +328,7 @@ void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout)
target->GetName() != this->GetInstallTargetName())) {
continue;
}
fout << "CMakeFiles/" << target->GetName() + ".tgt" + FILE_EXTENSION
<< " [Project]\n";
fout << target->GetName() + ".tgt" + FILE_EXTENSION << " [Project]\n";
}
}
@@ -337,33 +336,22 @@ void cmGlobalGhsMultiGenerator::WriteProjectLine(
std::ostream& fout, cmGeneratorTarget const* target,
std::string& rootBinaryDir)
{
cmValue projName = target->GetProperty("GENERATOR_FILE_NAME");
cmValue projFile = target->GetProperty("GENERATOR_FILE_NAME");
cmValue projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
/* If either value is not valid then this particular target is an
* unsupported target type and should be skipped.
*/
if (projName && projType) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
dir = cmSystemTools::ForceToRelativePath(rootBinaryDir, dir);
if (dir == ".") {
dir.clear();
} else {
if (dir.back() != '/') {
dir += "/";
}
}
if (projFile && projType) {
std::string path = cmSystemTools::RelativePath(rootBinaryDir, projFile);
std::string projFile = dir + *projName + FILE_EXTENSION;
fout << projFile;
fout << path;
fout << ' ' << *projType << '\n';
}
}
void cmGlobalGhsMultiGenerator::WriteTargets(cmLocalGenerator* root)
{
std::string rootBinaryDir =
cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeFiles");
std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
// All known targets
for (cmGeneratorTarget const* target : this->ProjectTargets) {