cmake/Source/cmCustomCommand.h

158 lines
5.1 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. */
2021-09-14 00:13:48 +02:00
#pragma once
2017-07-20 19:35:53 +02:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-07-09 11:21:54 +02:00
2016-10-30 18:24:19 +01:00
#include <string>
#include <utility>
#include <vector>
2020-02-01 23:06:01 +01:00
#include "cmCustomCommandLines.h"
#include "cmListFileCache.h"
2021-09-14 00:13:48 +02:00
#include "cmPolicies.h"
2020-02-01 23:06:01 +01:00
class cmImplicitDependsList
: public std::vector<std::pair<std::string, std::string>>
{
};
2023-07-02 19:51:09 +02:00
class cmStateSnapshot;
/** \class cmCustomCommand
* \brief A class to encapsulate a custom command
*
* cmCustomCommand encapsulates the properties of a custom command
*/
class cmCustomCommand
{
public:
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
2022-03-29 21:10:50 +02:00
void SetOutputs(std::vector<std::string> outputs);
void SetOutputs(std::string output);
2015-04-27 22:25:09 +02:00
/** Get the extra files produced by the command. */
const std::vector<std::string>& GetByproducts() const;
2022-03-29 21:10:50 +02:00
void SetByproducts(std::vector<std::string> byproducts);
/** Get the vector that holds the list of dependencies. */
const std::vector<std::string>& GetDepends() const;
2022-03-29 21:10:50 +02:00
void SetDepends(std::vector<std::string> depends);
bool HasMainDependency() const { return this->HasMainDependency_; }
const std::string& GetMainDependency() const;
void SetMainDependency(std::string main_dependency);
2015-04-27 22:25:09 +02:00
/** Get the working directory. */
std::string const& GetWorkingDirectory() const
2016-07-09 11:21:54 +02:00
{
return this->WorkingDirectory;
}
2015-04-27 22:25:09 +02:00
2022-03-29 21:10:50 +02:00
void SetWorkingDirectory(const char* workingDirectory)
{
this->WorkingDirectory = (workingDirectory ? workingDirectory : "");
}
/** Get the list of command lines. */
const cmCustomCommandLines& GetCommandLines() const;
2022-03-29 21:10:50 +02:00
void SetCommandLines(cmCustomCommandLines commandLines);
/** Get the comment string for the command. */
const char* GetComment() const;
2022-03-29 21:10:50 +02:00
void SetComment(const char* comment);
2020-08-30 11:54:41 +02:00
/** Get a value indicating if the command uses UTF-8 output pipes. */
bool GetStdPipesUTF8() const { return this->StdPipesUTF8; }
2022-03-29 21:10:50 +02:00
void SetStdPipesUTF8(bool stdPipesUTF8)
{
this->StdPipesUTF8 = stdPipesUTF8;
}
2020-08-30 11:54:41 +02:00
/** Append to the list of command lines. */
void AppendCommands(const cmCustomCommandLines& commandLines);
/** Append to the list of dependencies. */
void AppendDepends(const std::vector<std::string>& depends);
/** Set/Get whether old-style escaping should be used. */
bool GetEscapeOldStyle() const;
void SetEscapeOldStyle(bool b);
/** Set/Get whether the build tool can replace variables in
arguments to the command. */
bool GetEscapeAllowMakeVars() const;
void SetEscapeAllowMakeVars(bool b);
2011-01-16 11:35:12 +01:00
/** Backtrace of the command that created this custom command. */
cmListFileBacktrace const& GetBacktrace() const;
2022-03-29 21:10:50 +02:00
void SetBacktrace(cmListFileBacktrace lfbt);
2011-01-16 11:35:12 +01:00
2020-02-01 23:06:01 +01:00
void SetImplicitDepends(cmImplicitDependsList const&);
void AppendImplicitDepends(cmImplicitDependsList const&);
cmImplicitDependsList const& GetImplicitDepends() const;
2015-04-27 22:25:09 +02:00
/** Set/Get whether this custom command should be given access to the
real console (if possible). */
bool GetUsesTerminal() const;
void SetUsesTerminal(bool b);
2017-04-14 19:02:05 +02:00
/** Set/Get whether lists in command lines should be expanded. */
bool GetCommandExpandLists() const;
void SetCommandExpandLists(bool b);
2023-07-02 19:51:09 +02:00
/** Set/Get whether to use additional dependencies coming from
users of OUTPUT of the custom command. */
bool GetDependsExplicitOnly() const;
void SetDependsExplicitOnly(bool b);
2016-10-30 18:24:19 +01:00
/** Set/Get the depfile (used by the Ninja generator) */
const std::string& GetDepfile() const;
void SetDepfile(const std::string& depfile);
2019-11-11 23:01:05 +01:00
/** Set/Get the job_pool (used by the Ninja generator) */
const std::string& GetJobPool() const;
void SetJobPool(const std::string& job_pool);
2023-07-02 19:51:09 +02:00
#define DECLARE_CC_POLICY_ACCESSOR(P) \
cmPolicies::PolicyStatus Get##P##Status() const;
CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_ACCESSOR)
#undef DECLARE_CC_POLICY_ACCESSOR
/** Record policy values from state snapshot */
void RecordPolicyValues(const cmStateSnapshot& snapshot);
2021-09-14 00:13:48 +02:00
/** Set/Get the associated target */
const std::string& GetTarget() const;
void SetTarget(const std::string& target);
private:
std::vector<std::string> Outputs;
2015-04-27 22:25:09 +02:00
std::vector<std::string> Byproducts;
std::vector<std::string> Depends;
cmCustomCommandLines CommandLines;
2015-11-17 17:22:37 +01:00
cmListFileBacktrace Backtrace;
2020-02-01 23:06:01 +01:00
cmImplicitDependsList ImplicitDepends;
2021-09-14 00:13:48 +02:00
std::string Target;
std::string Comment;
std::string WorkingDirectory;
2016-10-30 18:24:19 +01:00
std::string Depfile;
2019-11-11 23:01:05 +01:00
std::string JobPool;
bool HaveComment = false;
bool EscapeAllowMakeVars = false;
bool EscapeOldStyle = true;
bool UsesTerminal = false;
bool CommandExpandLists = false;
2020-08-30 11:54:41 +02:00
bool StdPipesUTF8 = false;
2022-03-29 21:10:50 +02:00
bool HasMainDependency_ = false;
2023-07-02 19:51:09 +02:00
bool DependsExplicitOnly = false;
// Policies are NEW for synthesized custom commands, and set by cmMakefile for
// user-created custom commands.
#define DECLARE_CC_POLICY_FIELD(P) \
cmPolicies::PolicyStatus P##Status = cmPolicies::NEW;
CM_FOR_EACH_CUSTOM_COMMAND_POLICY(DECLARE_CC_POLICY_FIELD)
#undef DECLARE_CC_POLICY_FIELD
};