mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-19 11:18:40 +08:00
cmGlobCacheEntry: Add helper to carry CONFIGURE_DEPENDS glob cache arguments
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include <cm3p/json/value.h>
|
||||
|
||||
#include "cmFileAPI.h"
|
||||
#include "cmGlobCacheEntry.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
|
@@ -41,6 +41,7 @@
|
||||
#include "cmFileTimes.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGlobCacheEntry.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmHexFileConverter.h"
|
||||
#include "cmList.h"
|
||||
@@ -810,11 +811,16 @@ bool HandleGlobImpl(std::vector<std::string> const& args, bool recurse,
|
||||
std::sort(foundFiles.begin(), foundFiles.end());
|
||||
foundFiles.erase(std::unique(foundFiles.begin(), foundFiles.end()),
|
||||
foundFiles.end());
|
||||
cm->AddGlobCacheEntry(
|
||||
recurse, (recurse ? g.GetRecurseListDirs() : g.GetListDirs()),
|
||||
auto entry = cmGlobCacheEntry{
|
||||
recurse,
|
||||
(recurse ? g.GetRecurseListDirs() : g.GetListDirs()),
|
||||
(recurse ? g.GetRecurseThroughSymlinks() : false),
|
||||
(g.GetRelative() ? g.GetRelative() : ""), expr, foundFiles, variable,
|
||||
status.GetMakefile().GetBacktrace());
|
||||
(g.GetRelative() ? g.GetRelative() : ""),
|
||||
expr,
|
||||
foundFiles
|
||||
};
|
||||
cm->AddGlobCacheEntry(entry, variable,
|
||||
status.GetMakefile().GetBacktrace());
|
||||
} else {
|
||||
warnConfigureLate = true;
|
||||
}
|
||||
|
30
Source/cmGlobCacheEntry.h
Normal file
30
Source/cmGlobCacheEntry.h
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
struct cmGlobCacheEntry
|
||||
{
|
||||
const bool Recurse;
|
||||
const bool ListDirectories;
|
||||
const bool FollowSymlinks;
|
||||
const std::string Relative;
|
||||
const std::string Expression;
|
||||
std::vector<std::string> Files;
|
||||
|
||||
cmGlobCacheEntry(bool recurse, bool listDirectories, bool followSymlinks,
|
||||
std::string relative, std::string expression,
|
||||
std::vector<std::string> files)
|
||||
: Recurse(recurse)
|
||||
, ListDirectories(listDirectories)
|
||||
, FollowSymlinks(followSymlinks)
|
||||
, Relative(std::move(relative))
|
||||
, Expression(std::move(expression))
|
||||
, Files(std::move(files))
|
||||
{
|
||||
}
|
||||
};
|
@@ -7,6 +7,7 @@
|
||||
#include "cmsys/FStream.hxx"
|
||||
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGlobCacheEntry.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmMessageType.h"
|
||||
#include "cmMessenger.h"
|
||||
@@ -145,19 +146,18 @@ void cmGlobVerificationManager::CacheEntryKey::PrintGlobCommand(
|
||||
}
|
||||
|
||||
void cmGlobVerificationManager::AddCacheEntry(
|
||||
const bool recurse, const bool listDirectories, const bool followSymlinks,
|
||||
const std::string& relative, const std::string& expression,
|
||||
const std::vector<std::string>& files, const std::string& variable,
|
||||
const cmGlobCacheEntry& entry, const std::string& variable,
|
||||
const cmListFileBacktrace& backtrace, cmMessenger* messenger)
|
||||
{
|
||||
CacheEntryKey key = CacheEntryKey(recurse, listDirectories, followSymlinks,
|
||||
relative, expression);
|
||||
CacheEntryKey key =
|
||||
CacheEntryKey(entry.Recurse, entry.ListDirectories, entry.FollowSymlinks,
|
||||
entry.Relative, entry.Expression);
|
||||
CacheEntryValue& value = this->Cache[key];
|
||||
if (!value.Initialized) {
|
||||
value.Files = files;
|
||||
value.Files = entry.Files;
|
||||
value.Initialized = true;
|
||||
value.Backtraces.emplace_back(variable, backtrace);
|
||||
} else if (value.Initialized && value.Files != files) {
|
||||
} else if (value.Initialized && value.Files != entry.Files) {
|
||||
std::ostringstream message;
|
||||
message << std::boolalpha;
|
||||
message << "The glob expression\n ";
|
||||
|
@@ -13,6 +13,7 @@
|
||||
#include "cmListFileCache.h"
|
||||
|
||||
class cmMessenger;
|
||||
struct cmGlobCacheEntry;
|
||||
|
||||
/** \class cmGlobVerificationManager
|
||||
* \brief Class for expressing build-time dependencies on glob expressions.
|
||||
@@ -28,10 +29,7 @@ protected:
|
||||
bool SaveVerificationScript(const std::string& path, cmMessenger* messenger);
|
||||
|
||||
//! Add an entry into the glob cache
|
||||
void AddCacheEntry(bool recurse, bool listDirectories, bool followSymlinks,
|
||||
const std::string& relative,
|
||||
const std::string& expression,
|
||||
const std::vector<std::string>& files,
|
||||
void AddCacheEntry(const cmGlobCacheEntry& entry,
|
||||
const std::string& variable,
|
||||
const cmListFileBacktrace& bt, cmMessenger* messenger);
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
#include "cmCommand.h"
|
||||
#include "cmDefinitions.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmGlobCacheEntry.h"
|
||||
#include "cmGlobVerificationManager.h"
|
||||
#include "cmList.h"
|
||||
#include "cmListFileCache.h"
|
||||
@@ -238,15 +239,13 @@ bool cmState::SaveVerificationScript(const std::string& path,
|
||||
messenger);
|
||||
}
|
||||
|
||||
void cmState::AddGlobCacheEntry(
|
||||
bool recurse, bool listDirectories, bool followSymlinks,
|
||||
const std::string& relative, const std::string& expression,
|
||||
const std::vector<std::string>& files, const std::string& variable,
|
||||
cmListFileBacktrace const& backtrace, cmMessenger* messenger)
|
||||
void cmState::AddGlobCacheEntry(const cmGlobCacheEntry& entry,
|
||||
const std::string& variable,
|
||||
cmListFileBacktrace const& backtrace,
|
||||
cmMessenger* messenger)
|
||||
{
|
||||
this->GlobVerificationManager->AddCacheEntry(
|
||||
recurse, listDirectories, followSymlinks, relative, expression, files,
|
||||
variable, backtrace, messenger);
|
||||
this->GlobVerificationManager->AddCacheEntry(entry, variable, backtrace,
|
||||
messenger);
|
||||
}
|
||||
|
||||
void cmState::RemoveCacheEntry(std::string const& key)
|
||||
|
@@ -34,6 +34,7 @@ class cmStateSnapshot;
|
||||
class cmMessenger;
|
||||
class cmExecutionStatus;
|
||||
class cmListFileBacktrace;
|
||||
struct cmGlobCacheEntry;
|
||||
struct cmListFileArgument;
|
||||
|
||||
template <typename T>
|
||||
@@ -263,10 +264,7 @@ private:
|
||||
std::string const& GetGlobVerifyScript() const;
|
||||
std::string const& GetGlobVerifyStamp() const;
|
||||
bool SaveVerificationScript(const std::string& path, cmMessenger* messenger);
|
||||
void AddGlobCacheEntry(bool recurse, bool listDirectories,
|
||||
bool followSymlinks, const std::string& relative,
|
||||
const std::string& expression,
|
||||
const std::vector<std::string>& files,
|
||||
void AddGlobCacheEntry(const cmGlobCacheEntry& entry,
|
||||
const std::string& variable,
|
||||
cmListFileBacktrace const& bt,
|
||||
cmMessenger* messenger);
|
||||
|
@@ -48,6 +48,7 @@
|
||||
#include "cmExternalMakefileProjectGenerator.h"
|
||||
#include "cmFileTimeCache.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobCacheEntry.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmGlobalGeneratorFactory.h"
|
||||
#include "cmLinkLineComputer.h"
|
||||
@@ -2949,16 +2950,12 @@ std::string const& cmake::GetGlobVerifyStamp() const
|
||||
return this->State->GetGlobVerifyStamp();
|
||||
}
|
||||
|
||||
void cmake::AddGlobCacheEntry(bool recurse, bool listDirectories,
|
||||
bool followSymlinks, const std::string& relative,
|
||||
const std::string& expression,
|
||||
const std::vector<std::string>& files,
|
||||
void cmake::AddGlobCacheEntry(const cmGlobCacheEntry& entry,
|
||||
const std::string& variable,
|
||||
cmListFileBacktrace const& backtrace)
|
||||
{
|
||||
this->State->AddGlobCacheEntry(recurse, listDirectories, followSymlinks,
|
||||
relative, expression, files, variable,
|
||||
backtrace, this->Messenger.get());
|
||||
this->State->AddGlobCacheEntry(entry, variable, backtrace,
|
||||
this->Messenger.get());
|
||||
}
|
||||
|
||||
std::vector<std::string> cmake::GetAllExtensions() const
|
||||
|
@@ -53,6 +53,7 @@ class cmMakefile;
|
||||
class cmMessenger;
|
||||
class cmVariableWatch;
|
||||
struct cmBuildOptions;
|
||||
struct cmGlobCacheEntry;
|
||||
|
||||
/** \brief Represents a cmake invocation.
|
||||
*
|
||||
@@ -351,10 +352,7 @@ public:
|
||||
bool DoWriteGlobVerifyTarget() const;
|
||||
std::string const& GetGlobVerifyScript() const;
|
||||
std::string const& GetGlobVerifyStamp() const;
|
||||
void AddGlobCacheEntry(bool recurse, bool listDirectories,
|
||||
bool followSymlinks, const std::string& relative,
|
||||
const std::string& expression,
|
||||
const std::vector<std::string>& files,
|
||||
void AddGlobCacheEntry(const cmGlobCacheEntry& entry,
|
||||
const std::string& variable,
|
||||
cmListFileBacktrace const& bt);
|
||||
|
||||
|
Reference in New Issue
Block a user