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
|
2016-04-29 16:40:20 +03:00
|
|
|
#define cmLocalNinjaGenerator_h
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include <cmConfigure.h>
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmLocalCommonGenerator.h"
|
|
|
|
#include "cmLocalGenerator.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
#include "cmNinjaTypes.h"
|
2016-09-01 21:59:28 +03:00
|
|
|
#include "cmOutputConverter.h"
|
|
|
|
|
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-09-01 21:59:28 +03:00
|
|
|
class cmCustomCommand;
|
2014-03-10 23:47:19 +04:00
|
|
|
class cmCustomCommandGenerator;
|
2011-11-11 09:00:49 +04:00
|
|
|
class cmGeneratedFileStream;
|
2016-09-01 21:59:28 +03:00
|
|
|
class cmGeneratorTarget;
|
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmGlobalNinjaGenerator;
|
|
|
|
class cmMakefile;
|
|
|
|
class cmSourceFile;
|
2011-11-11 09:00:49 +04:00
|
|
|
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 23:37:56 +03:00
|
|
|
class cmLocalNinjaGenerator : public cmLocalCommonGenerator
|
2011-11-11 09:00:49 +04:00
|
|
|
{
|
|
|
|
public:
|
2015-08-02 12:41:51 +03:00
|
|
|
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
~cmLocalNinjaGenerator() CM_OVERRIDE;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
void Generate() CM_OVERRIDE;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
std::string GetTargetDirectory(cmGeneratorTarget const* target) const
|
|
|
|
CM_OVERRIDE;
|
2011-11-11 09:00:49 +04: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
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->HomeRelativeOutputPath;
|
|
|
|
}
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2012-07-18 13:27:49 +04:00
|
|
|
void ExpandRuleVariables(std::string& string,
|
2016-05-16 17:34:04 +03:00
|
|
|
const RuleVariables& replaceValues)
|
|
|
|
{
|
2012-07-19 09:32:03 +04:00
|
|
|
cmLocalGenerator::ExpandRuleVariables(string, replaceValues);
|
|
|
|
}
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string BuildCommandLine(const std::vector<std::string>& cmdLines);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2015-10-19 00:13:50 +03:00
|
|
|
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs);
|
|
|
|
void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2015-10-19 00:13:50 +03:00
|
|
|
void AddCustomCommandTarget(cmCustomCommand const* cc,
|
|
|
|
cmGeneratorTarget* target);
|
2014-03-10 23:47:19 +04:00
|
|
|
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& cmdLines);
|
2014-03-10 23:47:19 +04:00
|
|
|
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmNinjaDeps& ninjaDeps);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
std::string ConvertToLinkReference(std::string const& lib,
|
|
|
|
cmOutputConverter::OutputFormat format =
|
|
|
|
cmOutputConverter::SHELL) CM_OVERRIDE;
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
void ComputeObjectFilenames(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmSourceFile const*, std::string>& mapping,
|
2016-06-27 23:44:16 +03:00
|
|
|
cmGeneratorTarget const* gt = CM_NULLPTR) CM_OVERRIDE;
|
2012-07-18 13:27:49 +04:00
|
|
|
|
|
|
|
protected:
|
2016-06-27 22:25:27 +03:00
|
|
|
std::string ConvertToIncludeReference(
|
2016-05-20 00:11:40 +03:00
|
|
|
std::string const& path,
|
|
|
|
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
|
2016-06-27 22:25:27 +03:00
|
|
|
bool forceFullPaths = false) CM_OVERRIDE;
|
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
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
void WriteCustomCommandRule();
|
2016-05-16 17:34:04 +03: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 HomeRelativeOutputPath;
|
|
|
|
|
2015-10-19 00:13:50 +03:00
|
|
|
typedef std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*> >
|
2011-11-11 09:00:49 +04:00
|
|
|
CustomCommandTargetMap;
|
|
|
|
CustomCommandTargetMap CustomCommandTargets;
|
2016-02-10 22:08:48 +03:00
|
|
|
std::vector<cmCustomCommand const*> CustomCommands;
|
2011-11-11 09:00:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! cmLocalNinjaGenerator_h
|