mirror of
https://github.com/reactos/CMake.git
synced 2025-01-20 02:12:35 +00:00
9b334397f5
This patch is generated by a python script that uses regular expressions to search for string concatenation patterns of the kind ``` std::string str = <ARG0>; str += <ARG1>; str += <ARG2>; ... ``` and replaces them with a single `cmStrCat` call ``` std::string str = cmStrCat(<ARG0>, <ARG1>, <ARG2>, ...); ``` If any `<ARGX>` is itself a concatenated string of the kind ``` a + b + c + ...; ``` then `<ARGX>` is split into multiple arguments for the `cmStrCat` call. If there's a sequence of literals in the `<ARGX>`, then all literals in the sequence are concatenated and merged into a single literal argument for the `cmStrCat` call. Single character strings are converted to single char arguments for the `cmStrCat` call. `std::to_string(...)` wrappings are removed from `cmStrCat` arguments, because it supports numeric types as well as string types. `arg.substr(x)` arguments to `cmStrCat` are replaced with `cm::string_view(arg).substr(x)`
56 lines
1.8 KiB
C++
56 lines
1.8 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
|
#include "cmSubdirCommand.h"
|
|
|
|
#include "cmMakefile.h"
|
|
#include "cmStringAlgorithms.h"
|
|
#include "cmSystemTools.h"
|
|
|
|
class cmExecutionStatus;
|
|
|
|
// cmSubdirCommand
|
|
bool cmSubdirCommand::InitialPass(std::vector<std::string> const& args,
|
|
cmExecutionStatus&)
|
|
{
|
|
if (args.empty()) {
|
|
this->SetError("called with incorrect number of arguments");
|
|
return false;
|
|
}
|
|
bool res = true;
|
|
bool excludeFromAll = false;
|
|
|
|
for (std::string const& i : args) {
|
|
if (i == "EXCLUDE_FROM_ALL") {
|
|
excludeFromAll = true;
|
|
continue;
|
|
}
|
|
if (i == "PREORDER") {
|
|
// Ignored
|
|
continue;
|
|
}
|
|
|
|
// if they specified a relative path then compute the full
|
|
std::string srcPath =
|
|
this->Makefile->GetCurrentSourceDirectory() + "/" + i;
|
|
if (cmSystemTools::FileIsDirectory(srcPath)) {
|
|
std::string binPath =
|
|
this->Makefile->GetCurrentBinaryDirectory() + "/" + i;
|
|
this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, false);
|
|
}
|
|
// otherwise it is a full path
|
|
else if (cmSystemTools::FileIsDirectory(i)) {
|
|
// we must compute the binPath from the srcPath, we just take the last
|
|
// element from the source path and use that
|
|
std::string binPath = this->Makefile->GetCurrentBinaryDirectory() + "/" +
|
|
cmSystemTools::GetFilenameName(i);
|
|
this->Makefile->AddSubDirectory(i, binPath, excludeFromAll, false);
|
|
} else {
|
|
std::string error = cmStrCat("Incorrect SUBDIRS command. Directory: ", i,
|
|
" does not exist.");
|
|
this->SetError(error);
|
|
res = false;
|
|
}
|
|
}
|
|
return res;
|
|
}
|