Commit c34968a9 authored by Stephen Kelly's avatar Stephen Kelly

Port some of the generator API to cmGeneratorTarget.

Just enough to reach the BuildMacContentDirectory method and the
NeedRelinkBeforeInstall methods.

In the future, those methods can be moved to cmGeneratorTarget.
parent abb13ea5
This diff is collapsed.
......@@ -64,18 +64,23 @@ void cmLocalNinjaGenerator::Generate()
}
}
cmTargets& targets = this->GetMakefile()->GetTargets();
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
cmGeneratorTargetsType targets = this->GetMakefile()->GetGeneratorTargets();
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(&t->second);
if (t->second->Target->IsImported())
{
continue;
}
cmNinjaTargetGenerator* tg = cmNinjaTargetGenerator::New(t->second);
if(tg)
{
tg->Generate();
// Add the target to "all" if required.
if (!this->GetGlobalNinjaGenerator()->IsExcluded(
this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0],
t->second))
this->GetGlobalNinjaGenerator()->AddDependencyToAll(&t->second);
*t->second->Target))
this->GetGlobalNinjaGenerator()->AddDependencyToAll(t->second->Target);
delete tg;
}
}
......
......@@ -145,13 +145,18 @@ void cmLocalUnixMakefileGenerator3::Generate()
this->Makefile->IsOn("CMAKE_SKIP_ASSEMBLY_SOURCE_RULES");
// Generate the rule files for each target.
cmTargets& targets = this->Makefile->GetTargets();
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
cmGlobalUnixMakefileGenerator3* gg =
static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
if (t->second->Target->IsImported())
{
continue;
}
cmsys::auto_ptr<cmMakefileTargetGenerator> tg(
cmMakefileTargetGenerator::New(&(t->second)));
cmMakefileTargetGenerator::New(t->second));
if (tg.get())
{
tg->WriteRuleFiles();
......@@ -372,22 +377,23 @@ void cmLocalUnixMakefileGenerator3
// for each target we just provide a rule to cd up to the top and do a make
// on the target
cmTargets& targets = this->Makefile->GetTargets();
cmGeneratorTargetsType targets = this->Makefile->GetGeneratorTargets();
std::string localName;
for(cmTargets::iterator t = targets.begin(); t != targets.end(); ++t)
{
if((t->second.GetType() == cmTarget::EXECUTABLE) ||
(t->second.GetType() == cmTarget::STATIC_LIBRARY) ||
(t->second.GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second.GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second.GetType() == cmTarget::OBJECT_LIBRARY) ||
(t->second.GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second.GetType() == cmTarget::UTILITY))
for(cmGeneratorTargetsType::iterator t = targets.begin();
t != targets.end(); ++t)
{
if((t->second->GetType() == cmTarget::EXECUTABLE) ||
(t->second->GetType() == cmTarget::STATIC_LIBRARY) ||
(t->second->GetType() == cmTarget::SHARED_LIBRARY) ||
(t->second->GetType() == cmTarget::MODULE_LIBRARY) ||
(t->second->GetType() == cmTarget::OBJECT_LIBRARY) ||
(t->second->GetType() == cmTarget::INTERFACE_LIBRARY) ||
(t->second->GetType() == cmTarget::UTILITY))
{
emitted.insert(t->second.GetName());
emitted.insert(t->second->GetName());
// for subdirs add a rule to build this specific target by name.
localName = this->GetRelativeTargetDirectory(t->second);
localName = this->GetRelativeTargetDirectory(*t->second->Target);
localName += "/rule";
commands.clear();
depends.clear();
......@@ -404,22 +410,23 @@ void cmLocalUnixMakefileGenerator3
localName.c_str(), depends, commands, true);
// Add a target with the canonical name (no prefix, suffix or path).
if(localName != t->second.GetName())
if(localName != t->second->GetName())
{
commands.clear();
depends.push_back(localName);
this->WriteMakeRule(ruleFileStream, "Convenience name for target.",
t->second.GetName(), depends, commands, true);
t->second->GetName(), depends, commands, true);
}
// Add a fast rule to build the target
std::string makefileName = this->GetRelativeTargetDirectory(t->second);
std::string makefileName =
this->GetRelativeTargetDirectory(*t->second->Target);
makefileName += "/build.make";
// make sure the makefile name is suitable for a makefile
std::string makeTargetName =
this->GetRelativeTargetDirectory(t->second);
this->GetRelativeTargetDirectory(*t->second->Target);
makeTargetName += "/build";
localName = t->second.GetName();
localName = t->second->GetName();
localName += "/fast";
depends.clear();
commands.clear();
......@@ -433,11 +440,12 @@ void cmLocalUnixMakefileGenerator3
// Add a local name for the rule to relink the target before
// installation.
if(t->second.NeedRelinkBeforeInstall(this->ConfigurationName.c_str()))
if(t->second->Target
->NeedRelinkBeforeInstall(this->ConfigurationName.c_str()))
{
makeTargetName = this->GetRelativeTargetDirectory(t->second);
makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target);
makeTargetName += "/preinstall";
localName = t->second.GetName();
localName = t->second->GetName();
localName += "/preinstall";
depends.clear();
commands.clear();
......
......@@ -21,15 +21,15 @@
//----------------------------------------------------------------------------
cmMakefileExecutableTargetGenerator
::cmMakefileExecutableTargetGenerator(cmTarget* target):
cmMakefileTargetGenerator(target)
::cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target):
cmMakefileTargetGenerator(target->Target)
{
this->CustomCommandDriver = OnDepends;
this->Target->GetExecutableNames(
this->TargetNameOut, this->TargetNameReal, this->TargetNameImport,
this->TargetNamePDB, this->ConfigName);
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
......
......@@ -17,7 +17,7 @@
class cmMakefileExecutableTargetGenerator: public cmMakefileTargetGenerator
{
public:
cmMakefileExecutableTargetGenerator(cmTarget* target);
cmMakefileExecutableTargetGenerator(cmGeneratorTarget* target);
virtual ~cmMakefileExecutableTargetGenerator();
/* the main entry point for this class. Writes the Makefiles associated
......
......@@ -21,15 +21,15 @@
//----------------------------------------------------------------------------
cmMakefileLibraryTargetGenerator
::cmMakefileLibraryTargetGenerator(cmTarget* target):
cmMakefileTargetGenerator(target)
::cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target):
cmMakefileTargetGenerator(target->Target)
{
this->CustomCommandDriver = OnDepends;
this->Target->GetLibraryNames(
this->TargetNameOut, this->TargetNameSO, this->TargetNameReal,
this->TargetNameImport, this->TargetNamePDB, this->ConfigName);
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
......
......@@ -18,7 +18,7 @@ class cmMakefileLibraryTargetGenerator:
public cmMakefileTargetGenerator
{
public:
cmMakefileLibraryTargetGenerator(cmTarget* target);
cmMakefileLibraryTargetGenerator(cmGeneratorTarget* target);
virtual ~cmMakefileLibraryTargetGenerator();
/* the main entry point for this class. Writes the Makefiles associated
......
......@@ -63,7 +63,7 @@ cmMakefileTargetGenerator::~cmMakefileTargetGenerator()
}
cmMakefileTargetGenerator *
cmMakefileTargetGenerator::New(cmTarget *tgt)
cmMakefileTargetGenerator::New(cmGeneratorTarget *tgt)
{
cmMakefileTargetGenerator *result = 0;
......
......@@ -38,7 +38,7 @@ public:
virtual ~cmMakefileTargetGenerator();
// construct using this factory call
static cmMakefileTargetGenerator *New(cmTarget *tgt);
static cmMakefileTargetGenerator *New(cmGeneratorTarget *tgt);
/* the main entry point for this class. Writes the Makefiles associated
with this target */
......
......@@ -20,11 +20,11 @@
//----------------------------------------------------------------------------
cmMakefileUtilityTargetGenerator
::cmMakefileUtilityTargetGenerator(cmTarget* target):
cmMakefileTargetGenerator(target)
::cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target):
cmMakefileTargetGenerator(target->Target)
{
this->CustomCommandDriver = OnUtility;
this->OSXBundleGenerator = new cmOSXBundleGenerator(this->Target,
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
this->ConfigName);
this->OSXBundleGenerator->SetMacContentFolders(&this->MacContentFolders);
}
......
......@@ -18,7 +18,7 @@ class cmMakefileUtilityTargetGenerator:
public cmMakefileTargetGenerator
{
public:
cmMakefileUtilityTargetGenerator(cmTarget* target);
cmMakefileUtilityTargetGenerator(cmGeneratorTarget* target);
virtual ~cmMakefileUtilityTargetGenerator();
/* the main entry point for this class. Writes the Makefiles associated
......
......@@ -17,6 +17,7 @@
#include "cmGeneratedFileStream.h"
#include "cmMakefile.h"
#include "cmOSXBundleGenerator.h"
#include "cmGeneratorTarget.h"
#include <assert.h>
#include <algorithm>
......@@ -27,8 +28,8 @@
cmNinjaNormalTargetGenerator::
cmNinjaNormalTargetGenerator(cmTarget* target)
: cmNinjaTargetGenerator(target)
cmNinjaNormalTargetGenerator(cmGeneratorTarget* target)
: cmNinjaTargetGenerator(target->Target)
, TargetNameOut()
, TargetNameSO()
, TargetNameReal()
......@@ -36,15 +37,16 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
, TargetNamePDB()
, TargetLinkLanguage(0)
{
this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName());
this->TargetLinkLanguage = target->Target
->GetLinkerLanguage(this->GetConfigName());
if (target->GetType() == cmTarget::EXECUTABLE)
target->GetExecutableNames(this->TargetNameOut,
target->Target->GetExecutableNames(this->TargetNameOut,
this->TargetNameReal,
this->TargetNameImport,
this->TargetNamePDB,
GetLocalGenerator()->GetConfigName());
else
target->GetLibraryNames(this->TargetNameOut,
target->Target->GetLibraryNames(this->TargetNameOut,
this->TargetNameSO,
this->TargetNameReal,
this->TargetNameImport,
......@@ -55,7 +57,7 @@ cmNinjaNormalTargetGenerator(cmTarget* target)
{
// on Windows the output dir is already needed at compile time
// ensure the directory exists (OutDir test)
EnsureDirectoryExists(target->GetDirectory(this->GetConfigName()));
EnsureDirectoryExists(target->Target->GetDirectory(this->GetConfigName()));
}
this->OSXBundleGenerator = new cmOSXBundleGenerator(target,
......
......@@ -21,11 +21,12 @@
class cmSourceFile;
class cmOSXBundleGenerator;
class cmGeneratorTarget;
class cmNinjaNormalTargetGenerator : public cmNinjaTargetGenerator
{
public:
cmNinjaNormalTargetGenerator(cmTarget* target);
cmNinjaNormalTargetGenerator(cmGeneratorTarget* target);
~cmNinjaNormalTargetGenerator();
void Generate();
......
......@@ -26,7 +26,7 @@
#include <algorithm>
cmNinjaTargetGenerator *
cmNinjaTargetGenerator::New(cmTarget* target)
cmNinjaTargetGenerator::New(cmGeneratorTarget* target)
{
switch (target->GetType())
{
......@@ -44,7 +44,7 @@ cmNinjaTargetGenerator::New(cmTarget* target)
// We only want to process global targets that live in the home
// (i.e. top-level) directory. CMake creates copies of these targets
// in every directory, which we don't need.
cmMakefile *mf = target->GetMakefile();
cmMakefile *mf = target->Target->GetMakefile();
if (strcmp(mf->GetStartDirectory(), mf->GetHomeDirectory()) == 0)
return new cmNinjaUtilityTargetGenerator(target);
// else fallthrough
......
......@@ -30,7 +30,7 @@ class cmNinjaTargetGenerator
{
public:
/// Create a cmNinjaTargetGenerator according to the @a target's type.
static cmNinjaTargetGenerator* New(cmTarget* target);
static cmNinjaTargetGenerator* New(cmGeneratorTarget* target);
/// Build a NinjaTargetGenerator.
cmNinjaTargetGenerator(cmTarget* target);
......
......@@ -18,8 +18,9 @@
#include "cmSourceFile.h"
#include "cmTarget.h"
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(cmTarget *target)
: cmNinjaTargetGenerator(target) {}
cmNinjaUtilityTargetGenerator::cmNinjaUtilityTargetGenerator(
cmGeneratorTarget *target)
: cmNinjaTargetGenerator(target->Target) {}
cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() {}
......
......@@ -21,7 +21,7 @@ class cmSourceFile;
class cmNinjaUtilityTargetGenerator : public cmNinjaTargetGenerator
{
public:
cmNinjaUtilityTargetGenerator(cmTarget* target);
cmNinjaUtilityTargetGenerator(cmGeneratorTarget* target);
~cmNinjaUtilityTargetGenerator();
void Generate();
......
......@@ -18,10 +18,10 @@
//----------------------------------------------------------------------------
cmOSXBundleGenerator::
cmOSXBundleGenerator(cmTarget* target,
cmOSXBundleGenerator(cmGeneratorTarget* target,
const char* configName)
: Target(target)
, Makefile(target->GetMakefile())
: Target(target->Target)
, Makefile(target->Target->GetMakefile())
, LocalGenerator(Makefile->GetLocalGenerator())
, ConfigName(configName)
, MacContentFolders(0)
......
......@@ -21,11 +21,12 @@
class cmTarget;
class cmMakefile;
class cmLocalGenerator;
class cmGeneratorTarget;
class cmOSXBundleGenerator
{
public:
cmOSXBundleGenerator(cmTarget* target,
cmOSXBundleGenerator(cmGeneratorTarget* target,
const char* configName);
// create an app bundle at a given root, and return
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment