cleaned up the coding style made ivars private etc

This commit is contained in:
Ken Martin 2001-04-19 13:28:46 -04:00
parent 57c4325c7d
commit 24bce99cbf
10 changed files with 92 additions and 37 deletions

View File

@ -117,7 +117,7 @@ bool cmCablePackageCommand::Invoke(std::vector<std::string>& args)
outputs, m_TargetName.c_str()); outputs, m_TargetName.c_str());
// add the source list to the target // add the source list to the target
m_Makefile->GetTargets()[m_TargetName.c_str()].m_SourceLists.push_back(m_PackageName); m_Makefile->GetTargets()[m_TargetName.c_str()].GetSourceLists().push_back(m_PackageName);
return true; return true;
} }

View File

@ -19,6 +19,11 @@
#include "cmStandardIncludes.h" #include "cmStandardIncludes.h"
class cmMakefile; class cmMakefile;
/** \class cmCustomCommand
* \brief A class to encapsulate a custom command
*
* cmCustomCommand encapsulates the properties of a custom command
*/
class cmCustomCommand class cmCustomCommand
{ {
public: public:
@ -26,8 +31,38 @@ public:
std::vector<std::string> dep, std::vector<std::string> dep,
std::vector<std::string> out); std::vector<std::string> out);
cmCustomCommand(const cmCustomCommand& r); cmCustomCommand(const cmCustomCommand& r);
void ExpandVariables(const cmMakefile &);
/**
* Use the cmMakefile's Expand commands to expand any variables in
* this objects members.
*/
void ExpandVariables(const cmMakefile &);
/**
* Return the name of the source file. I'm not sure if this is a full path or not.
*/
std::string GetSourceName() const {return m_Source;}
void SetSourceName(const char *name) {m_Source = name;}
/**
* Return the command to execute
*/
std::string GetCommand() const {return m_Command;}
void SetCommand(const char *cmd) {m_Command = cmd;}
/**
* Return the vector that holds the list of dependencies
*/
const std::vector<std::string> &GetDepends() const {return m_Depends;}
std::vector<std::string> &GetDepends() {return m_Depends;}
/**
* Return the vector that holds the list of outputs of this command
*/
const std::vector<std::string> &GetOutputs() const {return m_Outputs;}
std::vector<std::string> &GetOutputs() {return m_Outputs;}
private:
std::string m_Source; std::string m_Source;
std::string m_Command; std::string m_Command;
std::vector<std::string> m_Depends; std::vector<std::string> m_Depends;

View File

