cbp2make
Makefile generation tool for Code::Blocks IDE
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CPlatform Class Reference

Contains platform-specific settings and generates commands from templates. More...

#include <platforms.h>

Public Types

enum  OS_Type {
  OS_Other, OS_Unix, OS_Windows, OS_Mac,
  OS_Count
}
 Type of Operating System for a platform. More...
 

Public Member Functions

bool & Active (void)
 Indicates that this platform is used by a build target. More...
 
OS_Type OS (void) const
 Type of operating system for this platform. More...
 
CString Name (void)
 Returns the name of this platform. More...
 
CStringCmd_Copy (void)
 File copying command template. More...
 
CStringCmd_Move (void)
 File moving command template. More...
 
CStringCmd_Make (void)
 Make tool invocation template. More...
 
CStringTool_Make (void)
 File name of the 'make' tool. More...
 
CStringCmd_RemoveFile (void)
 File removing (deleting) command template. More...
 
CStringCmd_ForceRemoveFile (void)
 Forced file removing command template. More...
 
CStringCmd_MakeDir (void)
 Directory creation command template. More...
 
CStringCmd_TestMakeDir (void)
 Directory existence checking and creation command template. More...
 
CStringCmd_ForceMakeDir (void)
 Forced directory creation (including parent directories) command template. More...
 
CStringCmd_RemoveDir (void)
 Directory removing command template. More...
 
CStringCmd_PrintWorkDir (void)
 Template of command to print working directory. More...
 
CStringCmd_EvalWorkDir (void)
 Template of command that evaluates working directory to assign it to a variable. More...
 
CStringCmd_ChangeDir (void)
 Current directory changing command template. More...
 
char Pd (void) const
 Returns path delimiter (separator) for this platform. More...
 
CString Pd (const CString &Path) const
 Converts path separators in given path to valid for this platform. More...
 
CString SpecialChars (void) const
 
CString ProtectPath (const CString &Path, const int QuoteMode=QUOTE_AUTO)
 
CString Copy (const CString &Source, const CString &Destination) const
 Generates file copying command from template. More...
 
CString Move (const CString &Source, const CString &Destination) const
 Generates file moving command from template. More...
 
CString Make (const CString &Options, const CString &Path) const
 Generates command to invoke make tool from template. More...
 
CString RemoveFile (const CString &Path) const
 Generates file removing command from template. More...
 
CString ForceRemoveFile (const CString &Path) const
 Generates forced file removing command from template. More...
 
CString MakeDir (const CString &Path) const
 Generates directory creation command from template. More...
 
CString TestMakeDir (const CString &Path) const
 Generates conditional (by existence) directory creation command from template. More...
 
CString ForceMakeDir (const CString &Path) const
 Generates forced directory creation command from template. More...
 
CString RemoveDir (const CString &Path) const
 Generates directory removing command from template. More...
 
CString PrintWorkDir (void) const
 Generates command to print current working directory from template. More...
 
CString EvalWorkDir (void) const
 Generates command to evaluate working directory value from template. More...
 
CString ChangeDir (const CString &Path) const
 Generates current directory changing command from template. More...
 
CString MakefileCmd (const CString &Command) const
 Converts raw command text to makefile-compatible form. More...
 
bool IsStaticLibraryExtension (const CString &Ext) const
 
bool IsDynamicLibraryExtension (const CString &Ext) const
 
void Assign (const CPlatform &Platform)
 Copies another platform to this platform. More...
 
void Clear (void)
 Resets the platform to the initial state. More...
 
void Reset (const CPlatform::OS_Type OS)
 Resets the platform to default settings for specified OS. More...
 
void Read (const TiXmlElement *PlatformRoot)
 Reads the platform settings from an XML document. More...
 
void Write (TiXmlElement *PlatformRoot)
 Writes the platform settings to an XML document. More...
 
void Show (void)
 Prints the platform settings to the standard output. More...
 
CPlatformoperator= (const CPlatform &Platform)
 Copies another platform to this platform. More...
 
 CPlatform (void)
 Creates platform description. More...
 
 CPlatform (const CPlatform &Platform)
 Copies another platform to this platform. More...
 
 ~CPlatform (void)
 

Static Public Member Functions

static CString Name (const OS_Type PlatformOS)
 Returns name of platform for type PlatformOS. More...
 
static OS_Type OS (CString &PlatformName)
 Returns platform type for name PlatformName. More...
 

Private Member Functions

void Read (const TiXmlElement *Root, const CString &Name, CString &Value)
 Reads template of command Name to Value from an XML document. More...
 
void Write (TiXmlElement *Root, const CString &Name, const CString &Value)
 Writes template of command Name to Value from an XML document. More...
 

Private Attributes

