2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2006-02-14 18:36:04 +03:00
|
|
|
#ifndef cmMakefileTargetGenerator_h
|
|
|
|
#define cmMakefileTargetGenerator_h
|
|
|
|
|
2015-07-07 23:37:56 +03:00
|
|
|
#include "cmCommonTargetGenerator.h"
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
#include "cmLocalUnixMakefileGenerator3.h"
|
2012-07-16 19:34:22 +04:00
|
|
|
#include "cmOSXBundleGenerator.h"
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2014-03-10 23:47:19 +04:00
|
|
|
class cmCustomCommandGenerator;
|
2006-02-14 18:36:04 +03:00
|
|
|
class cmDepends;
|
2012-03-07 20:54:52 +04:00
|
|
|
class cmGeneratorTarget;
|
2006-02-14 18:36:04 +03:00
|
|
|
class cmGeneratedFileStream;
|
2006-12-14 22:30:41 +03:00
|
|
|
class cmGlobalUnixMakefileGenerator3;
|
2006-02-14 18:36:04 +03:00
|
|
|
class cmLocalUnixMakefileGenerator3;
|
|
|
|
class cmMakefile;
|
|
|
|
class cmSourceFile;
|
|
|
|
|
|
|
|
/** \class cmMakefileTargetGenerator
|
|
|
|
* \brief Support Routines for writing makefiles
|
|
|
|
*
|
|
|
|
*/
|
2016-05-16 17:34:04 +03:00
|
|
|
class cmMakefileTargetGenerator : public cmCommonTargetGenerator
|
2006-02-14 18:36:04 +03:00
|
|
|
{
|
|
|
|
public:
|
2006-02-15 20:32:43 +03:00
|
|
|
// constructor to set the ivars
|
2015-06-06 15:57:26 +03:00
|
|
|
cmMakefileTargetGenerator(cmGeneratorTarget* target);
|
2012-07-18 14:17:39 +04:00
|
|
|
virtual ~cmMakefileTargetGenerator();
|
2006-02-15 20:32:43 +03:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// construct using this factory call
|
2016-05-16 17:34:04 +03:00
|
|
|
static cmMakefileTargetGenerator* New(cmGeneratorTarget* tgt);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
/* the main entry point for this class. Writes the Makefiles associated
|
|
|
|
with this target */
|
|
|
|
virtual void WriteRuleFiles() = 0;
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-07-11 17:55:27 +04:00
|
|
|
/* return the number of actions that have progress reporting on them */
|
2016-05-16 17:34:04 +03:00
|
|
|
virtual unsigned long GetNumberOfProgressActions()
|
|
|
|
{
|
|
|
|
return this->NumberOfProgressActions;
|
|
|
|
}
|
|
|
|
std::string GetProgressFileNameFull() { return this->ProgressFileNameFull; }
|
2006-07-11 17:55:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget; }
|
2012-07-18 15:39:14 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
protected:
|
|
|
|
// create the file and directory etc
|
|
|
|
void CreateRuleFile();
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// outputs the rules for object files and custom commands used by
|
|
|
|
// this target
|
|
|
|
void WriteTargetBuildRules();
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// write some common code at the top of build.make
|
|
|
|
void WriteCommonCodeRules();
|
2006-06-01 19:45:51 +04:00
|
|
|
void WriteTargetLanguageFlags();
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// write the provide require rules for this target
|
|
|
|
void WriteTargetRequiresRules();
|
|
|
|
|
|
|
|
// write the clean rules for this target
|
|
|
|
void WriteTargetCleanRules();
|
|
|
|
|
|
|
|
// write the depend rules for this target
|
|
|
|
void WriteTargetDependRules();
|
|
|
|
|
2008-02-15 19:22:23 +03: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(cmMakefileTargetGenerator* gen)
|
|
|
|
: Generator(gen)
|
|
|
|
{
|
|
|
|
}
|
2012-07-18 14:17:39 +04:00
|
|
|
|
2014-03-13 02:45:43 +04:00
|
|
|
void operator()(cmSourceFile const& source, const char* pkgloc);
|
2012-07-16 19:34:22 +04:00
|
|
|
|
|
|
|
private:
|
|
|
|
cmMakefileTargetGenerator* Generator;
|
|
|
|
};
|
2012-07-18 15:39:14 +04:00
|
|
|
friend struct MacOSXContentGeneratorType;
|
2008-02-15 19:22:23 +03:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// write the rules for an object
|
2014-03-13 02:50:42 +04:00
|
|
|
void WriteObjectRuleFiles(cmSourceFile const& source);
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// write the build rule for an object
|
2016-05-16 17:34:04 +03:00
|
|
|
void WriteObjectBuildFile(std::string& obj, const std::string& lang,
|
2014-03-13 02:50:42 +04:00
|
|
|
cmSourceFile const& source,
|
2006-02-14 18:36:04 +03:00
|
|
|
std::vector<std::string>& depends);
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// write the depend.make file for an object
|
2014-03-13 02:50:42 +04:00
|
|
|
void WriteObjectDependRules(cmSourceFile const& source,
|
2006-02-14 18:36:04 +03:00
|
|
|
std::vector<std::string>& depends);
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// write the build rule for a custom command
|
2014-03-10 23:47:19 +04:00
|
|
|
void GenerateCustomRuleFile(cmCustomCommandGenerator const& ccg);
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2007-03-09 19:29:15 +03:00
|
|
|
// write a rule to drive building of more than one output from
|
|
|
|
// another rule
|
|
|
|
void GenerateExtraOutput(const char* out, const char* in,
|
|
|
|
bool symbolic = false);
|
|
|
|
|
2015-02-06 00:48:16 +03:00
|
|
|
void MakeEchoProgress(cmLocalUnixMakefileGenerator3::EchoProgress&) const;
|
2009-03-16 23:22:13 +03:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// write out the variable that lists the objects for this target
|
|
|
|
void WriteObjectsVariable(std::string& variableName,
|
2014-03-25 10:17:45 +04:00
|
|
|
std::string& variableNameExternal,
|
|
|
|
bool useWatcomQuote);
|
2006-06-16 00:17:11 +04:00
|
|
|
void WriteObjectsString(std::string& buildObjs);
|
2008-01-30 04:46:25 +03:00
|
|
|
void WriteObjectsStrings(std::vector<std::string>& objStrings,
|
|
|
|
std::string::size_type limit = std::string::npos);
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2006-06-01 19:45:51 +04:00
|
|
|
// write the driver rule to build target outputs
|
2014-02-25 05:32:55 +04:00
|
|
|
void WriteTargetDriverRule(const std::string& main_output, bool relink);
|
2006-06-01 19:45:51 +04:00
|
|
|
|
2006-09-29 00:40:35 +04:00
|
|
|
void DriveCustomCommands(std::vector<std::string>& depends);
|
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// append intertarget dependencies
|
|
|
|
void AppendTargetDepends(std::vector<std::string>& depends);
|
|
|
|
|
2012-03-12 18:54:37 +04:00
|
|
|
// Append object file dependencies.
|
|
|
|
void AppendObjectDepends(std::vector<std::string>& depends);
|
|
|
|
|
2010-11-05 15:33:47 +03:00
|
|
|
// Append link rule dependencies (objects, etc.).
|
|
|
|
void AppendLinkDepends(std::vector<std::string>& depends);
|
|
|
|
|
2011-12-06 01:28:03 +04:00
|
|
|
// Lookup the link rule for this target.
|
2014-02-07 02:31:47 +04:00
|
|
|
std::string GetLinkRule(const std::string& linkRuleVar);
|
2011-12-06 01:28:03 +04:00
|
|
|
|
2007-12-28 22:59:06 +03:00
|
|
|
/** Create a script to hold link rules and a command to invoke the
|
|
|
|
script at build time. */
|
|
|
|
void CreateLinkScript(const char* name,
|
|
|
|
std::vector<std::string> const& link_commands,
|
2008-02-20 22:56:29 +03:00
|
|
|
std::vector<std::string>& makefile_commands,
|
|
|
|
std::vector<std::string>& makefile_depends);
|
2007-12-28 22:59:06 +03:00
|
|
|
|
2008-02-28 01:10:45 +03:00
|
|
|
/** Create a response file with the given set of options. Returns
|
|
|
|
the relative path from the target build working directory to the
|
|
|
|
response file name. */
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string CreateResponseFile(const char* name, std::string const& options,
|
2008-02-28 01:10:45 +03:00
|
|
|
std::vector<std::string>& makefile_depends);
|
|
|
|
|
2014-03-04 20:20:27 +04:00
|
|
|
/** Create list of flags for link libraries. */
|
2016-05-16 17:34:04 +03:00
|
|
|
void CreateLinkLibs(std::string& linkLibs, bool relink, bool useResponseFile,
|
2014-04-05 01:06:13 +04:00
|
|
|
std::vector<std::string>& makefile_depends,
|
|
|
|
bool useWatcomQuote);
|
2014-03-04 20:20:27 +04:00
|
|
|
|
2008-10-15 18:21:14 +04:00
|
|
|
/** Create lists of object files for linking and cleaning. */
|
|
|
|
void CreateObjectLists(bool useLinkScript, bool useArchiveRules,
|
|
|
|
bool useResponseFile, std::string& buildObjs,
|
2014-03-25 10:17:45 +04:00
|
|
|
std::vector<std::string>& makefile_depends,
|
|
|
|
bool useWatcomQuote);
|
2008-10-15 18:21:14 +04:00
|
|
|
|
2014-02-04 06:20:56 +04:00
|
|
|
void AddIncludeFlags(std::string& flags, const std::string& lang);
|
2011-03-15 21:07:36 +03:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
virtual void CloseFileStreams();
|
2014-02-04 06:20:56 +04:00
|
|
|
void RemoveForbiddenFlags(const char* flagVar, const std::string& linkLang,
|
2006-03-14 22:03:16 +03:00
|
|
|
std::string& linkFlags);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmLocalUnixMakefileGenerator3* LocalGenerator;
|
|
|
|
cmGlobalUnixMakefileGenerator3* GlobalGenerator;
|
2006-03-28 17:54:01 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
enum CustomCommandDriveType
|
|
|
|
{
|
|
|
|
OnBuild,
|
|
|
|
OnDepends,
|
|
|
|
OnUtility
|
|
|
|
};
|
2007-05-01 21:51:25 +04:00
|
|
|
CustomCommandDriveType CustomCommandDriver;
|
2006-09-29 00:40:35 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// the full path to the build file
|
|
|
|
std::string BuildFileName;
|
|
|
|
std::string BuildFileNameFull;
|
|
|
|
|
2006-07-11 17:55:27 +04:00
|
|
|
// the full path to the progress file
|
|
|
|
std::string ProgressFileNameFull;
|
|
|
|
unsigned long NumberOfProgressActions;
|
2009-03-16 23:55:58 +03:00
|
|
|
bool NoRuleMessages;
|
2006-07-11 17:55:27 +04:00
|
|
|
|
2006-02-14 18:36:04 +03:00
|
|
|
// the path to the directory the build file is in
|
|
|
|
std::string TargetBuildDirectory;
|
|
|
|
std::string TargetBuildDirectoryFull;
|
|
|
|
|
|
|
|
// the stream for the build file
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratedFileStream* BuildFileStream;
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// the stream for the flag file
|
|
|
|
std::string FlagFileNameFull;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratedFileStream* FlagFileStream;
|
|
|
|
class StringList : public std::vector<std::string>
|
|
|
|
{
|
|
|
|
};
|
2014-02-10 09:21:34 +04:00
|
|
|
std::map<std::string, StringList> FlagFileDepends;
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// the stream for the info file
|
|
|
|
std::string InfoFileNameFull;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmGeneratedFileStream* InfoFileStream;
|
2006-02-14 18:36:04 +03:00
|
|
|
|
|
|
|
// files to clean
|
|
|
|
std::vector<std::string> CleanFiles;
|
|
|
|
|
|
|
|
// objects used by this target
|
|
|
|
std::vector<std::string> Objects;
|
|
|
|
std::vector<std::string> ExternalObjects;
|
|
|
|
|
|
|
|
// Set of object file names that will be built in this directory.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> ObjectFiles;
|
2006-02-14 18:36:04 +03:00
|
|
|
|
2008-02-15 19:22:23 +03:00
|
|
|
// Set of extra output files to be driven by the build.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> ExtraFiles;
|
2008-02-15 19:22:23 +03:00
|
|
|
|
2015-03-06 22:35:28 +03:00
|
|
|
typedef std::map<std::string, std::string> MultipleOutputPairsType;
|
|
|
|
MultipleOutputPairsType MultipleOutputPairs;
|
2016-05-16 17:34:04 +03:00
|
|
|
bool WriteMakeRule(std::ostream& os, const char* comment,
|
2015-03-06 22:35:28 +03:00
|
|
|
const std::vector<std::string>& outputs,
|
|
|
|
const std::vector<std::string>& depends,
|
|
|
|
const std::vector<std::string>& commands,
|
|
|
|
bool in_help = false);
|
|
|
|
|
2008-02-19 00:38:34 +03:00
|
|
|
// Target name info.
|
|
|
|
std::string TargetNameOut;
|
|
|
|
std::string TargetNameSO;
|
|
|
|
std::string TargetNameReal;
|
|
|
|
std::string TargetNameImport;
|
|
|
|
std::string TargetNamePDB;
|
|
|
|
|
|
|
|
// Mac OS X content info.
|
2014-02-10 09:21:34 +04:00
|
|
|
std::set<std::string> MacContentFolders;
|
2012-07-16 19:34:22 +04:00
|
|
|
cmOSXBundleGenerator* OSXBundleGenerator;
|
2012-07-18 14:17:39 +04:00
|
|
|
MacOSXContentGeneratorType* MacOSXContentGenerator;
|
2006-02-14 18:36:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|