
#pragma once is a widely supported compiler pragma, even though it is not part of the C++ standard. Many of the issues keeping #pragma once from being standardized (distributed filesystems, build farms, hard links, etc.) do not apply to CMake - it is easy to build CMake on a single machine. CMake also does not install any header files which can be consumed by other projects (though cmCPluginAPI.h has been deliberately omitted from this conversion in case anyone is still using it.) Finally, #pragma once has been required to build CMake since at least August 2017 (7f29bbe6
enabled server mode unconditionally, which had been using #pragma once since September 2016 (b13d3e0d
)). The fact that we now require C++11 filters out old compilers, and it is unlikely that there is a compiler which supports C++11 but does not support #pragma once.
123 lines
4.2 KiB
C++
123 lines
4.2 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
#pragma once
|
|
|
|
#include "cmConfigure.h" // IWYU pragma: keep
|
|
|
|
#include <iosfwd>
|
|
#include <map>
|
|
#include <set>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
#include "cmLocalCommonGenerator.h"
|
|
#include "cmNinjaTypes.h"
|
|
#include "cmOutputConverter.h"
|
|
|
|
class cmCustomCommand;
|
|
class cmCustomCommandGenerator;
|
|
class cmGeneratedFileStream;
|
|
class cmGeneratorTarget;
|
|
class cmGlobalGenerator;
|
|
class cmGlobalNinjaGenerator;
|
|
class cmMakefile;
|
|
class cmRulePlaceholderExpander;
|
|
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 cmLocalCommonGenerator
|
|
{
|
|
public:
|
|
cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf);
|
|
|
|
~cmLocalNinjaGenerator() override;
|
|
|
|
void Generate() override;
|
|
|
|
cmRulePlaceholderExpander* CreateRulePlaceholderExpander() const override;
|
|
|
|
std::string GetTargetDirectory(
|
|
cmGeneratorTarget const* target) const override;
|
|
|
|
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;
|
|
}
|
|
|
|
std::string BuildCommandLine(
|
|
std::vector<std::string> const& cmdLines,
|
|
std::string const& customStep = std::string(),
|
|
cmGeneratorTarget const* target = nullptr) const;
|
|
|
|
void AppendTargetOutputs(cmGeneratorTarget* target, cmNinjaDeps& outputs,
|
|
const std::string& config);
|
|
void AppendTargetDepends(cmGeneratorTarget* target, cmNinjaDeps& outputs,
|
|
const std::string& config,
|
|
const std::string& fileConfig,
|
|
cmNinjaTargetDepends depends);
|
|
|
|
void AddCustomCommandTarget(cmCustomCommand const* cc,
|
|
cmGeneratorTarget* target);
|
|
void AppendCustomCommandLines(cmCustomCommandGenerator const& ccg,
|
|
std::vector<std::string>& cmdLines);
|
|
void AppendCustomCommandDeps(cmCustomCommandGenerator const& ccg,
|
|
cmNinjaDeps& ninjaDeps,
|
|
const std::string& config);
|
|
|
|
protected:
|
|
std::string ConvertToIncludeReference(
|
|
std::string const& path,
|
|
cmOutputConverter::OutputFormat format = cmOutputConverter::SHELL,
|
|
bool forceFullPaths = false) override;
|
|
|
|
private:
|
|
cmGeneratedFileStream& GetImplFileStream(const std::string& config) const;
|
|
cmGeneratedFileStream& GetCommonFileStream() const;
|
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
|
|
|
void WriteBuildFileTop();
|
|
void WriteProjectHeader(std::ostream& os);
|
|
void WriteNinjaRequiredVersion(std::ostream& os);
|
|
void WriteNinjaConfigurationVariable(std::ostream& os,
|
|
const std::string& config);
|
|
void WriteNinjaFilesInclusionConfig(std::ostream& os);
|
|
void WriteNinjaFilesInclusionCommon(std::ostream& os);
|
|
void WriteProcessedMakefile(std::ostream& os);
|
|
void WritePools(std::ostream& os);
|
|
|
|
void WriteCustomCommandBuildStatement(cmCustomCommand const* cc,
|
|
const cmNinjaDeps& orderOnlyDeps,
|
|
const std::string& config);
|
|
|
|
void WriteCustomCommandBuildStatements(const std::string& config);
|
|
|
|
std::string MakeCustomLauncher(cmCustomCommandGenerator const& ccg);
|
|
|
|
std::string WriteCommandScript(std::vector<std::string> const& cmdLines,
|
|
std::string const& customStep,
|
|
cmGeneratorTarget const* target) const;
|
|
|
|
void AdditionalCleanFiles(const std::string& config);
|
|
|
|
std::string HomeRelativeOutputPath;
|
|
|
|
using CustomCommandTargetMap =
|
|
std::map<cmCustomCommand const*, std::set<cmGeneratorTarget*>>;
|
|
CustomCommandTargetMap CustomCommandTargets;
|
|
std::vector<cmCustomCommand const*> CustomCommands;
|
|
};
|