bool m_Active
 Indicates that this platform is used by a build target. More...
 
OS_Type m_OS_Type
 Type of operating system for this platform. More...
 
CString m_Cmd_Null
 Name of the NULL device (/dev/null etc). More...
 
CString m_Cmd_Copy
 File copying command template. More...
 
CString m_Cmd_Move
 File moving command template. More...
 
CString m_Cmd_Make
 Make tool invocation template. More...
 
CString m_Tool_Make
 File name of the make tool. More...
 
CString m_Cmd_RemoveFile
 File removing (deleting) command template. More...
 
CString m_Cmd_ForceRemoveFile
 Forced file removing command template. More...
 
CString m_Cmd_MakeDir
 Directory creation command template. More...
 
CString m_Cmd_TestMakeDir
 Directory existence checking and creation command template. More...
 
CString m_Cmd_ForceMakeDir
 Forced directory creation (including parent directories) command template. More...
 
CString m_Cmd_RemoveDir
 Directory removing command template. More...
 
CString m_Cmd_PrintWorkDir
 Template of command to print working directory. More...
 
CString m_Cmd_EvalWorkDir
 Template of command that evaluates working directory to assign it to a variable. More...
 
CString m_Cmd_ChangeDir
 Current directory changing command template. More...
 
char m_PathDelimiter
 File system path delimiter (separator). More...
 
CStringList m_StaticLibraryExtensions
 
CStringList m_DynamicLibraryExtensions
 

Detailed Description

Contains platform-specific settings and generates commands from templates.

Command templates use few special macros that should be substituted to get a working command:

A command template looks like this: "make $opts -f $file" (make tool invocation).

Member Enumeration Documentation

◆ OS_Type

Type of Operating System for a platform.

Enumerator
OS_Other 

Type for undefined or unknown OS.

OS_Unix 

Type for UNIX-like OS.

OS_Windows 

Type for OS Windows.

OS_Mac 

Type for MacOS.

OS_Count 

Number of OS types.

Constructor & Destructor Documentation

◆ CPlatform() [1/2]

CPlatform::CPlatform ( void  )

Creates platform description.

◆ CPlatform() [2/2]

CPlatform::CPlatform ( const CPlatform Platform)

Copies another platform to this platform.

Parameters
Platformanother platform.

◆ ~CPlatform()

CPlatform::~CPlatform ( void  )

Member Function Documentation

◆ Active()

CPlatform::Active ( void  )
inline

Indicates that this platform is used by a build target.

Returns
reference to CPlatform::m_Active.

◆ Assign()

void CPlatform::Assign ( const CPlatform Platform)

Copies another platform to this platform.

Parameters
Platformanother platform.

◆ ChangeDir()

CString CPlatform::ChangeDir ( const CString Path) const

Generates current directory changing command from template.

Parameters
Patha directory path.
Returns
current directory changing command.
See also
CPlatform::Cmd_ChangeDir().

◆ Clear()

void CPlatform::Clear ( void  )

Resets the platform to the initial state.

◆ Cmd_ChangeDir()

CPlatform::Cmd_ChangeDir ( void  )
inline

Current directory changing command template.

Returns
reference to CPlatform::m_Cmd_ChangeDir.

◆ Cmd_Copy()

CPlatform::Cmd_Copy ( void  )
inline

File copying command template.

Returns
reference to CPlatform::m_Cmd_Copy.

◆ Cmd_EvalWorkDir()

CPlatform::Cmd_EvalWorkDir ( void  )
inline

Template of command that evaluates working directory to assign it to a variable.

Returns
reference to CPlatform::m_Cmd_EvalWorkDir.

◆ Cmd_ForceMakeDir()

CPlatform::Cmd_ForceMakeDir ( void  )
inline

Forced directory creation (including parent directories) command template.

Returns
reference to CPlatform::m_Cmd_ForceMakeDir.

◆ Cmd_ForceRemoveFile()

CPlatform::Cmd_ForceRemoveFile ( void  )
inline

Forced file removing command template.

Returns
reference to CPlatform::m_Cmd_ForceRemoveFile.

◆ Cmd_Make()

CPlatform::Cmd_Make ( void  )
inline

Make tool invocation template.

Returns
reference to CPlatform::m_Cmd_Make.

◆ Cmd_MakeDir()

CPlatform::Cmd_MakeDir ( void  )
inline

Directory creation command template.

Returns
reference to CPlatform::m_Cmd_ForceMakeDir.

◆ Cmd_Move()

CPlatform::Cmd_Move ( void  )
inline

File moving command template.

Returns
reference to CPlatform::m_Cmd_Move.

◆ Cmd_PrintWorkDir()

CPlatform::Cmd_PrintWorkDir ( void  )
inline

