summaryrefslogtreecommitdiffstats
path: root/Source/cmCMakePresetsGraph.h
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2021-12-21 22:12:51 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2022-01-07 00:46:41 (GMT)
commita239f23a987a063852c8f29040ef4eaeaebf3b9c (patch)
tree1130ca42122ad547cd706803e8e48a3d35065eb5 /Source/cmCMakePresetsGraph.h
parent84d440caace3f65ef6ddd197098f8d83c0ecef70 (diff)
downloadCMake-a239f23a987a063852c8f29040ef4eaeaebf3b9c.zip
CMake-a239f23a987a063852c8f29040ef4eaeaebf3b9c.tar.gz
CMake-a239f23a987a063852c8f29040ef4eaeaebf3b9c.tar.bz2
Refactor: Generalize file graph in CMakePresets
Before this refactoring, presets had a simple flag that marked them as "user" or "not user", and checking the file graph of two files was as simple as checking this flag. This only allowed for two files in the graph. Generalize the code to allow for arbitrarily many files in the graph.
Diffstat (limited to 'Source/cmCMakePresetsGraph.h')
-rw-r--r--Source/cmCMakePresetsGraph.h37
1 files changed, 31 insertions, 6 deletions
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index 937b281..c27a611 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -8,6 +8,7 @@
#include <map>
#include <memory>
#include <string>
+#include <unordered_set>
#include <utility>
#include <vector>
@@ -32,7 +33,7 @@ public:
INVALID_VARIABLE,
DUPLICATE_PRESETS,
CYCLIC_PRESET_INHERITANCE,
- USER_PRESET_INHERITANCE,
+ PRESET_UNREACHABLE_FROM_FILE,
INVALID_MACRO_EXPANSION,
BUILD_TEST_PRESETS_UNSUPPORTED,
INVALID_CONFIGURE_PRESET,
@@ -40,6 +41,7 @@ public:
INVALID_CONDITION,
CONDITION_UNSUPPORTED,
TOOLCHAIN_FILE_UNSUPPORTED,
+ CYCLIC_INCLUDE,
};
enum class ArchToolsetStrategy
@@ -57,6 +59,15 @@ public:
class Condition;
+ class File
+ {
+ public:
+ std::string Filename;
+ int Version;
+
+ std::unordered_set<File*> ReachableFiles;
+ };
+
class Preset
{
public:
@@ -77,7 +88,7 @@ public:
std::string Name;
std::vector<std::string> Inherits;
bool Hidden;
- bool User;
+ File* OriginFile;
std::string DisplayName;
std::string Description;
@@ -321,12 +332,11 @@ public:
std::vector<std::string> TestPresetOrder;
std::string SourceDir;
- int Version;
- int UserVersion;
+ std::vector<std::unique_ptr<File>> Files;
int GetVersion(const Preset& preset) const
{
- return preset.User ? this->UserVersion : this->Version;
+ return preset.OriginFile->Version;
}
static std::string GetFilename(const std::string& sourceDir);
@@ -372,7 +382,22 @@ public:
void PrintAllPresets() const;
private:
+ enum class RootType
+ {
+ Project,
+ User,
+ };
+
+ enum class ReadReason
+ {
+ Root,
+ Included,
+ };
+
ReadFileResult ReadProjectPresetsInternal(bool allowNoFiles);
- ReadFileResult ReadJSONFile(const std::string& filename, bool user);
+ ReadFileResult ReadJSONFile(const std::string& filename, RootType rootType,
+ ReadReason readReason,
+ std::vector<File*>& inProgressFiles,
+ File*& file);
void ClearPresets();
};