diff options
author | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-18 09:27:49 (GMT) |
---|---|---|
committer | Peter Kümmel <syntheticpp@gmx.net> | 2012-07-18 09:27:49 (GMT) |
commit | 7751966297e3b68b6c9904300f96bb57882af11a (patch) | |
tree | 54d87eba73fb853c5d66f5d68e2b36a5cea7d35d | |
parent | c3988ee871c99e31ad4d10e9033d89da902d5694 (diff) | |
download | CMake-7751966297e3b68b6c9904300f96bb57882af11a.zip CMake-7751966297e3b68b6c9904300f96bb57882af11a.tar.gz CMake-7751966297e3b68b6c9904300f96bb57882af11a.tar.bz2 |
Ninja: remove 'friend' in ninja code
-rw-r--r-- | Source/cmGlobalNinjaGenerator.h | 104 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.h | 62 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.h | 3 |
5 files changed, 87 insertions, 86 deletions
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 61353c5..b2fe243 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -153,6 +153,7 @@ public: static bool IsMinGW() { return UsingMinGW; } + public: /// Default constructor. cmGlobalNinjaGenerator(); @@ -216,12 +217,12 @@ public: } virtual const char* GetCleanTargetName() const { return "clean"; } -public: - cmGeneratedFileStream* GetBuildFileStream() const - { return this->BuildFileStream; } - cmGeneratedFileStream* GetRulesFileStream() const - { return this->RulesFileStream; } + cmGeneratedFileStream* GetBuildFileStream() const { + return this->BuildFileStream; } + + cmGeneratedFileStream* GetRulesFileStream() const { + return this->RulesFileStream; } void AddCXXCompileCommand(const std::string &commandLine, const std::string &sourceFile); @@ -246,27 +247,63 @@ public: void AddCustomCommandRule(); void AddMacOSXContentRule(); + bool HasCustomCommandOutput(const std::string &output) { + return this->CustomCommandOutputs.find(output) != + this->CustomCommandOutputs.end(); + } + + /// Called when we have seen the given custom command. Returns true + /// if we has seen it before. + bool SeenCustomCommand(cmCustomCommand const *cc) { + return !this->CustomCommands.insert(cc).second; + } + + /// Called when we have seen the given custom command output. + void SeenCustomCommandOutput(const std::string &output) { + this->CustomCommandOutputs.insert(output); + // We don't need the assumed dependencies anymore, because we have + // an output. + this->AssumedSourceDependencies.erase(output); + } + + void AddAssumedSourceDependencies(const std::string &source, + const cmNinjaDeps &deps) { + std::set<std::string> &ASD = this->AssumedSourceDependencies[source]; + // Because we may see the same source file multiple times (same source + // specified in multiple targets), compute the union of any assumed + // dependencies. + ASD.insert(deps.begin(), deps.end()); + } + + void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); + void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); + void AddDependencyToAll(cmTarget* target); + void AddDependencyToAll(const std::string& input); + + const std::vector<cmLocalGenerator*>& GetLocalGenerators() const { + return LocalGenerators; } + + bool IsExcluded(cmLocalGenerator* root, cmTarget& target) { + return cmGlobalGenerator::IsExcluded(root, target); } + + int GetRuleCmdLength(const std::string& name) { + return RuleCmdLength[name]; } + + void AddTargetAlias(const std::string& alias, cmTarget* target); + + protected: /// Overloaded methods. /// @see cmGlobalGenerator::CheckALLOW_DUPLICATE_CUSTOM_TARGETS() virtual bool CheckALLOW_DUPLICATE_CUSTOM_TARGETS() { return true; } + private: /// @see cmGlobalGenerator::ComputeTargetObjects virtual void ComputeTargetObjects(cmGeneratorTarget* gt) const; -private: - // In order to access the AddDependencyToAll() functions and co. - friend class cmLocalNinjaGenerator; - - // In order to access the SeenCustomCommand() function. - friend class cmNinjaTargetGenerator; - friend class cmNinjaNormalTargetGenerator; - friend class cmNinjaUtilityTargetGenerator; - -private: void OpenBuildFileStream(); void CloseBuildFileStream(); @@ -278,15 +315,8 @@ private: /// Write the common disclaimer text at the top of each build file. void WriteDisclaimer(std::ostream& os); - void AddDependencyToAll(cmTarget* target); - void AddDependencyToAll(const std::string& input); - void WriteAssumedSourceDependencies(); - void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); - void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); - - void AddTargetAlias(const std::string& alias, cmTarget* target); void WriteTargetAliases(std::ostream& os); void WriteBuiltinTargets(std::ostream& os); @@ -295,39 +325,9 @@ private: void WriteTargetClean(std::ostream& os); void WriteTargetHelp(std::ostream& os); - /// Called when we have seen the given custom command. Returns true - /// if we has seen it before. - bool SeenCustomCommand(cmCustomCommand const *cc) { - return !this->CustomCommands.insert(cc).second; - } - - /// Called when we have seen the given custom command output. - void SeenCustomCommandOutput(const std::string &output) { - this->CustomCommandOutputs.insert(output); - // We don't need the assumed dependencies anymore, because we have - // an output. - this->AssumedSourceDependencies.erase(output); - } - - bool HasCustomCommandOutput(const std::string &output) { - return this->CustomCommandOutputs.find(output) != - this->CustomCommandOutputs.end(); - } - - void AddAssumedSourceDependencies(const std::string &source, - const cmNinjaDeps &deps) { - std::set<std::string> &ASD = this->AssumedSourceDependencies[source]; - // Because we may see the same source file multiple times (same source - // specified in multiple targets), compute the union of any assumed - // dependencies. - ASD.insert(deps.begin(), deps.end()); - } - std::string ninjaCmd() const; - int GetRuleCmdLength(const std::string& name) { return RuleCmdLength[name]; } -private: /// The file containing the build statement. (the relation ship of the /// compilation DAG). cmGeneratedFileStream* BuildFileStream; diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index ea9c406..d902f4e 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -61,7 +61,7 @@ void cmLocalNinjaGenerator::Generate() tg->Generate(); // Add the target to "all" if required. if (!this->GetGlobalNinjaGenerator()->IsExcluded( - this->GetGlobalNinjaGenerator()->LocalGenerators[0], + this->GetGlobalNinjaGenerator()->GetLocalGenerators()[0], t->second)) this->GetGlobalNinjaGenerator()->AddDependencyToAll(&t->second); delete tg; diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index ea44b2f..20b36e8 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -45,7 +45,6 @@ public: /// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory() virtual std::string GetTargetDirectory(cmTarget const& target) const; -public: const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const; cmGlobalNinjaGenerator* GetGlobalNinjaGenerator(); @@ -67,33 +66,8 @@ public: std::string GetHomeRelativeOutputPath() const { return this->HomeRelativeOutputPath; } -protected: - virtual std::string ConvertToLinkReference(std::string const& lib); - virtual std::string ConvertToIncludeReference(std::string const& path); - -private: - friend class cmGlobalNinjaGenerator; - - // In order to access to protected member of the local generator. - friend class cmNinjaTargetGenerator; - friend class cmNinjaNormalTargetGenerator; - friend class cmNinjaUtilityTargetGenerator; - -private: - cmGeneratedFileStream& GetBuildFileStream() const; - cmGeneratedFileStream& GetRulesFileStream() const; - - void WriteBuildFileTop(); - void WriteProjectHeader(std::ostream& os); - void WriteNinjaFilesInclusion(std::ostream& os); - void WriteProcessedMakefile(std::ostream& os); - - void SetConfigName(); - std::string ConvertToNinjaPath(const char *path); - struct map_to_ninja_path; - friend struct map_to_ninja_path; struct map_to_ninja_path { cmLocalNinjaGenerator *LocalGenerator; map_to_ninja_path(cmLocalNinjaGenerator *LocalGen) @@ -102,26 +76,52 @@ private: return LocalGenerator->ConvertToNinjaPath(path.c_str()); } }; + map_to_ninja_path MapToNinjaPath() { return map_to_ninja_path(this); } + void ExpandRuleVariables(std::string& string, + const RuleVariables& replaceValues) { + return cmLocalGenerator:: + ExpandRuleVariables(string, replaceValues); } + + std::string BuildCommandLine(const std::vector<std::string> &cmdLines); + void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs); void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs); - void AppendCustomCommandDeps(const cmCustomCommand *cc, - cmNinjaDeps &ninjaDeps); - std::string BuildCommandLine(const std::vector<std::string> &cmdLines); + void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target); void AppendCustomCommandLines(const cmCustomCommand *cc, std::vector<std::string> &cmdLines); + void AppendCustomCommandDeps(const cmCustomCommand *cc, + cmNinjaDeps &ninjaDeps); + + virtual std::string ConvertToLinkReference(std::string const& lib); + + +protected: + virtual std::string ConvertToIncludeReference(std::string const& path); + + +private: + cmGeneratedFileStream& GetBuildFileStream() const; + cmGeneratedFileStream& GetRulesFileStream() const; + + void WriteBuildFileTop(); + void WriteProjectHeader(std::ostream& os); + void WriteNinjaFilesInclusion(std::ostream& os); + void WriteProcessedMakefile(std::ostream& os); + + void SetConfigName(); + void WriteCustomCommandRule(); void WriteCustomCommandBuildStatement(cmCustomCommand const *cc, const cmNinjaDeps& orderOnlyDeps); - void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target); void WriteCustomCommandBuildStatements(); -private: + std::string ConfigName; std::string HomeRelativeOutputPath; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 36eb64d..ac2b468 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -91,7 +91,7 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const const char* cmNinjaTargetGenerator::GetConfigName() const { - return this->LocalGenerator->ConfigName.c_str(); + return this->LocalGenerator->GetConfigName(); } // TODO: Picked up from cmMakefileTargetGenerator. Refactor it. diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 0a3329f..a2ca4bd 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -126,7 +126,7 @@ protected: private: cmNinjaTargetGenerator* Generator; }; - friend class MacOSXContentGeneratorType; + protected: MacOSXContentGeneratorType MacOSXContentGenerator; @@ -134,6 +134,7 @@ protected: cmOSXBundleGenerator* OSXBundleGenerator; std::set<cmStdString> MacContentFolders; + private: cmTarget* Target; cmGeneratorTarget* GeneratorTarget; |