Template of command to print working directory.

Returns
reference to CPlatform::m_Cmd_PrintWorkDir.

◆ Cmd_RemoveDir()

CPlatform::Cmd_RemoveDir ( void  )
inline

Directory removing command template.

Returns
reference to CPlatform::m_Cmd_RemoveDir.

◆ Cmd_RemoveFile()

CPlatform::Cmd_RemoveFile ( void  )
inline

File removing (deleting) command template.

Returns
reference to CPlatform::m_Cmd_RemoveFile.

◆ Cmd_TestMakeDir()

CPlatform::Cmd_TestMakeDir ( void  )
inline

Directory existence checking and creation command template.

Returns
reference to CPlatform::m_Cmd_TestMakeDir.

◆ Copy()

CString CPlatform::Copy ( const CString Source,
const CString Destination 
) const

Generates file copying command from template.

Parameters
Sourcesource file.
Destinationtarget file.
Returns
file copying command.
See also
CPlatform::Cmd_Copy().

◆ EvalWorkDir()

CString CPlatform::EvalWorkDir ( void  ) const

Generates command to evaluate working directory value from template.

Returns
working directory expression for assignment to a variable.
See also
CPlatform::Cmd_EvalWorkDir().

◆ ForceMakeDir()

CString CPlatform::ForceMakeDir ( const CString Path) const

Generates forced directory creation command from template.

Parameters
Patha directory path.
Returns
forced directory creation command.
See also
CPlatform::Cmd_ForceMakeDir().

◆ ForceRemoveFile()

CString CPlatform::ForceRemoveFile ( const CString Path) const

Generates forced file removing command from template.

Parameters
Patha file path.
Returns
forced file removing command.
See also
CPlatform::Cmd_ForceRemoveFile().

◆ IsDynamicLibraryExtension()

bool CPlatform::IsDynamicLibraryExtension ( const CString Ext) const

◆ IsStaticLibraryExtension()

bool CPlatform::IsStaticLibraryExtension ( const CString Ext) const

◆ Make()

CString CPlatform::Make ( const CString Options,
const CString Path 
) const

Generates command to invoke make tool from template.

Parameters
Optionsmake tool options.
Pathpath to a makefile.
Returns
make tool invocation command.
See also
CPlatform::Cmd_Make().

◆ MakeDir()

CString CPlatform::MakeDir ( const CString Path) const

Generates directory creation command from template.

Parameters
Patha directory path.
Returns
directory creation command.
See also
CPlatform::Cmd_MakeDir().

◆ MakefileCmd()

CString CPlatform::MakefileCmd ( const CString Command) const

Converts raw command text to makefile-compatible form.

Parameters
Commanda command text.
Returns
makefile-compatible command.

In Windows, it is required to prepend commands with "cmd /c" in order to make them work as intended from the makefile, while in UNIX is is not required to change commands anyhow. This function is invented to deal with compatibility issues for other platforms as well.

◆ Move()

CString CPlatform::Move ( const CString Source,
const CString Destination 
) const

Generates file moving command from template.

Parameters
Sourcesource file.
Destinationtarget file.
Returns
file moving command.
See also
CPlatform::Cmd_Move().

◆ Name() [1/2]

CString CPlatform::Name ( const OS_Type  PlatformOS)
static

Returns name of platform for type PlatformOS.

Parameters
PlatformOSa platform / operating system type.
Returns
name of platform.

◆ Name() [2/2]

CString CPlatform::Name ( void  )

Returns the name of this platform.

Returns
name of this platform.

◆ operator=()

CPlatform & CPlatform::operator= ( const CPlatform Platform)

Copies another platform to this platform.

Parameters
Platformanother platform.
Returns
reference to this platform.

◆ OS() [1/2]

CPlatform::OS_Type CPlatform::OS ( CString PlatformName)
static

Returns platform type for name PlatformName.

Parameters
PlatformNamea name of platform / operating system.
Returns
type of platform.

◆ OS() [2/2]

CPlatform::OS ( void  ) const
inline

Type of operating system for this platform.

Returns
value of CPlatform::m_OS_Type.

◆ Pd() [1/2]

CPlatform::Pd ( void  ) const
inline

Returns path delimiter (separator) for this platform.

Returns
path delimiter (separator) for this platform.

◆ Pd() [2/2]

CString CPlatform::Pd ( const CString Path) const

Converts path separators in given path to valid for this platform.

Parameters
Patha file path.
Returns
file path with valid separators.

◆ PrintWorkDir()

CString CPlatform::PrintWorkDir ( void  ) const

Generates command to print current working directory from template.

Returns
command to print current working directory.
See also
CPlatform::Cmd_PrintWorkDir().

