GHS: Port to cmGeneratorTarget.

This commit is contained in:
Stephen Kelly 2015-10-21 21:31:00 +02:00
parent b92d0b2c94
commit b74aa0e3d2
4 changed files with 41 additions and 39 deletions

View File

@ -22,23 +22,22 @@
std::string const cmGhsMultiTargetGenerator::DDOption("-dynamic");
cmGhsMultiTargetGenerator::cmGhsMultiTargetGenerator(cmGeneratorTarget *target)
: Target(target->Target)
, GeneratorTarget(target)
: GeneratorTarget(target)
, LocalGenerator(static_cast<cmLocalGhsMultiGenerator *>(
target->GetLocalGenerator()))
, Makefile(target->Target->GetMakefile())
, TargetGroup(DetermineIfTargetGroup(target))
, DynamicDownload(false)
{
this->RelBuildFilePath = this->GetRelBuildFilePath(target->Target);
this->RelBuildFilePath = this->GetRelBuildFilePath(target);
this->RelOutputFileName =
this->RelBuildFilePath + this->Target->GetName() + ".a";
this->RelBuildFilePath + target->GetName() + ".a";
this->RelBuildFileName = this->RelBuildFilePath;
this->RelBuildFileName += this->GetBuildFileName(target->Target);
this->RelBuildFileName += this->GetBuildFileName(target);
std::string absPathToRoot = this->GetAbsPathToRoot(target->Target);
std::string absPathToRoot = this->GetAbsPathToRoot(target);
absPathToRoot = this->AddSlashIfNeededToPath(absPathToRoot);
this->AbsBuildFilePath = absPathToRoot + this->RelBuildFilePath;
this->AbsBuildFileName = absPathToRoot + this->RelBuildFileName;
@ -51,7 +50,8 @@ cmGhsMultiTargetGenerator::~cmGhsMultiTargetGenerator()
}
std::string
cmGhsMultiTargetGenerator::GetRelBuildFilePath(const cmTarget *target)
cmGhsMultiTargetGenerator::GetRelBuildFilePath(
const cmGeneratorTarget *target)
{
std::string output;
char const *folderProp = target->GetProperty("FOLDER");
@ -66,15 +66,13 @@ cmGhsMultiTargetGenerator::GetRelBuildFilePath(const cmTarget *target)
}
std::string
cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmTarget *target)
cmGhsMultiTargetGenerator::GetAbsPathToRoot(const cmGeneratorTarget *target)
{
cmGeneratorTarget* gt = target->GetMakefile()->GetGlobalGenerator()
->GetGeneratorTarget(target);
return gt->GetLocalGenerator()->GetBinaryDirectory();
return target->GetLocalGenerator()->GetBinaryDirectory();
}
std::string
cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmTarget *target)
cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmGeneratorTarget *target)
{
std::string output;
output = cmGhsMultiTargetGenerator::GetAbsPathToRoot(target);
@ -84,7 +82,7 @@ cmGhsMultiTargetGenerator::GetAbsBuildFilePath(const cmTarget *target)
}
std::string
cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmTarget *target)
cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmGeneratorTarget *target)
{
std::string output;
output = cmGhsMultiTargetGenerator::GetRelBuildFilePath(target);
@ -93,7 +91,8 @@ cmGhsMultiTargetGenerator::GetRelBuildFileName(const cmTarget *target)
return output;
}
std::string cmGhsMultiTargetGenerator::GetBuildFileName(const cmTarget *target)
std::string
cmGhsMultiTargetGenerator::GetBuildFileName(const cmGeneratorTarget *target)
{
std::string output;
output = target->GetName();
@ -161,7 +160,8 @@ void cmGhsMultiTargetGenerator::Generate()
bool cmGhsMultiTargetGenerator::IncludeThisTarget()
{
bool output = true;
char const *excludeFromAll = this->Target->GetProperty("EXCLUDE_FROM_ALL");
char const *excludeFromAll =
this->GeneratorTarget->GetProperty("EXCLUDE_FROM_ALL");
if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&
'\0' == excludeFromAll[1])
{
@ -367,13 +367,13 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
for (cmTargetDependSet::iterator tdsI = tds.begin(); tdsI != tds.end();
++tdsI)
{
const cmTarget *tg = (*tdsI)->Target;
const cmGeneratorTarget *tg = *tdsI;
*this->GetFolderBuildStreams() << " -L\"" << GetAbsBuildFilePath(tg)
<< "\"" << std::endl;
}
// library targets
cmTarget::LinkLibraryVectorType llv =
this->Target->GetOriginalLinkLibraries();
this->GeneratorTarget->Target->GetOriginalLinkLibraries();
for (cmTarget::LinkLibraryVectorType::const_iterator llvI = llv.begin();
llvI != llv.end(); ++llvI)
{
@ -391,10 +391,12 @@ void cmGhsMultiTargetGenerator::WriteTargetLinkLibraries()
void cmGhsMultiTargetGenerator::WriteCustomCommands()
{
WriteCustomCommandsHelper(this->Target->GetPreBuildCommands(),
cmTarget::PRE_BUILD);
WriteCustomCommandsHelper(this->Target->GetPostBuildCommands(),
cmTarget::POST_BUILD);
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPreBuildCommands(),
cmTarget::PRE_BUILD);
WriteCustomCommandsHelper(
this->GeneratorTarget->Target->GetPostBuildCommands(),
cmTarget::POST_BUILD);
}
void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper(
@ -518,7 +520,7 @@ cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
std::string outputDir(AbsBuildFilePath);
const char *runtimeOutputProp =
this->Target->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
this->GeneratorTarget->GetProperty("RUNTIME_OUTPUT_DIRECTORY");
if (NULL != runtimeOutputProp)
{
outputDir = runtimeOutputProp;
@ -526,7 +528,8 @@ cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
std::string configCapped(cmSystemTools::UpperCase(config));
const char *runtimeOutputSProp =
this->Target->GetProperty("RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
this->GeneratorTarget
->GetProperty("RUNTIME_OUTPUT_DIRECTORY_" + configCapped);
if (NULL != runtimeOutputSProp)
{
outputDir = runtimeOutputSProp;
@ -544,9 +547,10 @@ cmGhsMultiTargetGenerator::GetOutputDirectory(const std::string &config) const
std::string
cmGhsMultiTargetGenerator::GetOutputFilename(const std::string &config) const
{
std::string outputFilename(this->Target->GetName());
std::string outputFilename(this->GeneratorTarget->GetName());
const char *outputNameProp = this->Target->GetProperty("OUTPUT_NAME");
const char *outputNameProp =
this->GeneratorTarget->GetProperty("OUTPUT_NAME");
if (NULL != outputNameProp)
{
outputFilename = outputNameProp;
@ -554,7 +558,7 @@ cmGhsMultiTargetGenerator::GetOutputFilename(const std::string &config) const
std::string configCapped(cmSystemTools::UpperCase(config));
const char *outputNameSProp =
this->Target->GetProperty(configCapped + "_OUTPUT_NAME");
this->GeneratorTarget->GetProperty(configCapped + "_OUTPUT_NAME");
if (NULL != outputNameSProp)
{
outputFilename = outputNameSProp;

View File

@ -54,11 +54,11 @@ public:
return this->AbsOutputFileName.c_str();
}
static std::string GetRelBuildFilePath(const cmTarget *target);
static std::string GetAbsPathToRoot(const cmTarget *target);
static std::string GetAbsBuildFilePath(const cmTarget *target);
static std::string GetRelBuildFileName(const cmTarget *target);
static std::string GetBuildFileName(const cmTarget *target);
static std::string GetRelBuildFilePath(const cmGeneratorTarget *target);
static std::string GetAbsPathToRoot(const cmGeneratorTarget *target);
static std::string GetAbsBuildFilePath(const cmGeneratorTarget *target);
static std::string GetRelBuildFileName(const cmGeneratorTarget *target);
static std::string GetBuildFileName(const cmGeneratorTarget *target);
static std::string AddSlashIfNeededToPath(std::string const &input);
private:
@ -99,7 +99,6 @@ private:
bool DetermineIfDynamicDownload(std::string const &config,
const std::string &language);
cmTarget *Target;
cmGeneratorTarget* GeneratorTarget;
cmLocalGhsMultiGenerator *LocalGenerator;
cmMakefile *Makefile;

View File

@ -487,7 +487,7 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
tgtsI != tgts.end(); ++tgtsI)
{
const cmGeneratorTarget *tgt = *tgtsI;
if (IsTgtForBuild(tgt->Target))
if (IsTgtForBuild(tgt))
{
char const *rawFolderName = tgt->GetProperty("FOLDER");
if (NULL == rawFolderName)
@ -504,7 +504,7 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
GhsMultiGpj::PROJECT);
}
std::vector<cmsys::String> splitPath = cmSystemTools::SplitString(
cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt->Target));
cmGhsMultiTargetGenerator::GetRelBuildFileName(tgt));
std::string foldNameRelBuildFile(*(splitPath.end() - 2) + "/" +
splitPath.back());
*this->TargetFolderBuildStreams[folderName] << foldNameRelBuildFile
@ -516,13 +516,12 @@ void cmGlobalGhsMultiGenerator::UpdateBuildFiles(
}
}
bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmTarget *tgt)
bool cmGlobalGhsMultiGenerator::IsTgtForBuild(const cmGeneratorTarget *tgt)
{
const std::string config =
tgt->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
tgt->Target->GetMakefile()->GetSafeDefinition("CMAKE_BUILD_TYPE");
std::vector<cmSourceFile *> tgtSources;
cmGeneratorTarget* gt = this->GetGeneratorTarget(tgt);
gt->GetSourceFiles(tgtSources, config);
tgt->GetSourceFiles(tgtSources, config);
bool tgtInBuild = true;
char const *excludeFromAll = tgt->GetProperty("EXCLUDE_FROM_ALL");
if (NULL != excludeFromAll && '1' == excludeFromAll[0] &&

View File

@ -111,7 +111,7 @@ private:
GhsMultiGpj::Types projType);
static std::string GetFileNameFromPath(std::string const &path);
void UpdateBuildFiles(std::vector<cmGeneratorTarget*> tgts);
bool IsTgtForBuild(const cmTarget *tgt);
bool IsTgtForBuild(const cmGeneratorTarget *tgt);
std::vector<cmGeneratedFileStream *> TargetSubProjects;
std::map<std::string, cmGeneratedFileStream *> TargetFolderBuildStreams;