Add support of custom rules

Fixes: #27383
This commit is contained in:
Marc Chevrier
2026-09-20 11:43:10 +02:00
parent 08bde1b972
commit 386d1d874c
254 changed files with 4454 additions and 126 deletions
+20
View File
@@ -57,6 +57,8 @@ class cmExternalMakefileProjectGenerator;
class cmBuildSbomGenerator;
class cmInstallSbomGenerator;
class cmGeneratorTarget;
class cmRule;
class cmGeneratorRule;
class cmInstallRuntimeDependencySet;
class cmLinkLineComputer;
class cmMakefile;
@@ -178,6 +180,9 @@ public:
virtual bool InspectConfigTypeVariables() { return true; }
// Produce custom commands for file sets attached to a custom rule
void CreateCustomCommandsFromRules();
enum class CxxModuleSupportQuery
{
// Support is expected at the call site.
@@ -412,6 +417,10 @@ public:
void AddAlias(std::string const& name, std::string const& tgtName);
bool IsAlias(std::string const& name) const;
//! Find a rule by name.
cmRule* FindRule(std::string const& name) const;
cmGeneratorRule* FindGeneratorRule(std::string const& name) const;
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
bool NameResolvesToFramework(std::string const& libname) const;
@@ -532,6 +541,9 @@ public:
virtual char const* GetRebuildCacheTargetName() const { return nullptr; }
virtual char const* GetCleanTargetName() const { return nullptr; }
void IndexRule(cmRule* rule);
void IndexGeneratorRule(cmGeneratorRule* gt);
// Lookup edit_cache target command preferred by this generator.
virtual std::string GetEditCacheCommand() const { return ""; }
@@ -896,6 +908,8 @@ private:
using TargetMap = std::unordered_map<std::string, cmTarget*>;
using GeneratorTargetMap =
std::unordered_map<std::string, cmGeneratorTarget*>;
using RuleMap = std::unordered_map<std::string, cmRule*>;
using GeneratorRuleMap = std::unordered_map<std::string, cmGeneratorRule*>;
using MakefileMap = std::unordered_map<std::string, cmMakefile*>;
using LocalGeneratorMap = std::unordered_map<std::string, cmLocalGenerator*>;
using TargetDirectoryRegistrationMap =
@@ -913,6 +927,12 @@ private:
// Map from target directories to targets using it.
mutable TargetDirectoryMap TargetDirectories;
// Map efficiently from rule name to cmRule instance.
// Do not use this structure for looping over all rules.
// It may not contain all of them.
RuleMap RuleSearchIndex;
GeneratorRuleMap GeneratorRuleSearchIndex;
// Map efficiently from source directory path to cmMakefile instance.
// Do not use this structure for looping over all directories.
// It may not contain all of them (see note in IndexMakefile method).