◆ ProtectPath()

CString CPlatform::ProtectPath ( const CString Path,
const int  QuoteMode = QUOTE_AUTO 
)

◆ Read() [1/2]

void CPlatform::Read ( const TiXmlElement *  Root,
const CString Name,
CString Value 
)
private

Reads template of command Name to Value from an XML document.

Parameters
Rootan element of an XML document.
Namename of a command.
Valuecommand template.

◆ Read() [2/2]

void CPlatform::Read ( const TiXmlElement *  PlatformRoot)

Reads the platform settings from an XML document.

Parameters
PlatformRootan element of an XML document.

◆ RemoveDir()

CString CPlatform::RemoveDir ( const CString Path) const

Generates directory removing command from template.

Parameters
Patha directory path.
Returns
directory removing command.
See also
CPlatform::Cmd_RemoveDir().

◆ RemoveFile()

CString CPlatform::RemoveFile ( const CString Path) const

Generates file removing command from template.

Parameters
Patha file path.
Returns
file removing command.
See also
CPlatform::Cmd_RemoveFile().

◆ Reset()

void CPlatform::Reset ( const CPlatform::OS_Type  OS)

Resets the platform to default settings for specified OS.

Parameters
OSoperating system type.

◆ Show()

void CPlatform::Show ( void  )

Prints the platform settings to the standard output.

◆ SpecialChars()

CString CPlatform::SpecialChars ( void  ) const

◆ TestMakeDir()

CString CPlatform::TestMakeDir ( const CString Path) const

Generates conditional (by existence) directory creation command from template.

Parameters
Patha directory path.
Returns
conditional directory creation command.
See also
CPlatform::Cmd_TestMakeDir().

◆ Tool_Make()

CPlatform::Tool_Make ( void  )
inline

File name of the 'make' tool.

Returns
reference to CPlatform::m_Tool_Make.

◆ Write() [1/2]

void CPlatform::Write ( TiXmlElement *  Root,
const CString Name,
const CString Value 
)
private

Writes template of command Name to Value from an XML document.

Parameters
Rootan element of an XML document.
Namename of a command.
Valuecommand template.

◆ Write() [2/2]

void CPlatform::Write ( TiXmlElement *  PlatformRoot)

Writes the platform settings to an XML document.

Parameters
PlatformRootan element of an XML document.

Member Data Documentation

◆ m_Active

CPlatform::m_Active
private

Indicates that this platform is used by a build target.

This property is modified by CCodeBlocksProject during makefile creation.

◆ m_Cmd_ChangeDir

CPlatform::m_Cmd_ChangeDir
private

Current directory changing command template.

◆ m_Cmd_Copy

CPlatform::m_Cmd_Copy
private

File copying command template.

◆ m_Cmd_EvalWorkDir

CPlatform::m_Cmd_EvalWorkDir
private

Template of command that evaluates working directory to assign it to a variable.

◆ m_Cmd_ForceMakeDir

CPlatform::m_Cmd_ForceMakeDir
private

Forced directory creation (including parent directories) command template.

◆ m_Cmd_ForceRemoveFile

CPlatform::m_Cmd_ForceRemoveFile
private

Forced file removing command template.

◆ m_Cmd_Make

CPlatform::m_Cmd_Make
private

Make tool invocation template.

◆ m_Cmd_MakeDir

CPlatform::m_Cmd_MakeDir
private

Directory creation command template.

◆ m_Cmd_Move

CPlatform::m_Cmd_Move
private

File moving command template.

◆ m_Cmd_Null

CPlatform::m_Cmd_Null
private

Name of the NULL device (/dev/null etc).

◆ m_Cmd_PrintWorkDir

CPlatform::m_Cmd_PrintWorkDir
private

Template of command to print working directory.

◆ m_Cmd_RemoveDir

CPlatform::m_Cmd_RemoveDir
private

Directory removing command template.

◆ m_Cmd_RemoveFile

CPlatform::m_Cmd_RemoveFile
private

File removing (deleting) command template.

◆ m_Cmd_TestMakeDir

CPlatform::m_Cmd_TestMakeDir
private

Directory existence checking and creation command template.

◆ m_DynamicLibraryExtensions

CStringList CPlatform::m_DynamicLibraryExtensions
private

◆ m_OS_Type

CPlatform::m_OS_Type
private

Type of operating system for this platform.

◆ m_PathDelimiter

CPlatform::m_PathDelimiter
private

File system path delimiter (separator).

◆ m_StaticLibraryExtensions

CStringList CPlatform::m_StaticLibraryExtensions
private

◆ m_Tool_Make

CPlatform::m_Tool_Make
private

File name of the make tool.


The documentation for this class was generated from the following files: