mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-10 15:50:50 -06:00
cmSourceFile: use unique_ptr for CustomCommand
This commit is contained in:
@@ -15,6 +15,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <utility>
|
||||
|
||||
#include "cm_memory.hxx"
|
||||
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmCommandArgumentParserHelper.h"
|
||||
#include "cmCustomCommand.h"
|
||||
@@ -1025,7 +1027,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
|
||||
depends2.push_back(main_dependency);
|
||||
}
|
||||
|
||||
cmCustomCommand* cc = new cmCustomCommand(
|
||||
std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>(
|
||||
this, outputs, byproducts, depends2, commandLines, comment, workingDir);
|
||||
cc->SetEscapeOldStyle(escapeOldStyle);
|
||||
cc->SetEscapeAllowMakeVars(true);
|
||||
@@ -1033,7 +1035,7 @@ cmSourceFile* cmMakefile::AddCustomCommandToOutput(
|
||||
cc->SetCommandExpandLists(command_expand_lists);
|
||||
cc->SetDepfile(depfile);
|
||||
cc->SetJobPool(job_pool);
|
||||
file->SetCustomCommand(cc);
|
||||
file->SetCustomCommand(std::move(cc));
|
||||
this->UpdateOutputToSourceMap(outputs, file, false);
|
||||
this->UpdateOutputToSourceMap(byproducts, file, true);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <array>
|
||||
#include <utility>
|
||||
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmMessageType.h"
|
||||
@@ -21,11 +20,6 @@ cmSourceFile::cmSourceFile(cmMakefile* mf, const std::string& name,
|
||||
{
|
||||
}
|
||||
|
||||
cmSourceFile::~cmSourceFile()
|
||||
{
|
||||
this->SetCustomCommand(nullptr);
|
||||
}
|
||||
|
||||
std::string const& cmSourceFile::GetExtension() const
|
||||
{
|
||||
return this->Extension;
|
||||
@@ -320,19 +314,12 @@ bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
|
||||
return cmIsOn(this->GetProperty(prop));
|
||||
}
|
||||
|
||||
cmCustomCommand* cmSourceFile::GetCustomCommand()
|
||||
cmCustomCommand* cmSourceFile::GetCustomCommand() const
|
||||
{
|
||||
return this->CustomCommand;
|
||||
return this->CustomCommand.get();
|
||||
}
|
||||
|
||||
cmCustomCommand const* cmSourceFile::GetCustomCommand() const
|
||||
void cmSourceFile::SetCustomCommand(std::unique_ptr<cmCustomCommand> cc)
|
||||
{
|
||||
return this->CustomCommand;
|
||||
}
|
||||
|
||||
void cmSourceFile::SetCustomCommand(cmCustomCommand* cc)
|
||||
{
|
||||
cmCustomCommand* old = this->CustomCommand;
|
||||
this->CustomCommand = cc;
|
||||
delete old;
|
||||
this->CustomCommand = std::move(cc);
|
||||
}
|
||||
|
||||
@@ -5,14 +5,15 @@
|
||||
|
||||
#include "cmConfigure.h" // IWYU pragma: keep
|
||||
|
||||
#include "cmCustomCommand.h"
|
||||
#include "cmPropertyMap.h"
|
||||
#include "cmSourceFileLocation.h"
|
||||
#include "cmSourceFileLocationKind.h"
|
||||
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class cmCustomCommand;
|
||||
class cmMakefile;
|
||||
|
||||
/** \class cmSourceFile
|
||||
@@ -32,17 +33,11 @@ public:
|
||||
cmMakefile* mf, const std::string& name,
|
||||
cmSourceFileLocationKind kind = cmSourceFileLocationKind::Ambiguous);
|
||||
|
||||
~cmSourceFile();
|
||||
|
||||
cmSourceFile(const cmSourceFile&) = delete;
|
||||
cmSourceFile& operator=(const cmSourceFile&) = delete;
|
||||
|
||||
/**
|
||||
* Get the list of the custom commands for this source file
|
||||
* Get the custom command for this source file
|
||||
*/
|
||||
cmCustomCommand* GetCustomCommand();
|
||||
cmCustomCommand const* GetCustomCommand() const;
|
||||
void SetCustomCommand(cmCustomCommand* cc);
|
||||
cmCustomCommand* GetCustomCommand() const;
|
||||
void SetCustomCommand(std::unique_ptr<cmCustomCommand> cc);
|
||||
|
||||
//! Set/Get a property of this source file
|
||||
void SetProperty(const std::string& prop, const char* value);
|
||||
@@ -114,7 +109,7 @@ public:
|
||||
private:
|
||||
cmSourceFileLocation Location;
|
||||
cmPropertyMap Properties;
|
||||
cmCustomCommand* CustomCommand = nullptr;
|
||||
std::unique_ptr<cmCustomCommand> CustomCommand;
|
||||
std::string Extension;
|
||||
std::string Language;
|
||||
std::string FullPath;
|
||||
|
||||
Reference in New Issue
Block a user