summaryrefslogtreecommitdiff
path: root/Source/cmGlobalGenerator.h
diff options
context:
space:
mode:
authorRobert Maynard <robert.maynard@kitware.com>2018-10-30 16:13:33 -0400
committerBrad King <brad.king@kitware.com>2019-01-25 08:20:02 -0500
commit1a45266cb544d73a7d7e46d6129ead1faf71fa85 (patch)
tree3deb468824f493530a91f0da882dafa069921c94 /Source/cmGlobalGenerator.h
parent378473f9f184000cb768c1b99e6242e054787f34 (diff)
downloadcmake-1a45266cb544d73a7d7e46d6129ead1faf71fa85.tar.gz
cmGlobalGenerator: Add a class that represent the build command
This refactors a std::vector<std::string> into a class so that we can extend the features to represent things such as multiple chained commands in the future.
Diffstat (limited to 'Source/cmGlobalGenerator.h')
-rw-r--r--Source/cmGlobalGenerator.h54
1 files changed, 53 insertions, 1 deletions
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 36d3d107e4..ca5708b373 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -41,6 +41,54 @@ class cmSourceFile;
class cmStateDirectory;
class cmake;
+namespace detail {
+inline void AppendStrs(std::vector<std::string>&)
+{
+}
+template <typename T, typename... Ts>
+inline void AppendStrs(std::vector<std::string>& command, T&& s, Ts&&... ts)
+{
+ command.emplace_back(std::forward<T>(s));
+ AppendStrs(command, std::forward<Ts>(ts)...);
+}
+
+struct GeneratedMakeCommand
+{
+ // Add each argument as a separate element to the vector
+ template <typename... T>
+ void add(T&&... args)
+ {
+ // iterate the args and append each one
+ AppendStrs(PrimaryCommand, std::forward<T>(args)...);
+ }
+
+ // Add each value in the iterators as a separate element to the vector
+ void add(std::vector<std::string>::const_iterator start,
+ std::vector<std::string>::const_iterator end)
+ {
+ PrimaryCommand.insert(PrimaryCommand.end(), start, end);
+ }
+
+ std::string printable() const
+ {
+ std::size_t size = PrimaryCommand.size();
+ for (auto&& i : PrimaryCommand) {
+ size += i.size();
+ }
+ std::string buffer;
+ buffer.reserve(size);
+ for (auto&& i : PrimaryCommand) {
+ buffer.append(i);
+ buffer.append(1, ' ');
+ }
+ return buffer;
+ }
+
+ std::vector<std::string> PrimaryCommand;
+ bool RequiresOutputForward = false;
+};
+}
+
/** \class cmGlobalGenerator
* \brief Responsible for overseeing the generation process for the entire tree
*
@@ -182,8 +230,12 @@ public:
virtual bool Open(const std::string& bindir, const std::string& projectName,
bool dryRun);
+ struct GeneratedMakeCommand final : public detail::GeneratedMakeCommand
+ {
+ };
+
virtual void GenerateBuildCommand(
- std::vector<std::string>& makeCommand, const std::string& makeProgram,
+ GeneratedMakeCommand& makeCommand, const std::string& makeProgram,
const std::string& projectName, const std::string& projectDir,
const std::string& targetName, const std::string& config, bool fast,
int jobs, bool verbose,