Source: Add cmInstallRuntimeDependencySet
parent
9f6cfe7169
commit
f2617cf8e6
|
@ -352,6 +352,8 @@ set(SRCS
|
|||
cmInstallFilesGenerator.cxx
|
||||
cmInstallImportedRuntimeArtifactsGenerator.h
|
||||
cmInstallImportedRuntimeArtifactsGenerator.cxx
|
||||
cmInstallRuntimeDependencySet.h
|
||||
cmInstallRuntimeDependencySet.cxx
|
||||
cmInstallScriptGenerator.h
|
||||
cmInstallScriptGenerator.cxx
|
||||
cmInstallSubdirectoryGenerator.h
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "cmGeneratorExpression.h"
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmInstallGenerator.h"
|
||||
#include "cmInstallRuntimeDependencySet.h"
|
||||
#include "cmLinkLineComputer.h"
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
|
@ -3332,3 +3333,26 @@ bool cmGlobalGenerator::GenerateCPackPropertiesFile()
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
cmInstallRuntimeDependencySet*
|
||||
cmGlobalGenerator::CreateAnonymousRuntimeDependencySet()
|
||||
{
|
||||
auto set = cm::make_unique<cmInstallRuntimeDependencySet>();
|
||||
auto* retval = set.get();
|
||||
this->RuntimeDependencySets.push_back(std::move(set));
|
||||
return retval;
|
||||
}
|
||||
|
||||
cmInstallRuntimeDependencySet* cmGlobalGenerator::GetNamedRuntimeDependencySet(
|
||||
const std::string& name)
|
||||
{
|
||||
auto it = this->RuntimeDependencySetsByName.find(name);
|
||||
if (it == this->RuntimeDependencySetsByName.end()) {
|
||||
auto set = cm::make_unique<cmInstallRuntimeDependencySet>(name);
|
||||
it =
|
||||
this->RuntimeDependencySetsByName.insert(std::make_pair(name, set.get()))
|
||||
.first;
|
||||
this->RuntimeDependencySets.push_back(std::move(set));
|
||||
}
|
||||
return it->second;
|
||||
}
|
||||
|
|
|
@ -42,6 +42,7 @@ class cmDirectoryId;
|
|||
class cmExportBuildFileGenerator;
|
||||
class cmExternalMakefileProjectGenerator;
|
||||
class cmGeneratorTarget;
|
||||
class cmInstallRuntimeDependencySet;
|
||||
class cmLinkLineComputer;
|
||||
class cmLocalGenerator;
|
||||
class cmMakefile;
|
||||
|
@ -528,6 +529,11 @@ public:
|
|||
|
||||
std::string NewDeferId();
|
||||
|
||||
cmInstallRuntimeDependencySet* CreateAnonymousRuntimeDependencySet();
|
||||
|
||||
cmInstallRuntimeDependencySet* GetNamedRuntimeDependencySet(
|
||||
const std::string& name);
|
||||
|
||||
protected:
|
||||
// for a project collect all its targets by following depend
|
||||
// information, and also collect all the targets
|
||||
|
@ -747,6 +753,11 @@ private:
|
|||
|
||||
std::unordered_set<std::string> GeneratedFiles;
|
||||
|
||||
std::vector<std::unique_ptr<cmInstallRuntimeDependencySet>>
|
||||
RuntimeDependencySets;
|
||||
std::map<std::string, cmInstallRuntimeDependencySet*>
|
||||
RuntimeDependencySetsByName;
|
||||
|
||||
#if !defined(CMAKE_BOOTSTRAP)
|
||||
// Pool of file locks
|
||||
cmFileLockPool FileLockPool;
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmInstallRuntimeDependencySet.h"
|
||||
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "cmGeneratorTarget.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmInstallImportedRuntimeArtifactsGenerator.h"
|
||||
#include "cmInstallTargetGenerator.h"
|
||||
#include "cmStateTypes.h"
|
||||
#include "cmTargetDepend.h"
|
||||
|
||||
cmInstallRuntimeDependencySet::cmInstallRuntimeDependencySet(std::string name)
|
||||
: Name(std::move(name))
|
||||
{
|
||||
}
|
||||
|
||||
void cmInstallRuntimeDependencySet::AddExecutable(
|
||||
std::unique_ptr<Item> executable)
|
||||
{
|
||||
this->Executables.push_back(std::move(executable));
|
||||
}
|
||||
|
||||
void cmInstallRuntimeDependencySet::AddLibrary(std::unique_ptr<Item> library)
|
||||
{
|
||||
this->Libraries.push_back(std::move(library));
|
||||
}
|
||||
|
||||
void cmInstallRuntimeDependencySet::AddModule(std::unique_ptr<Item> module)
|
||||
{
|
||||
this->Modules.push_back(std::move(module));
|
||||
}
|
||||
|
||||
bool cmInstallRuntimeDependencySet::AddBundleExecutable(
|
||||
std::unique_ptr<Item> bundleExecutable)
|
||||
{
|
||||
if (this->BundleExecutable) {
|
||||
return false;
|
||||
}
|
||||
this->BundleExecutable = bundleExecutable.get();
|
||||
this->AddExecutable(std::move(bundleExecutable));
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string cmInstallRuntimeDependencySet::TargetItem::GetItemPath(
|
||||
const std::string& config) const
|
||||
{
|
||||
return this->Target->GetTarget()->GetFullPath(config);
|
||||
}
|
||||
|
||||
namespace {
|
||||
const std::set<const cmGeneratorTarget*>& GetTargetDependsClosure(
|
||||
std::map<const cmGeneratorTarget*, std::set<const cmGeneratorTarget*>>&
|
||||
targetDepends,
|
||||
const cmGeneratorTarget* tgt)
|
||||
{
|
||||
auto it = targetDepends.insert({ tgt, {} });
|
||||
auto& retval = it.first->second;
|
||||
if (it.second) {
|
||||
auto const& deps = tgt->GetGlobalGenerator()->GetTargetDirectDepends(tgt);
|
||||
for (auto const& dep : deps) {
|
||||
if (!dep.IsCross() && dep.IsLink()) {
|
||||
auto type = dep->GetType();
|
||||
if (type == cmStateEnums::EXECUTABLE ||
|
||||
type == cmStateEnums::SHARED_LIBRARY ||
|
||||
type == cmStateEnums::MODULE_LIBRARY) {
|
||||
retval.insert(dep);
|
||||
}
|
||||
auto const& depDeps = GetTargetDependsClosure(targetDepends, dep);
|
||||
retval.insert(depDeps.begin(), depDeps.end());
|
||||
}
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
}
|
||||
|
||||
void cmInstallRuntimeDependencySet::TargetItem::AddPostExcludeFiles(
|
||||
const std::string& config, std::set<std::string>& files,
|
||||
cmInstallRuntimeDependencySet* set) const
|
||||
{
|
||||
for (auto const* dep : GetTargetDependsClosure(set->TargetDepends,
|
||||
this->Target->GetTarget())) {
|
||||
files.insert(dep->GetFullPath(config));
|
||||
}
|
||||
}
|
||||
|
||||
std::string cmInstallRuntimeDependencySet::ImportedTargetItem::GetItemPath(
|
||||
const std::string& config) const
|
||||
{
|
||||
return this->Target->GetTarget()->GetFullPath(config);
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#pragma once
|
||||
|
||||
#include <map>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <cm/memory>
|
||||
#include <cm/string_view>
|
||||
#include <cmext/string_view>
|
||||
|
||||
class cmGeneratorTarget;
|
||||
class cmInstallImportedRuntimeArtifactsGenerator;
|
||||
class cmInstallTargetGenerator;
|
||||
|
||||
class cmInstallRuntimeDependencySet
|
||||
{
|
||||
public:
|
||||
cmInstallRuntimeDependencySet(std::string name = "");
|
||||
|
||||
cmInstallRuntimeDependencySet(const cmInstallRuntimeDependencySet&) = delete;
|
||||
cmInstallRuntimeDependencySet& operator=(
|
||||
const cmInstallRuntimeDependencySet&) = delete;
|
||||
|
||||
cm::string_view GetName() const { return this->Name; }
|
||||
|
||||
cm::string_view GetDisplayName() const
|
||||
{
|
||||
if (this->Name.empty()) {
|
||||
return "<anonymous>"_s;
|
||||
}
|
||||
return this->Name;
|
||||
}
|
||||
|
||||
class Item
|
||||
{
|
||||
public:
|
||||
virtual ~Item() = default;
|
||||
|
||||
virtual std::string GetItemPath(const std::string& config) const = 0;
|
||||
|
||||
virtual void AddPostExcludeFiles(
|
||||
const std::string& /*config*/, std::set<std::string>& /*files*/,
|
||||
cmInstallRuntimeDependencySet* /*set*/) const
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
class TargetItem : public Item
|
||||
{
|
||||
public:
|
||||
TargetItem(cmInstallTargetGenerator* target)
|
||||
: Target(target)
|
||||
{
|
||||
}
|
||||
|
||||
std::string GetItemPath(const std::string& config) const override;
|
||||
|
||||
void AddPostExcludeFiles(
|
||||
const std::string& config, std::set<std::string>& files,
|
||||
cmInstallRuntimeDependencySet* set) const override;
|
||||
|
||||
private:
|
||||
cmInstallTargetGenerator* Target;
|
||||
};
|
||||
|
||||
class ImportedTargetItem : public Item
|
||||
{
|
||||
public:
|
||||
ImportedTargetItem(cmInstallImportedRuntimeArtifactsGenerator* target)
|
||||
: Target(target)
|
||||
{
|
||||
}
|
||||
|
||||
std::string GetItemPath(const std::string& config) const override;
|
||||
|
||||
private:
|
||||
cmInstallImportedRuntimeArtifactsGenerator* Target;
|
||||
};
|
||||
|
||||
void AddExecutable(std::unique_ptr<Item> executable);
|
||||
void AddLibrary(std::unique_ptr<Item> library);
|
||||
void AddModule(std::unique_ptr<Item> module);
|
||||
bool AddBundleExecutable(std::unique_ptr<Item> bundleExecutable);
|
||||
|
||||
void AddExecutable(cmInstallTargetGenerator* executable)
|
||||
{
|
||||
this->AddExecutable(cm::make_unique<TargetItem>(executable));
|
||||
}
|
||||
|
||||
void AddLibrary(cmInstallTargetGenerator* library)
|
||||
{
|
||||
this->AddLibrary(cm::make_unique<TargetItem>(library));
|
||||
}
|
||||
|
||||
void AddModule(cmInstallTargetGenerator* module)
|
||||
{
|
||||
this->AddModule(cm::make_unique<TargetItem>(module));
|
||||
}
|
||||
|
||||
bool AddBundleExecutable(cmInstallTargetGenerator* bundleExecutable)
|
||||
{
|
||||
return this->AddBundleExecutable(
|
||||
cm::make_unique<TargetItem>(bundleExecutable));
|
||||
}
|
||||
|
||||
void AddExecutable(cmInstallImportedRuntimeArtifactsGenerator* executable)
|
||||
{
|
||||
this->AddExecutable(cm::make_unique<ImportedTargetItem>(executable));
|
||||
}
|
||||
|
||||
void AddLibrary(cmInstallImportedRuntimeArtifactsGenerator* library)
|
||||
{
|
||||
this->AddLibrary(cm::make_unique<ImportedTargetItem>(library));
|
||||
}
|
||||
|
||||
void AddModule(cmInstallImportedRuntimeArtifactsGenerator* module)
|
||||
{
|
||||
this->AddModule(cm::make_unique<ImportedTargetItem>(module));
|
||||
}
|
||||
|
||||
bool AddBundleExecutable(
|
||||
cmInstallImportedRuntimeArtifactsGenerator* bundleExecutable)
|
||||
{
|
||||
return this->AddBundleExecutable(
|
||||
cm::make_unique<ImportedTargetItem>(bundleExecutable));
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<Item>>& GetExecutables() const
|
||||
{
|
||||
return this->Executables;
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<Item>>& GetLibraries() const
|
||||
{
|
||||
return this->Libraries;
|
||||
}
|
||||
|
||||
const std::vector<std::unique_ptr<Item>>& GetModules() const
|
||||
{
|
||||
return this->Modules;
|
||||
}
|
||||
|
||||
Item* GetBundleExecutable() const { return this->BundleExecutable; }
|
||||
|
||||
bool Empty() const
|
||||
{
|
||||
return this->Executables.empty() && this->Libraries.empty() &&
|
||||
this->Modules.empty();
|
||||
}
|
||||
|
||||
private:
|
||||
std::string Name;
|
||||
std::vector<std::unique_ptr<Item>> Executables;
|
||||
std::vector<std::unique_ptr<Item>> Libraries;
|
||||
std::vector<std::unique_ptr<Item>> Modules;
|
||||
Item* BundleExecutable = nullptr;
|
||||
|
||||
std::map<const cmGeneratorTarget*, std::set<const cmGeneratorTarget*>>
|
||||
TargetDepends;
|
||||
};
|
Loading…
Reference in New Issue