cmake/Source/cmLocalNinjaGenerator.h

126 lines
4.2 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
2012-04-19 19:04:21 +03:00
#ifndef cmLocalNinjaGenerator_h
2016-07-09 11:21:54 +02:00
#define cmLocalNinjaGenerator_h
2012-04-19 19:04:21 +03:00
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2016-10-30 18:24:19 +01:00
#include <iosfwd>
#include <map>
#include <set>
#include <string>
#include <vector>
2012-04-19 19:04:21 +03:00
2017-04-14 19:02:05 +02:00
#include "cmLocalCommonGenerator.h"
#include "cmNinjaTypes.h"
#include "cmOutputConverter.h"
2016-10-30 18:24:19 +01:00
class cmCustomCommand;
2015-04-27 22:25:09 +02:00
class cmCustomCommandGenerator;
2012-04-19 19:04:21 +03:00
class cmGeneratedFileStream;
2016-10-30 18:24:19 +01:00
class cmGeneratorTarget;
class cmGlobalGenerator;
class cmGlobalNinjaGenerator;
class cmMakefile;
2017-04-14 19:02:05 +02:00
class cmRulePlaceholderExpander;
2012-04-19 19:04:21 +03:00
class cmake;
/**
* \class cmLocalNinjaGenerator
* \brief Write a local build.ninja file.
*
* cmLocalNinjaGenerator produces a local build.ninja file from its
* member Makefile.
*/
2015-11-17 17:22:37 +01:00
class cmLocalNinjaGenerator : public cmLocalCommonGenerator
2012-04-19 19:04:21 +03:00
{
public:
2015-11-17 17:22:37 +01:00
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
2012-04-19 19:04:21 +03:00
2018-01-26 17:06:56 +01:00
~cmLocalNinjaGenerator() override;
2012-04-19 19:04:21 +03:00
2018-01-26 17:06:56 +01:00
void Generate() override;
2012-04-19 19:04:21 +03:00
2018-01-26 17:06:56 +01:00
cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const override;
2017-04-14 19:02:05 +02:00
2018-01-26 17:06:56 +01:00
std::string GetTargetDirectory(
cmGeneratorTarget const* target) const override;
2012-04-19 19:04:21 +03: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-07-09 11:21:54 +02:00
{
return this->HomeRelativeOutputPath;
}
2012-04-19 19:04:21 +03:00
2018-08-09 18:06:22 +02:00
std::string BuildCommandLine(
std::vector<std::string> const& cmdLines,
std::string const& customStep = std::string(),
cmGeneratorTarget const* target = nullptr) const;
2012-08-04 10:26:08 +03:00
2020-08-30 11:54:41 +02:00
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs,
const std::string& config);
2017-07-20 19:35:53 +02:00
void AppendTargetDepends(
2020-08-30 11:54:41 +02:00
cmGeneratorTarget* target, cmNinjaDeps& outputs, const std::string& config,
const std::string& fileConfig,
2017-07-20 19:35:53 +02:00
cmNinjaTargetDepends depends = DependOnTargetArtifact);
2012-04-19 19:04:21 +03:00
2016-03-13 13:35:51 +01:00
void AddCustomCommandTarget(cmCustomCommand const* cc,
cmGeneratorTarget* target);
2015-04-27 22:25:09 +02:00
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
2016-07-09 11:21:54 +02:00
std::vector<std::string>& cmdLines);
2015-04-27 22:25:09 +02:00
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
2020-08-30 11:54:41 +02:00
cmNinjaDeps& ninjaDeps,
const std::string& config);
2012-08-04 10:26:08 +03:00
protected:
2016-10-30 18:24:19 +01:00
std::string ConvertToIncludeReference(
2016-07-09 11:21:54 +02:00
std::string const& path,
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
2018-01-26 17:06:56 +01:00
bool forceFullPaths = false) override;
2012-08-04 10:26:08 +03:00
private:
2020-08-30 11:54:41 +02:00
cmGeneratedFileStream& GetImplFileStream(const std::string& config) const;
cmGeneratedFileStream& GetCommonFileStream() const;
2012-08-04 10:26:08 +03:00
cmGeneratedFileStream& GetRulesFileStream() const;
void WriteBuildFileTop();
void WriteProjectHeader(std::ostream& os);
2015-04-27 22:25:09 +02:00
void WriteNinjaRequiredVersion(std::ostream& os);
2020-08-30 11:54:41 +02:00
void WriteNinjaConfigurationVariable(std::ostream& os,
const std::string& config);
void WriteNinjaFilesInclusionConfig(std::ostream& os);
void WriteNinjaFilesInclusionCommon(std::ostream& os);
2012-08-04 10:26:08 +03:00
void WriteProcessedMakefile(std::ostream& os);
2014-08-03 19:52:23 +02:00
void WritePools(std::ostream& os);
2012-08-04 10:26:08 +03:00
2016-07-09 11:21:54 +02:00
void WriteCustomCommandBuildStatement(cmCustomCommand const* cc,
2020-08-30 11:54:41 +02:00
const cmNinjaDeps& orderOnlyDeps,
const std::string& config);
2012-04-19 19:04:21 +03:00
2020-08-30 11:54:41 +02:00
void WriteCustomCommandBuildStatements(const std::string& config);
2012-04-19 19:04:21 +03:00
2015-04-27 22:25:09 +02:00
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
2012-08-04 10:26:08 +03:00
2018-08-09 18:06:22 +02:00
std::string WriteCommandScript(std::vector<std::string> const& cmdLines,
std::string const& customStep,
cmGeneratorTarget const* target) const;
2020-08-30 11:54:41 +02:00
void AdditionalCleanFiles(const std::string& config);
2019-11-11 23:01:05 +01:00
2012-04-19 19:04:21 +03:00
std::string HomeRelativeOutputPath;
2020-02-01 23:06:01 +01:00
using CustomCommandTargetMap =
std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*>>;
2012-04-19 19:04:21 +03:00
CustomCommandTargetMap CustomCommandTargets;
2016-07-09 11:21:54 +02:00
std::vector<cmCustomCommand const*> CustomCommands;
2012-04-19 19:04:21 +03:00
};
#endif // ! cmLocalNinjaGenerator_h