@ -91,7 +91,7 @@ void cmDSPMakefile::OutputDSPFile()
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (l->second.m_IsALibrary) if (l->second.IsALibrary())
{ {
this->SetBuildType(m_LibraryBuildType, l->first.c_str()); this->SetBuildType(m_LibraryBuildType, l->first.c_str());
} }
@ -196,7 +196,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmClassFile> classes = std::vector<cmClassFile> classes =
m_Makefile->GetClassesFromSourceLists(target.m_SourceLists); m_Makefile->GetClassesFromSourceLists(target.GetSourceLists());
for(std::vector<cmClassFile>::iterator i = classes.begin(); for(std::vector<cmClassFile>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
@ -212,11 +212,11 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// add any custom rules to the source groups // add any custom rules to the source groups
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
target.m_CustomCommands.begin(); target.GetCustomCommands().begin();
cr != target.m_CustomCommands.end(); ++cr) cr != target.GetCustomCommands().end(); ++cr)
{ {
cmSourceGroup& sourceGroup = cmSourceGroup& sourceGroup =
m_Makefile->FindSourceGroup(cr->m_Source.c_str(), m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(),
sourceGroups); sourceGroups);
cmCustomCommand cc(*cr); cmCustomCommand cc(*cr);
cc.ExpandVariables(*m_Makefile); cc.ExpandVariables(*m_Makefile);

View File

@ -91,7 +91,7 @@ void cmDSPMakefile::OutputDSPFile()
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (l->second.m_IsALibrary) if (l->second.IsALibrary())
{ {
this->SetBuildType(m_LibraryBuildType, l->first.c_str()); this->SetBuildType(m_LibraryBuildType, l->first.c_str());
} }
@ -196,7 +196,7 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// get the classes from the source lists then add them to the groups // get the classes from the source lists then add them to the groups
std::vector<cmClassFile> classes = std::vector<cmClassFile> classes =
m_Makefile->GetClassesFromSourceLists(target.m_SourceLists); m_Makefile->GetClassesFromSourceLists(target.GetSourceLists());
for(std::vector<cmClassFile>::iterator i = classes.begin(); for(std::vector<cmClassFile>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
{ {
@ -212,11 +212,11 @@ void cmDSPMakefile::WriteDSPFile(std::ostream& fout,
// add any custom rules to the source groups // add any custom rules to the source groups
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
target.m_CustomCommands.begin(); target.GetCustomCommands().begin();
cr != target.m_CustomCommands.end(); ++cr) cr != target.GetCustomCommands().end(); ++cr)
{ {
cmSourceGroup& sourceGroup = cmSourceGroup& sourceGroup =
m_Makefile->FindSourceGroup(cr->m_Source.c_str(), m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(),
sourceGroups); sourceGroups);
cmCustomCommand cc(*cr); cmCustomCommand cc(*cr);
cc.ExpandVariables(*m_Makefile); cc.ExpandVariables(*m_Makefile);

View File

@ -134,7 +134,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
{ {
if(*i != dspname) if(*i != dspname)
{ {
if (!l.m_IsALibrary || if (!l.IsALibrary() ||
project->GetLibraryBuildType() == cmDSPMakefile::DLL) project->GetLibraryBuildType() == cmDSPMakefile::DLL)
{ {
fout << "Begin Project Dependency\n"; fout << "Begin Project Dependency\n";

View File

@ -134,7 +134,7 @@ void cmDSWMakefile::WriteProject(std::ostream& fout,
{ {
if(*i != dspname) if(*i != dspname)
{ {
if (!l.m_IsALibrary || if (!l.IsALibrary() ||
project->GetLibraryBuildType() == cmDSPMakefile::DLL) project->GetLibraryBuildType() == cmDSPMakefile::DLL)
{ {
fout << "Begin Project Dependency\n"; fout << "Begin Project Dependency\n";

View File

@ -304,7 +304,7 @@ void cmMakefile::AddCustomCommand(const char* source,
if (m_Targets.find(target) != m_Targets.end()) if (m_Targets.find(target) != m_Targets.end())
{ {
cmCustomCommand cc(source,command,depends,outputs); cmCustomCommand cc(source,command,depends,outputs);
m_Targets[target].m_CustomCommands.push_back(cc); m_Targets[target].GetCustomCommands().push_back(cc);
} }
} }
@ -368,8 +368,8 @@ void cmMakefile::SetProjectName(const char* p)
void cmMakefile::AddLibrary(const char* lname, const std::vector<std::string> &srcs) void cmMakefile::AddLibrary(const char* lname, const std::vector<std::string> &srcs)
{ {
cmTarget target; cmTarget target;
target.m_IsALibrary = 1; target.SetIsALibrary(1);
target.m_SourceLists = srcs; target.GetSourceLists() = srcs;
m_Targets.insert(cmTargets::value_type(lname,target)); m_Targets.insert(cmTargets::value_type(lname,target));
} }
@ -377,8 +377,8 @@ void cmMakefile::AddExecutable(const char *exeName,
const std::vector<std::string> &srcs) const std::vector<std::string> &srcs)
{ {
cmTarget target; cmTarget target;
target.m_IsALibrary = 0; target.SetIsALibrary(0);
target.m_SourceLists = srcs; target.GetSourceLists() = srcs;
m_Targets.insert(cmTargets::value_type(exeName,target)); m_Targets.insert(cmTargets::value_type(exeName,target));
} }

View File

@ -55,30 +55,30 @@ bool cmSourceGroup::Matches(const char* name)
*/ */
void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd) void cmSourceGroup::AddCustomCommand(const cmCustomCommand &cmd)
{ {
CustomCommands::iterator s = m_CustomCommands.find(cmd.m_Source); CustomCommands::iterator s = m_CustomCommands.find(cmd.GetSourceName());
if(s == m_CustomCommands.end()) if(s == m_CustomCommands.end())
{ {
// The source was not found. Add it with this command. // The source was not found. Add it with this command.
m_CustomCommands[cmd.m_Source][cmd.m_Command]. m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()].
m_Depends.insert(cmd.m_Depends.begin(),cmd.m_Depends.end()); m_Depends.insert(cmd.GetDepends().begin(),cmd.GetDepends().end());
m_CustomCommands[cmd.m_Source][cmd.m_Command]. m_CustomCommands[cmd.GetSourceName()][cmd.GetCommand()].
m_Outputs.insert(cmd.m_Outputs.begin(),cmd.m_Outputs.end()); m_Outputs.insert(cmd.GetOutputs().begin(),cmd.GetOutputs().end());
return; return;
} }
// The source already exists. See if the command exists. // The source already exists. See if the command exists.
Commands& commands = s->second; Commands& commands = s->second;
Commands::iterator c = commands.find(cmd.m_Command); Commands::iterator c = commands.find(cmd.GetCommand());
if(c == commands.end()) if(c == commands.end())
{ {
// The command did not exist. Add it. // The command did not exist. Add it.
commands[cmd.m_Command].m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end()); commands[cmd.GetCommand()].m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
commands[cmd.m_Command].m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end()); commands[cmd.GetCommand()].m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
return; return;
} }
// The command already exists for this source. Merge the sets. // The command already exists for this source. Merge the sets.
CommandFiles& commandFiles = c->second; CommandFiles& commandFiles = c->second;
commandFiles.m_Depends.insert(cmd.m_Depends.begin(), cmd.m_Depends.end()); commandFiles.m_Depends.insert(cmd.GetDepends().begin(), cmd.GetDepends().end());
commandFiles.m_Outputs.insert(cmd.m_Outputs.begin(), cmd.m_Outputs.end()); commandFiles.m_Outputs.insert(cmd.GetOutputs().begin(), cmd.GetOutputs().end());
} }

View File

@ -28,9 +28,29 @@
class cmTarget class cmTarget
{ {
public: public:
/**
* is this target a library?
*/
bool IsALibrary() const { return m_IsALibrary; }
bool GetIsALibrary() const { return m_IsALibrary; }
void SetIsALibrary(bool f) { m_IsALibrary = f; }
/**
* Get the list of the custom commands for this target
*/
const std::vector<cmCustomCommand> &GetCustomCommands() const {return m_CustomCommands;}
std::vector<cmCustomCommand> &GetCustomCommands() {return m_CustomCommands;}
/**
* Get the list of the source lists used by this target
*/
const std::vector<std::string> &GetSourceLists() const {return m_SourceLists;}
std::vector<std::string> &GetSourceLists() {return m_SourceLists;}
private:
std::vector<cmCustomCommand> m_CustomCommands; std::vector<cmCustomCommand> m_CustomCommands;
bool m_IsALibrary;
std::vector<std::string> m_SourceLists; std::vector<std::string> m_SourceLists;
bool m_IsALibrary;
}; };
typedef std::map<std::string,cmTarget> cmTargets; typedef std::map<std::string,cmTarget> cmTargets;

View File

@ -74,7 +74,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (l->second.m_IsALibrary) if (l->second.IsALibrary())
{ {
fout << " \\\nlib" << l->first.c_str() << "${CMAKE_LIB_EXT}"; fout << " \\\nlib" << l->first.c_str() << "${CMAKE_LIB_EXT}";
} }
@ -83,7 +83,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (!l->second.m_IsALibrary) if (!l->second.IsALibrary())
{ {
fout << "\\\n" << l->first.c_str(); fout << "\\\n" << l->first.c_str();
} }
@ -95,7 +95,7 @@ void cmUnixMakefileGenerator::OutputTargetRules(std::ostream& fout)
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
std::vector<cmClassFile> classes = std::vector<cmClassFile> classes =
m_Makefile->GetClassesFromSourceLists(l->second.m_SourceLists); m_Makefile->GetClassesFromSourceLists(l->second.GetSourceLists());
fout << l->first << "_SRC_OBJS = "; fout << l->first << "_SRC_OBJS = ";
for(std::vector<cmClassFile>::iterator i = classes.begin(); for(std::vector<cmClassFile>::iterator i = classes.begin();
i != classes.end(); i++) i != classes.end(); i++)
@ -174,7 +174,7 @@ void cmUnixMakefileGenerator::OutputTargets(std::ostream& fout)
for(cmTargets::const_iterator l = tgts.begin(); for(cmTargets::const_iterator l = tgts.begin();
l != tgts.end(); l++) l != tgts.end(); l++)
{ {
if (l->second.m_IsALibrary) if (l->second.IsALibrary())
{ {
fout << "#---------------------------------------------------------\n"; fout << "#---------------------------------------------------------\n";
fout << "# rules for a library\n"; fout << "# rules for a library\n";
@ -432,11 +432,11 @@ void cmUnixMakefileGenerator::OutputCustomRules(std::ostream& fout)
{ {
// add any custom rules to the source groups // add any custom rules to the source groups
for (std::vector<cmCustomCommand>::const_iterator cr = for (std::vector<cmCustomCommand>::const_iterator cr =
tgt->second.m_CustomCommands.begin(); tgt->second.GetCustomCommands().begin();
cr != tgt->second.m_CustomCommands.end(); ++cr) cr != tgt->second.GetCustomCommands().end(); ++cr)
{ {
cmSourceGroup& sourceGroup = cmSourceGroup& sourceGroup =
m_Makefile->FindSourceGroup(cr->m_Source.c_str(), m_Makefile->FindSourceGroup(cr->GetSourceName().c_str(),
sourceGroups); sourceGroups);
cmCustomCommand cc(*cr); cmCustomCommand cc(*cr);
cc.ExpandVariables(*m_Makefile); cc.ExpandVariables(*m_Makefile);