2011-11-11 09:00:49 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2011 Peter Collingbourne <peter@pcc.me.uk>
|
|
|
|
Copyright 2011 Nicolas Despres <nicolas.despres@gmail.com>
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#ifndef cmLocalNinjaGenerator_h
|
|
|
|
# define cmLocalNinjaGenerator_h
|
|
|
|
|
|
|
|
# include "cmLocalGenerator.h"
|
|
|
|
# include "cmNinjaTypes.h"
|
|
|
|
|
2014-03-10 23:47:19 +04:00
|
|
|
class cmCustomCommandGenerator;
|
2011-11-11 09:00:49 +04:00
|
|
|
class cmGlobalNinjaGenerator;
|
|
|
|
class cmGeneratedFileStream;
|
|
|
|
class cmake;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* \class cmLocalNinjaGenerator
|
|
|
|
* \brief Write a local build.ninja file.
|
|
|
|
*
|
|
|
|
* cmLocalNinjaGenerator produces a local build.ninja file from its
|
|
|
|
* member Makefile.
|
|
|
|
*/
|
|
|
|
class cmLocalNinjaGenerator : public cmLocalGenerator
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Default constructor.
|
2015-04-28 08:50:52 +03:00
|
|
|
cmLocalNinjaGenerator(cmLocalGenerator* parent);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
/// Destructor.
|
|
|
|
virtual ~cmLocalNinjaGenerator();
|
|
|
|
|
|
|
|
/// Overloaded methods. @see cmLocalGenerator::Generate()
|
|
|
|
virtual void Generate();
|
|
|
|
|
|
|
|
/// Overloaded methods. @see cmLocalGenerator::Configure()
|
|
|
|
virtual void Configure();
|
|
|
|
|
|
|
|
/// Overloaded methods. @see cmLocalGenerator::GetTargetDirectory()
|
|
|
|
virtual std::string GetTargetDirectory(cmTarget const& target) const;
|
|
|
|
|
|
|
|
const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
|
|
|
|
cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Shortcut to get the cmake instance throw the global generator.
|
|
|
|
* @return an instance of the cmake object.
|
|
|
|
*/
|
|
|
|
const cmake* GetCMakeInstance() const;
|
|
|
|
cmake* GetCMakeInstance();
|
|
|
|
|
2014-02-10 08:07:44 +04:00
|
|
|
std::string const& GetConfigName() const
|
|
|
|
{ return this->ConfigName; }
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
/// @return whether we are processing the top CMakeLists.txt file.
|
|
|
|
bool isRootMakefile() const;
|
|
|
|
|
|
|
|
/// @returns the relative path between the HomeOutputDirectory and this
|
|
|
|
/// local generators StartOutputDirectory.
|
|
|
|
std::string GetHomeRelativeOutputPath() const
|
|
|
|
{ return this->HomeRelativeOutputPath; }
|
|
|
|
|
2014-03-11 02:32:00 +04:00
|
|
|
std::string ConvertToNinjaPath(const std::string& path);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
struct map_to_ninja_path {
|
|
|
|
cmLocalNinjaGenerator *LocalGenerator;
|
2012-02-05 05:48:08 +04:00
|
|
|
map_to_ninja_path(cmLocalNinjaGenerator *LocalGen)
|
|
|
|
: LocalGenerator(LocalGen) {}
|
2011-11-11 09:00:49 +04:00
|
|
|
std::string operator()(const std::string &path) {
|
2014-10-15 16:54:05 +04:00
|
|
|
return LocalGenerator->ConvertToNinjaPath(path);
|
2011-11-11 09:00:49 +04:00
|
|
|
}
|
|
|
|
};
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
map_to_ninja_path MapToNinjaPath() {
|
|
|
|
return map_to_ninja_path(this);
|
|
|
|
}
|
|
|
|
|
2012-07-18 13:27:49 +04:00
|
|
|
void ExpandRuleVariables(std::string& string,
|
|
|
|
const RuleVariables& replaceValues) {
|
2012-07-19 09:32:03 +04:00
|
|
|
cmLocalGenerator::ExpandRuleVariables(string, replaceValues);
|
|
|
|
}
|
2012-07-18 13:27:49 +04:00
|
|
|
|
|
|
|
std::string BuildCommandLine(const std::vector<std::string> &cmdLines);
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs);
|
|
|
|
void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
|
|
|
|
|
2012-07-18 13:27:49 +04:00
|
|
|
void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target);
|
2014-03-10 23:47:19 +04:00
|
|
|
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
|
2011-11-11 09:00:49 +04:00
|
|
|
std::vector<std::string> &cmdLines);
|
2014-03-10 23:47:19 +04:00
|
|
|
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
|
2012-07-18 13:27:49 +04:00
|
|
|
cmNinjaDeps &ninjaDeps);
|
|
|
|
|
2014-03-04 22:06:29 +04:00
|
|
|
virtual std::string ConvertToLinkReference(std::string const& lib,
|
|
|
|
OutputFormat format = SHELL);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2014-03-11 20:37:26 +04:00
|
|
|
virtual void ComputeObjectFilenames(
|
|
|
|
std::map<cmSourceFile const*, std::string>& mapping,
|
|
|
|
cmGeneratorTarget const* gt = 0);
|
|
|
|
|
2012-07-18 13:27:49 +04:00
|
|
|
|
|
|
|
protected:
|
2014-03-04 22:04:02 +04:00
|
|
|
virtual std::string ConvertToIncludeReference(std::string const& path,
|
2014-10-10 17:57:07 +04:00
|
|
|
OutputFormat format = SHELL,
|
|
|
|
bool forceFullPaths = false);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
cmGeneratedFileStream& GetBuildFileStream() const;
|
|
|
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
|
|
|
|
|
|
|
void WriteBuildFileTop();
|
|
|
|
void WriteProjectHeader(std::ostream& os);
|
2014-10-02 23:21:05 +04:00
|
|
|
void WriteNinjaRequiredVersion(std::ostream& os);
|
2012-07-18 13:27:49 +04:00
|
|
|
void WriteNinjaFilesInclusion(std::ostream& os);
|
|
|
|
void WriteProcessedMakefile(std::ostream& os);
|
2013-11-23 13:49:36 +04:00
|
|
|
void WritePools(std::ostream& os);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
|
|
|
void SetConfigName();
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
void WriteCustomCommandRule();
|
2012-03-13 17:17:46 +04:00
|
|
|
void WriteCustomCommandBuildStatement(cmCustomCommand const *cc,
|
2011-11-11 09:00:49 +04:00
|
|
|
const cmNinjaDeps& orderOnlyDeps);
|
|
|
|
|
|
|
|
void WriteCustomCommandBuildStatements();
|
|
|
|
|
2014-03-10 23:47:19 +04:00
|
|
|
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
std::string ConfigName;
|
|
|
|
std::string HomeRelativeOutputPath;
|
|
|
|
|
2012-03-13 17:17:46 +04:00
|
|
|
typedef std::map<cmCustomCommand const*, std::set<cmTarget*> >
|
2011-11-11 09:00:49 +04:00
|
|
|
CustomCommandTargetMap;
|
|
|
|
CustomCommandTargetMap CustomCommandTargets;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! cmLocalNinjaGenerator_h
|