diff options
-rw-r--r-- | Source/cmLocalCommonGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmLocalCommonGenerator.h | 15 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 2 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.cxx | 14 | ||||
-rw-r--r-- | Source/cmLocalNinjaGenerator.h | 4 | ||||
-rw-r--r-- | Source/cmLocalUnixMakefileGenerator3.cxx | 2 | ||||
-rw-r--r-- | Source/cmOutputConverter.h | 10 |
7 files changed, 32 insertions, 31 deletions
diff --git a/Source/cmLocalCommonGenerator.cxx b/Source/cmLocalCommonGenerator.cxx index eca7a9e..aa953f4 100644 --- a/Source/cmLocalCommonGenerator.cxx +++ b/Source/cmLocalCommonGenerator.cxx @@ -8,7 +8,6 @@ #include "cmGeneratorTarget.h" #include "cmMakefile.h" #include "cmOutputConverter.h" -#include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStringAlgorithms.h" @@ -17,9 +16,8 @@ class cmGlobalGenerator; cmLocalCommonGenerator::cmLocalCommonGenerator(cmGlobalGenerator* gg, - cmMakefile* mf, WorkDir wd) + cmMakefile* mf) : cmLocalGenerator(gg, mf) - , WorkingDirectory(wd) { this->ConfigNames = this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig); @@ -29,21 +27,9 @@ cmLocalCommonGenerator::~cmLocalCommonGenerator() = default; std::string const& cmLocalCommonGenerator::GetWorkingDirectory() const { - if (this->WorkingDirectory == WorkDir::TopBin) { - return this->GetState()->GetBinaryDirectory(); - } return this->StateSnapshot.GetDirectory().GetCurrentBinary(); } -std::string cmLocalCommonGenerator::MaybeRelativeToWorkDir( - std::string const& path) const -{ - if (this->WorkingDirectory == WorkDir::TopBin) { - return this->MaybeRelativeToTopBinDir(path); - } - return this->MaybeRelativeToCurBinDir(path); -} - std::string cmLocalCommonGenerator::GetTargetFortranFlags( cmGeneratorTarget const* target, std::string const& config) { diff --git a/Source/cmLocalCommonGenerator.h b/Source/cmLocalCommonGenerator.h index 0505c13..52f7a9e 100644 --- a/Source/cmLocalCommonGenerator.h +++ b/Source/cmLocalCommonGenerator.h @@ -20,15 +20,8 @@ class cmSourceFile; */ class cmLocalCommonGenerator : public cmLocalGenerator { -protected: - enum class WorkDir - { - TopBin, - CurBin, - }; - public: - cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf, WorkDir wd); + cmLocalCommonGenerator(cmGlobalGenerator* gg, cmMakefile* mf); ~cmLocalCommonGenerator() override; std::vector<std::string> const& GetConfigNames() const @@ -36,9 +29,7 @@ public: return this->ConfigNames; } - std::string const& GetWorkingDirectory() const; - - std::string MaybeRelativeToWorkDir(std::string const& path) const; + virtual std::string const& GetWorkingDirectory() const; std::string GetTargetFortranFlags(cmGeneratorTarget const* target, std::string const& config) override; @@ -48,8 +39,6 @@ public: cmGeneratorTarget const* gt = nullptr) override; protected: - WorkDir WorkingDirectory; - std::vector<std::string> ConfigNames; friend class cmCommonTargetGenerator; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index bda82bc..ea60a4e 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -89,7 +89,7 @@ class cmLocalGenerator : public cmOutputConverter { public: cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile); - virtual ~cmLocalGenerator(); + ~cmLocalGenerator() override; /** * Generate the makefile for this directory. diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index a047233..2e837bb 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -41,7 +41,7 @@ cmLocalNinjaGenerator::cmLocalNinjaGenerator(cmGlobalGenerator* gg, cmMakefile* mf) - : cmLocalCommonGenerator(gg, mf, WorkDir::TopBin) + : cmLocalCommonGenerator(gg, mf) { } @@ -188,6 +188,18 @@ cmGlobalNinjaGenerator* cmLocalNinjaGenerator::GetGlobalNinjaGenerator() return static_cast<cmGlobalNinjaGenerator*>(this->GetGlobalGenerator()); } +std::string const& cmLocalNinjaGenerator::GetWorkingDirectory() const +{ + return this->GetState()->GetBinaryDirectory(); +} + +std::string cmLocalNinjaGenerator::MaybeRelativeToWorkDir( + std::string const& path) const +{ + return this->GetGlobalNinjaGenerator()->NinjaOutputPath( + this->MaybeRelativeToTopBinDir(path)); +} + // Virtual protected methods. std::string cmLocalNinjaGenerator::ConvertToIncludeReference( diff --git a/Source/cmLocalNinjaGenerator.h b/Source/cmLocalNinjaGenerator.h index 4d393d9..347aaa0 100644 --- a/Source/cmLocalNinjaGenerator.h +++ b/Source/cmLocalNinjaGenerator.h @@ -52,6 +52,10 @@ public: const cmake* GetCMakeInstance() const; cmake* GetCMakeInstance(); + std::string const& GetWorkingDirectory() const override; + + std::string MaybeRelativeToWorkDir(std::string const& path) const override; + /// @returns the relative path between the HomeOutputDirectory and this /// local generators StartOutputDirectory. std::string GetHomeRelativeOutputPath() const diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index d8f532f..028066e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -111,7 +111,7 @@ private: cmLocalUnixMakefileGenerator3::cmLocalUnixMakefileGenerator3( cmGlobalGenerator* gg, cmMakefile* mf) - : cmLocalCommonGenerator(gg, mf, WorkDir::CurBin) + : cmLocalCommonGenerator(gg, mf) { this->MakefileVariableSize = 0; this->ColorMakefile = false; diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 2717bdd..625d897 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -16,6 +16,7 @@ class cmOutputConverter { public: cmOutputConverter(cmStateSnapshot const& snapshot); + virtual ~cmOutputConverter() = default; /** * Convert the given remote path to a relative path with respect to @@ -27,6 +28,15 @@ public: std::string MaybeRelativeToTopBinDir(std::string const& path) const; std::string MaybeRelativeToCurBinDir(std::string const& path) const; + /** + * The effective working directory can be different for each generator. + * By default, equivalent to the current binary directory. + */ + virtual std::string MaybeRelativeToWorkDir(std::string const& path) const + { + return this->MaybeRelativeToCurBinDir(path); + } + std::string const& GetRelativePathTopSource() const; std::string const& GetRelativePathTopBinary() const; void SetRelativePathTop(std::string const& topSource, |