2016-09-27 19:01:08 +00:00
|
|
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
2011-11-11 05:00:49 +00:00
|
|
|
#ifndef cmLocalNinjaGenerator_h
|
2016-04-29 13:40:20 +00:00
|
|
|
#define cmLocalNinjaGenerator_h
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2017-08-25 18:39:02 +00:00
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
2016-04-29 13:40:20 +00:00
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
#include <iosfwd>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2016-11-05 20:40:14 +00:00
|
|
|
#include "cmLocalCommonGenerator.h"
|
|
|
|
#include "cmNinjaTypes.h"
|
|
|
|
#include "cmOutputConverter.h"
|
|
|
|
|
2016-09-01 18:59:28 +00:00
|
|
|
class cmCustomCommand;
|
2014-03-10 19:47:19 +00:00
|
|
|
class cmCustomCommandGenerator;
|
2011-11-11 05:00:49 +00:00
|
|
|
class cmGeneratedFileStream;
|
2016-09-01 18:59:28 +00:00
|
|
|
class cmGeneratorTarget;
|
|
|
|
class cmGlobalGenerator;
|
|
|
|
class cmGlobalNinjaGenerator;
|
|
|
|
class cmMakefile;
|
2016-11-05 20:40:14 +00:00
|
|
|
class cmRulePlaceholderExpander;
|
2011-11-11 05:00:49 +00: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 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
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
~cmLocalNinjaGenerator() override;
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
void Generate() override;
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const override;
|
2016-10-09 08:34:50 +00:00
|
|
|
|
2017-09-15 13:56:26 +00:00
|
|
|
std::string GetTargetDirectory(
|
|
|
|
cmGeneratorTarget const* target) const override;
|
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
|
2016-05-16 14:34:04 +00:00
|
|
|
{
|
|
|
|
return this->HomeRelativeOutputPath;
|
|
|
|
}
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2017-12-14 16:09:02 +00:00
|
|
|
std::string BuildCommandLine(
|
|
|
|
std::vector<std::string> const& cmdLines,
|
|
|
|
std::string const& customStep = std::string(),
|
|
|
|
cmGeneratorTarget const* target = nullptr) const;
|
2012-07-18 09:27:49 +00:00
|
|
|
|
2019-11-14 16:38:35 +00:00
|
|
|
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs,
|
|
|
|
const std::string& config);
|
2017-04-17 20:24:44 +00:00
|
|
|
void AppendTargetDepends(
|
2019-11-14 16:38:35 +00:00
|
|
|
cmGeneratorTarget* target, cmNinjaDeps& outputs, const std::string& config,
|
2019-11-15 18:01:36 +00:00
|
|
|
const std::string& fileConfig,
|
2017-04-17 20:24:44 +00:00
|
|
|
cmNinjaTargetDepends depends = DependOnTargetArtifact);
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2015-10-18 21:13:50 +00:00
|
|
|
void AddCustomCommandTarget(cmCustomCommand const* cc,
|
|
|
|
cmGeneratorTarget* target);
|
2014-03-10 19:47:19 +00:00
|
|
|
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
|
2016-05-16 14:34:04 +00:00
|
|
|
std::vector<std::string>& cmdLines);
|
2014-03-10 19:47:19 +00:00
|
|
|
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
|
2019-11-14 16:38:35 +00:00
|
|
|
cmNinjaDeps& ninjaDeps,
|
|
|
|
const std::string& config);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
|
|
|
protected:
|
2016-06-27 19:25:27 +00:00
|
|
|
std::string ConvertToIncludeReference(
|
2016-05-19 21:11:40 +00:00
|
|
|
std::string const& path,
|
|
|
|
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
|
2017-09-15 13:56:26 +00:00
|
|
|
bool forceFullPaths = false) override;
|
2012-07-18 09:27:49 +00:00
|
|
|
|
|
|
|
private:
|
2020-01-17 20:25:08 +00:00
|
|
|
cmGeneratedFileStream& GetImplFileStream(const std::string& config) const;
|
2019-11-15 18:01:36 +00:00
|
|
|
cmGeneratedFileStream& GetCommonFileStream() const;
|
2012-07-18 09:27:49 +00:00
|
|
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
|
|
|
|
|
|
|
void WriteBuildFileTop();
|
|
|
|
void WriteProjectHeader(std::ostream& os);
|
2014-10-02 19:21:05 +00:00
|
|
|
void WriteNinjaRequiredVersion(std::ostream& os);
|
2019-11-15 18:01:36 +00:00
|
|
|
void WriteNinjaConfigurationVariable(std::ostream& os,
|
|
|
|
const std::string& config);
|
|
|
|
void WriteNinjaFilesInclusionConfig(std::ostream& os);
|
|
|
|
void WriteNinjaFilesInclusionCommon(std::ostream& os);
|
2012-07-18 09:27:49 +00:00
|
|
|
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
|
|
|
|
2016-05-16 14:34:04 +00:00
|
|
|
void WriteCustomCommandBuildStatement(cmCustomCommand const* cc,
|
2019-11-14 16:38:35 +00:00
|
|
|
const cmNinjaDeps& orderOnlyDeps,
|
|
|
|
const std::string& config);
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2019-11-14 16:38:35 +00:00
|
|
|
void WriteCustomCommandBuildStatements(const std::string& config);
|
2011-11-11 05:00:49 +00:00
|
|
|
|
2014-03-10 19:47:19 +00:00
|
|
|
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
|
2012-07-18 09:27:49 +00:00
|
|
|
|
2017-12-14 16:09:02 +00:00
|
|
|
std::string WriteCommandScript(std::vector<std::string> const& cmdLines,
|
|
|
|
std::string const& customStep,
|
|
|
|
cmGeneratorTarget const* target) const;
|
|
|
|
|
2019-11-14 16:38:35 +00:00
|
|
|
void AdditionalCleanFiles(const std::string& config);
|
2019-05-13 14:42:46 +00:00
|
|
|
|
2011-11-11 05:00:49 +00:00
|
|
|
std::string HomeRelativeOutputPath;
|
|
|
|
|
2019-09-04 16:03:01 +00:00
|
|
|
using CustomCommandTargetMap =
|
|
|
|
std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*>>;
|
2011-11-11 05:00:49 +00:00
|
|
|
CustomCommandTargetMap CustomCommandTargets;
|
2016-02-10 19:08:48 +00:00
|
|
|
std::vector<cmCustomCommand const*> CustomCommands;
|
2011-11-11 05:00:49 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! cmLocalNinjaGenerator_h
|