2016-09-27 22:01:08 +03: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 09:00:49 +04:00
|
|
|
#ifndef cmNinjaTargetGenerator_h
|
|
|
|
#define cmNinjaTargetGenerator_h
|
|
|
|
|
2016-08-24 01:29:15 +03:00
|
|
|
#include <cmConfigure.h>
|
2015-07-07 23:37:56 +03:00
|
|
|
|
2016-08-24 01:29:15 +03:00
|
|
|
#include "cmCommonTargetGenerator.h"
|
2015-09-25 20:26:44 +03:00
|
|
|
#include "cmGlobalNinjaGenerator.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmNinjaTypes.h"
|
2012-07-16 19:34:22 +04:00
|
|
|
#include "cmOSXBundleGenerator.h"
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-08-24 01:29:15 +03:00
|
|
|
#include <set>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
class cmCustomCommand;
|
2011-11-11 09:00:49 +04:00
|
|
|
class cmGeneratedFileStream;
|
2012-03-13 17:24:54 +04:00
|
|
|
class cmGeneratorTarget;
|
2016-08-24 01:29:15 +03:00
|
|
|
class cmLocalNinjaGenerator;
|
2011-11-11 09:00:49 +04:00
|
|
|
class cmMakefile;
|
|
|
|
class cmSourceFile;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmNinjaTargetGenerator : public cmCommonTargetGenerator
|
2011-11-11 09:00:49 +04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/// Create a cmNinjaTargetGenerator according to the @a target's type.
|
2012-10-10 23:32:37 +04:00
|
|
|
static cmNinjaTargetGenerator* New(cmGeneratorTarget* target);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
/// Build a NinjaTargetGenerator.
|
2015-06-06 15:02:24 +03:00
|
|
|
cmNinjaTargetGenerator(cmGeneratorTarget* target);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
/// Destructor.
|
2016-06-27 22:25:27 +03:00
|
|
|
~cmNinjaTargetGenerator() CM_OVERRIDE;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
virtual void Generate() = 0;
|
|
|
|
|
|
|
|
std::string GetTargetName() const;
|
|
|
|
|
2015-01-29 19:02:06 +03:00
|
|
|
bool NeedDepTypeMSVC(const std::string& lang) const;
|
2013-10-18 14:59:47 +04:00
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
protected:
|
2012-08-22 14:37:55 +04:00
|
|
|
bool SetMsvcTargetPdbVariable(cmNinjaVars&) const;
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
cmGeneratedFileStream& GetBuildFileStream() const;
|
|
|
|
cmGeneratedFileStream& GetRulesFileStream() const;
|
|
|
|
|
2012-09-16 03:16:43 +04:00
|
|
|
cmGeneratorTarget* GetGeneratorTarget() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->GeneratorTarget;
|
|
|
|
}
|
2012-09-16 03:16:43 +04:00
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
cmLocalNinjaGenerator* GetLocalGenerator() const
|
2016-05-16 17:34:04 +03:00
|
|
|
{
|
|
|
|
return this->LocalGenerator;
|
|
|
|
}
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
cmGlobalNinjaGenerator* GetGlobalGenerator() const;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmMakefile* GetMakefile() const { return this->Makefile; }
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2015-05-18 20:31:11 +03:00
|
|
|
std::string LanguageCompilerRule(const std::string& lang) const;
|
2016-09-21 22:38:53 +03:00
|
|
|
std::string LanguagePreprocessRule(std::string const& lang) const;
|
|
|
|
bool NeedExplicitPreprocessing(std::string const& lang) const;
|
2016-09-22 17:34:45 +03:00
|
|
|
std::string LanguageDyndepRule(std::string const& lang) const;
|
|
|
|
bool NeedDyndep(std::string const& lang) const;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2014-03-11 02:48:46 +04:00
|
|
|
std::string OrderDependsTargetForTarget();
|
|
|
|
|
|
|
|
std::string ComputeOrderDependsForTarget();
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
/**
|
|
|
|
* Compute the flags for compilation of object files for a given @a language.
|
|
|
|
* @note Generally it is the value of the variable whose name is computed
|
|
|
|
* by LanguageFlagsVarName().
|
|
|
|
*/
|
2014-03-13 02:50:42 +04:00
|
|
|
std::string ComputeFlagsForObject(cmSourceFile const* source,
|
2011-11-11 09:00:49 +04:00
|
|
|
const std::string& language);
|
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
void AddIncludeFlags(std::string& flags,
|
|
|
|
std::string const& lang) CM_OVERRIDE;
|
2015-07-09 16:58:13 +03:00
|
|
|
|
2014-03-13 02:50:42 +04:00
|
|
|
std::string ComputeDefines(cmSourceFile const* source,
|
2011-11-11 09:00:49 +04:00
|
|
|
const std::string& language);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string ConvertToNinjaPath(const std::string& path) const
|
|
|
|
{
|
2015-09-25 20:26:44 +03:00
|
|
|
return this->GetGlobalGenerator()->ConvertToNinjaPath(path);
|
2012-02-19 05:50:53 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGlobalNinjaGenerator::MapToNinjaPathImpl MapToNinjaPath() const
|
|
|
|
{
|
2015-09-25 20:26:44 +03:00
|
|
|
return this->GetGlobalGenerator()->MapToNinjaPath();
|
2011-11-11 09:00:49 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/// @return the list of link dependency for the given target @a target.
|
|
|
|
cmNinjaDeps ComputeLinkDeps() const;
|
|
|
|
|
|
|
|
/// @return the source file path for the given @a source.
|
2014-03-13 02:50:42 +04:00
|
|
|
std::string GetSourceFilePath(cmSourceFile const* source) const;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
|
|
|
/// @return the object file path for the given @a source.
|
2014-03-13 02:50:42 +04:00
|
|
|
std::string GetObjectFilePath(cmSourceFile const* source) const;
|
2016-09-21 22:38:53 +03:00
|
|
|
|
|
|
|
/// @return the preprocessed source file path for the given @a source.
|
|
|
|
std::string GetPreprocessedFilePath(cmSourceFile const* source) const;
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2016-09-22 17:34:45 +03:00
|
|
|
/// @return the dyndep file path for this target.
|
|
|
|
std::string GetDyndepFilePath(std::string const& lang) const;
|
|
|
|
|
|
|
|
/// @return the target dependency scanner info file path
|
|
|
|
std::string GetTargetDependInfoPath(std::string const& lang) const;
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
/// @return the file path where the target named @a name is generated.
|
|
|
|
std::string GetTargetFilePath(const std::string& name) const;
|
|
|
|
|
|
|
|
/// @return the output path for the target.
|
|
|
|
virtual std::string GetTargetOutputDir() const;
|
|
|
|
|
|
|
|
void WriteLanguageRules(const std::string& language);
|
|
|
|
void WriteCompileRule(const std::string& language);
|
|
|
|
void WriteObjectBuildStatements();
|
2014-06-28 00:13:52 +04:00
|
|
|
void WriteObjectBuildStatement(cmSourceFile const* source,
|
|
|
|
bool writeOrderDependsTargetForTarget);
|
2016-09-22 17:34:45 +03:00
|
|
|
void WriteTargetDependInfo(std::string const& lang);
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2015-07-15 21:16:11 +03:00
|
|
|
void ExportObjectCompileCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string const& language, std::string const& sourceFileName,
|
|
|
|
std::string const& objectDir, std::string const& objectFileName,
|
|
|
|
std::string const& objectFileDir, std::string const& flags,
|
|
|
|
std::string const& defines, std::string const& includes);
|
|
|
|
|
|
|
|
cmNinjaDeps GetObjects() const { return this->Objects; }
|
2011-11-11 09:00:49 +04:00
|
|
|
|
2012-08-22 14:37:55 +04:00
|
|
|
void EnsureDirectoryExists(const std::string& dir) const;
|
|
|
|
void EnsureParentDirectoryExists(const std::string& path) const;
|
2012-06-13 02:52:46 +04:00
|
|
|
|
2012-07-16 19:34:22 +04:00
|
|
|
// write rules for Mac OS X Application Bundle content.
|
2016-05-16 17:34:04 +03:00
|
|
|
struct MacOSXContentGeneratorType
|
|
|
|
: cmOSXBundleGenerator::MacOSXContentGeneratorType
|
2012-07-16 19:34:22 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
MacOSXContentGeneratorType(cmNinjaTargetGenerator* g)
|
|
|
|
: Generator(g)
|
|
|
|
{
|
|
|
|
}
|
2012-07-18 14:17:39 +04:00
|
|
|
|
2016-06-27 22:25:27 +03:00
|
|
|
void operator()(cmSourceFile const& source,
|
|
|
|
const char* pkgloc) CM_OVERRIDE;
|
2012-07-16 19:34:22 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
cmNinjaTargetGenerator* Generator;
|
|
|
|
};
|
2012-07-18 15:39:14 +04:00
|
|
|
friend struct MacOSXContentGeneratorType;
|
2012-07-10 22:13:01 +04:00
|
|
|
|
2012-07-18 14:17:39 +04:00
|
|
|
MacOSXContentGeneratorType* MacOSXContentGenerator;
|
2012-07-10 22:13:01 +04:00
|
|
|
// Properly initialized by sub-classes.
|
|
|
|
cmOSXBundleGenerator* OSXBundleGenerator;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> MacContentFolders;
|
2012-07-10 22:13:01 +04:00
|
|
|
|
2014-03-11 02:32:00 +04:00
|
|
|
void addPoolNinjaVariable(const std::string& pool_property,
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget* target, cmNinjaVars& vars);
|
2012-07-18 13:27:49 +04:00
|
|
|
|
2016-04-06 13:55:15 +03:00
|
|
|
bool ForceResponseFile();
|
|
|
|
|
2011-11-11 09:00:49 +04:00
|
|
|
private:
|
|
|
|
cmLocalNinjaGenerator* LocalGenerator;
|
|
|
|
/// List of object files for this target.
|
|
|
|
cmNinjaDeps Objects;
|
2016-09-22 17:34:45 +03:00
|
|
|
cmNinjaDeps DDIFiles; // TODO: Make per-language.
|
2014-04-04 19:09:56 +04:00
|
|
|
std::vector<cmCustomCommand const*> CustomCommands;
|
2016-06-23 18:01:29 +03:00
|
|
|
cmNinjaDeps ExtraFiles;
|
2011-11-11 09:00:49 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ! cmNinjaTargetGenerator_h
|