2011-11-11 05:00:49 +00: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
|
|
|
|
|
2015-07-07 20:37:56 +00:00
|
|
|
# include "cmLocalCommonGenerator.h"
|
2011-11-11 05:00:49 +00:00
|
|
|
# include "cmNinjaTypes.h"
|
|
|
|
|
2014-03-10 19:47:19 +00:00
|
|
|
class cmCustomCommandGenerator;
|
2011-11-11 05:00:49 +00: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.
|
|
|
|
*/
|
2015-07-07 20:37:56 +00:00
|
|
|
class cmLocalNinjaGenerator : public cmLocalCommonGenerator
|
2011-11-11 05:00:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-08-02 09:41:51 +00:00
|
|
|
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
|
2011-11-11 05:00:49 +00:00
|
|
|
|
|
|
|
virtual ~cmLocalNinjaGenerator();
|
|
|
|
|
|
|
|
virtual void Generate();
|
|
|
|
|
2015-10-09 20:27:46 +00:00
|
|
|
virtual
|
|
|
|
std::string GetTargetDirectory(cmGeneratorTarget const* target) const;
|
2011-11-11 05:00:49 +00:00
|
|
|
|
|
|
|
const cmGlobalNinjaGenerator* GetGlobalNinjaGenerator() const;
|
|
|
|
cmGlobalNinjaGenerator* GetGlobalNinjaGenerator();
|
|
|
|
|
|
|
|
const cmake* GetCMakeInstance() const;
|
|
|
|
cmake* GetCMakeInstance();
|
|
|
|
|
|
|
|
/// @returns the relative path between the HomeOutputDirectory and this
|
|
|
|
/// local generators StartOutputDirectory.
|
|
|
|
std::string GetHomeRelativeOutputPath() const
|
|
|
|
{ return this->HomeRelativeOutputPath; }
|
|
|
|
|
2012-07-18 09:27:49 +00:00
|
|
|
void ExpandRuleVariables(std::string& string,
|
|
|
|
const RuleVariables& replaceValues) {
|
2012-07-19 05:32:03 +00:00
|
|
|
cmLocalGenerator::ExpandRuleVariables(string, replaceValues);
|
|
|
|
}
|
2012-07-18 09:27:49 +00:00
|
|
|
|
|
|
|
std::string BuildCommandLine(const std::vector<std::string> &cmdLines);
|
|
|
|
|
2011-11-11 05:00:49 +00:00
|
|
|
void AppendTargetOutputs(cmTarget* target, cmNinjaDeps& outputs);
|
|
|
|
void AppendTargetDepends(cmTarget* target, cmNinjaDeps& outputs);
|
|
|
|
|
2012-07-18 09:27:49 +00:00
|
|
|
void AddCustomCommandTarget(cmCustomCommand const* cc, cmTarget* target);
|
2014-03-10 19:47:19 +00:00
|
|
|
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
|
2011-11-11 05:00:49 +00:00
|
|
|
std::vector<std::string> &cmdLines);
|
2014-03-10 19:47:19 +00:00
|
|
|
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
|
2012-07-18 09:27:49 +00:00
|
|
|
cmNinjaDeps &ninjaDeps);
|
|
|
|
|
2014-03-04 18:06:29 +00:00
|
|
|
virtual std::string ConvertToLinkReference(std::string const& lib,
|
|
|
|
OutputFormat format = SHELL);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
2014-03-11 16:37:26 +00:00
|
|
|
virtual void ComputeObjectFilenames(
|
|
|
|
std::map<cmSourceFile const*, std::string>& mapping,
|
|
|
|
cmGeneratorTarget const* gt = 0);
|
|
|
|
|
2012-07-18 09:27:49 +00:00
|
|
|
|
|
|
|
protected:
|
2014-03-04 18:04:02 +00:00
|
|
|
virtual std::string ConvertToIncludeReference(std::string const& path,
|
2014-10-10 13:57:07 +00:00
|
|
|
OutputFormat format = SHELL,
|
|
|
|
bool forceFullPaths = false);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
cmGeneratedFileStream& GetBuildFileStream() const;
|
|
|
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
|
|
|
|
|
|
|
void WriteBuildFileTop();
|
|
|
|
void WriteProjectHeader(std::ostream& os);
|
2014-10-02 19:21:05 +00:00
|
|
|
void WriteNinjaRequiredVersion(std::ostream& os);
|
2012-07-18 09:27:49 +00:00
|
|
|
void WriteNinjaFilesInclusion(std::ostream& os);
|
|
|
|
void WriteProcessedMakefile(std::ostream& os);
|
2013-11-23 09:49:36 +00:00
|
|
|
void WritePools(std::ostream& os);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
2011-11-11 05:00:49 +00:00
|
|
|
void WriteCustomCommandRule();
|
2012-03-13 13:17:46 +00:00
|
|
|
void WriteCustomCommandBuildStatement(cmCustomCommand const *cc,
|
2011-11-11 05:00:49 +00:00
|
|
|
const cmNinjaDeps& orderOnlyDeps);
|
|
|
|
|
|
|
|
void WriteCustomCommandBuildStatements();
|
|
|
|
|
2014-03-10 19:47:19 +00:00
|
|
|
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
2011-11-11 05:00:49 +00:00
|
|
|
std::string HomeRelativeOutputPath;
|
|
|
|
|
2012-03-13 13:17:46 +00:00
|
|
|
typedef std::map<cmCustomCommand const*, std::set<cmTarget*> >
|
2011-11-11 05:00:49 +00:00
|
|
|
CustomCommandTargetMap;
|
|
|
|
CustomCommandTargetMap CustomCommandTargets;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! cmLocalNinjaGenerator_h
|