Code::Blocks  SVN r11506
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
CompilerCommandGenerator Class Reference

Generate command-lines needed to produce a build. More...

#include <compilercommandgenerator.h>

Inheritance diagram for CompilerCommandGenerator:
Collaboration diagram for CompilerCommandGenerator:

Public Member Functions

 CompilerCommandGenerator ()
 
virtual ~CompilerCommandGenerator ()
 
virtual void Init (cbProject *project)
 Initialize for use with the specified project. More...
 
virtual void GenerateCommandLine (wxString &macro, ProjectBuildTarget *target, ProjectFile *pf, const wxString &file, const wxString &object, const wxString &flat_object, const wxString &deps)
 Get the command line to compile/link the specific file. More...
 
virtual const wxArrayString & GetCompilerSearchDirs (ProjectBuildTarget *target)
 Get the full include dirs used in the actual command line. More...
 
virtual const wxArrayString & GetLinkerSearchDirs (ProjectBuildTarget *target)
 Get the full linker dirs used in the actual command line. More...
 

Protected Member Functions

virtual void DoBuildScripts (cbProject *project, CompileTargetBase *target, const wxString &funcName)
 Apply pre-build scripts for base. More...
 
virtual wxString GetOrderedOptions (const ProjectBuildTarget *target, OptionsRelationType rel, const wxString &project_options, const wxString &target_options)
 Arrange order of options. More...
 
virtual wxArrayString GetOrderedOptions (const ProjectBuildTarget *target, OptionsRelationType rel, const wxArrayString &project_options, const wxArrayString &target_options)
 Arrange order of options. More...
 
virtual wxArrayString GetOrderedIncludeDirs (Compiler *compiler, ProjectBuildTarget *target)
 
virtual wxArrayString GetOrderedLibrariesDirs (Compiler *compiler, ProjectBuildTarget *target)
 
virtual wxArrayString GetOrderedResourceIncludeDirs (Compiler *compiler, ProjectBuildTarget *target)
 
virtual wxString SetupOutputFilenames (Compiler *compiler, ProjectBuildTarget *target)
 Setup output filename for build target. More...
 
virtual wxString SetupIncludeDirs (Compiler *compiler, ProjectBuildTarget *target)
 Setup compiler include dirs for build target. More...
 
virtual wxString SetupLibrariesDirs (Compiler *compiler, ProjectBuildTarget *target)
 Setup linker include dirs for build target. More...
 
virtual wxString SetupResourceIncludeDirs (Compiler *compiler, ProjectBuildTarget *target)
 Setup resource compiler include dirs for build target. More...
 
virtual wxString SetupCompilerOptions (Compiler *compiler, ProjectBuildTarget *target)
 Setup compiler flags for build target. More...
 
virtual wxString SetupLinkerOptions (Compiler *compiler, ProjectBuildTarget *target)
 Setup linker flags for build target. More...
 
virtual wxString SetupLinkLibraries (Compiler *compiler, ProjectBuildTarget *target)
 Setup link libraries for build target. More...
 
virtual wxString SetupResourceCompilerOptions (Compiler *compiler, ProjectBuildTarget *target)
 Setup resource compiler flags for build target. More...
 
virtual wxString FixupLinkLibraries (Compiler *compiler, const wxString &lib)
 Fix library name based on advanced compiler settings. More...
 
virtual void FixPathSeparators (Compiler *compiler, wxString &inAndOut)
 

Static Protected Member Functions

static wxString MakeOptString (const wxArrayString &arr, const wxString &opt, wxChar separator=_T(' '))
 
static wxString PathSearch (const wxArrayString &arr, const wxString &filename)
 

Protected Attributes

OptionsMap m_Output
 output filenames, per-target More...
 
OptionsMap m_StaticOutput
 static output filenames, per-target More...
 
OptionsMap m_DefOutput
 def output filenames, per-target More...
 
OptionsMap m_Inc
 compiler 'include' dirs, per-target More...
 
OptionsMap m_Lib
 linker 'include' dirs, per-target More...
 
OptionsMap m_RC
 resource compiler 'include' dirs, per-target More...
 
OptionsMap m_CFlags
 compiler flags, per-target More...
 
OptionsMap m_RCFlags
 resource compiler flags, per-target More...
 
OptionsMap m_LDFlags
 linker flags, per-target More...
 
OptionsMap m_LDAdd
 link libraries, per-target More...
 
wxString m_PrjIncPath
 directive to add the project's top-level path in compiler search dirs (ready for the command line) More...
 
SearchDirsMap m_CompilerSearchDirs
 array of final compiler search dirs, per-target More...
 
SearchDirsMap m_LinkerSearchDirs
 array of final linker search dirs, per-target More...
 

Private Member Functions

wxString GetProcessedIncludeDir (Compiler *compiler, ProjectBuildTarget *target, const wxArrayString &inc_dirs, const wxString &inc_switch)
 Processes include dirs by default. More...
 
void SearchDirsFromBackticks (Compiler *compiler, ProjectBuildTarget *target, const wxString &btOutput)
 

Private Attributes

wxArrayString m_NotLoadedScripts
 
wxArrayString m_ScriptsWithErrors
 

Detailed Description

Generate command-lines needed to produce a build.

This pre-generates everything when Init() is called.

This is used by compilers to generate the needed command lines for a build.

Definition at line 30 of file compilercommandgenerator.h.

Constructor & Destructor Documentation

◆ CompilerCommandGenerator()

CompilerCommandGenerator::CompilerCommandGenerator ( )

Definition at line 39 of file compilercommandgenerator.cpp.

◆ ~CompilerCommandGenerator()

CompilerCommandGenerator::~CompilerCommandGenerator ( )
virtual

Definition at line 44 of file compilercommandgenerator.cpp.

Member Function Documentation

◆ DoBuildScripts()

void CompilerCommandGenerator::DoBuildScripts ( cbProject *  project,
CompileTargetBase *  target,
const wxString &  funcName 
)
protectedvirtual

◆ FixPathSeparators()

void CompilerCommandGenerator::FixPathSeparators ( Compiler *  compiler,
wxString &  inAndOut 
)
protectedvirtual

◆ FixupLinkLibraries()

wxString CompilerCommandGenerator::FixupLinkLibraries ( Compiler *  compiler,
const wxString &  lib 
)
protectedvirtual

◆ GenerateCommandLine()

void CompilerCommandGenerator::GenerateCommandLine ( wxString &  macro,
ProjectBuildTarget *  target,
ProjectFile *  pf,
const wxString &  file,
const wxString &  object,
const wxString &  flat_object,
const wxString &  deps 
)
virtual

Get the command line to compile/link the specific file.

Definition at line 207 of file compilercommandgenerator.cpp.

References _T, wxFileName::Assign(), CompilerPrograms::C, wxString::Clear(), ProjectFile::compilerVar, wxString::Contains(), CompilerPrograms::CPP, LogManager::DebugLog(), wxString::EndsWith(), FileFilters::EXECUTABLE_EXT, F(), wxString::Find(), FixPathSeparators(), Manager::Get(), GetArrayFromString(), CompilerFactory::GetCompiler(), CompileTargetBase::GetCompilerID(), Compiler::GetCOnlyFlags(), wxArrayString::GetCount(), Compiler::GetCPPOnlyFlags(), CompilerFactory::GetDefaultCompiler(), wxFileName::GetExt(), wxFileName::GetFullPath(), Manager::GetLogManager(), Manager::GetMacrosManager(), wxFileName::GetName(), wxFileName::GetPath(), Compiler::GetPrograms(), GetStringFromArray(), Compiler::GetSwitches(), CompilerSwitches::includeDirs, CompilerSwitches::includeDirSeparator, wxArrayString::Index(), wxArrayString::IsEmpty(), wxString::IsEmpty(), CompilerPrograms::LD, CompilerPrograms::LIB, wxString::Lower(), m_CFlags, m_DefOutput, m_Inc, m_LDAdd, m_LDFlags, m_Lib, m_Output, m_PrjIncPath, m_RC, m_RCFlags, m_StaticOutput, wxString::Matches(), CompilerSwitches::objectSeparator, QuoteStringIfNeeded(), wxArrayString::RemoveAt(), wxString::RemoveLast(), wxString::Replace(), MacrosManager::ReplaceMacros(), wxFileName::SetExt(), CompileOptionsBase::SupportsCurrentPlatform(), ttDynamicLib, ttStaticLib, UnquoteStringIfNeeded(), CompilerPrograms::WINDRES, wxString::wx_str(), wxNOT_FOUND, and wxT.

Referenced by DirectCommands::GetCompileFileCommand(), DirectCommands::GetCompileSingleFileCommand(), DirectCommands::GetPostBuildCommands(), DirectCommands::GetPreBuildCommands(), and DirectCommands::GetTargetLinkCommands().

◆ GetCompilerSearchDirs()

const wxArrayString & CompilerCommandGenerator::GetCompilerSearchDirs ( ProjectBuildTarget *  target)
virtual

Get the full include dirs used in the actual command line.

These are the actual include dirs that will be used for building and might be different than target->GetIncludeDirs(). This is because it's the sum of target include dirs + project include dirs + build-script include dirs.

Note
This is only valid after Init() has been called.

Definition at line 1098 of file compilercommandgenerator.cpp.

References wxArrayString::Clear(), and m_CompilerSearchDirs.

Referenced by DirectCommands::DepsSearchStart().

◆ GetLinkerSearchDirs()

const wxArrayString & CompilerCommandGenerator::GetLinkerSearchDirs ( ProjectBuildTarget *  target)
virtual

Get the full linker dirs used in the actual command line.

These are the actual linker dirs that will be used for building and might be different than target->GetLibDirs(). This is because it's the sum of target linker dirs + project linker dirs + build-script linker dirs.

Note
This is only valid after Init() has been called.

Definition at line 1110 of file compilercommandgenerator.cpp.

References wxArrayString::Clear(), and m_LinkerSearchDirs.

Referenced by cbGetDynamicLinkerPathForTarget(), and DebuggerGDB::DoDebug().

◆ GetOrderedIncludeDirs()

wxArrayString CompilerCommandGenerator::GetOrderedIncludeDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ GetOrderedLibrariesDirs()

wxArrayString CompilerCommandGenerator::GetOrderedLibrariesDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ GetOrderedOptions() [1/2]

wxString CompilerCommandGenerator::GetOrderedOptions ( const ProjectBuildTarget *  target,
OptionsRelationType  rel,
const wxString &  project_options,
const wxString &  target_options 
)
protectedvirtual

◆ GetOrderedOptions() [2/2]

wxArrayString CompilerCommandGenerator::GetOrderedOptions ( const ProjectBuildTarget *  target,
OptionsRelationType  rel,
const wxArrayString &  project_options,
const wxArrayString &  target_options 
)
protectedvirtual

Arrange order of options.

Depending on the order defined for the build target, it concatenates project_options with target_options and returns the result.

Definition at line 1154 of file compilercommandgenerator.cpp.

References wxArrayString::Add(), wxArrayString::GetCount(), CompileTargetBase::GetOptionRelation(), orAppendToParentOptions, orPrependToParentOptions, orUseParentOptionsOnly, and orUseTargetOptionsOnly.

◆ GetOrderedResourceIncludeDirs()

wxArrayString CompilerCommandGenerator::GetOrderedResourceIncludeDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ GetProcessedIncludeDir()

wxString CompilerCommandGenerator::GetProcessedIncludeDir ( Compiler *  compiler,
ProjectBuildTarget *  target,
const wxArrayString &  inc_dirs,
const wxString &  inc_switch 
)
private

◆ Init()

void CompilerCommandGenerator::Init ( cbProject *  project)
virtual

Initialize for use with the specified project.

Definition at line 49 of file compilercommandgenerator.cpp.

References _(), _T, cbEVT_COMPILER_SET_BUILD_OPTIONS, cbMessageBox(), cbThrow, wxArrayString::Clear(), DoBuildScripts(), Manager::Get(), CompileTargetBase::GetBasePath(), cbProject::GetBuildTarget(), cbProject::GetBuildTargetsCount(), cbProject::GetCommonTopLevelPath(), CompilerFactory::GetCompiler(), CompileTargetBase::GetCompilerID(), wxArrayString::GetCount(), CompilerFactory::GetDefaultCompiler(), Manager::GetLogManager(), cbProject::GetModified(), CompileTargetBase::GetTargetType(), CompileTargetBase::GetTitle(), Manager::IsBatchBuild(), wxArrayString::IsEmpty(), wxString::IsEmpty(), wxString::Last(), LogManager::LogToStdOut(), m_CFlags, m_CompilerSearchDirs, m_DefOutput, m_Inc, m_LDAdd, m_LDFlags, m_Lib, m_LinkerSearchDirs, m_NotLoadedScripts, m_Output, m_PrjIncPath, m_RC, m_RCFlags, m_ScriptsWithErrors, m_StaticOutput, Manager::ProcessEvent(), QuoteStringIfNeeded(), wxString::RemoveLast(), CodeBlocksEvent::SetBuildTargetName(), cbProject::SetModified(), SetupCompilerOptions(), SetupIncludeDirs(), SetupLibrariesDirs(), SetupLinkerOptions(), SetupLinkLibraries(), SetupOutputFilenames(), SetupResourceCompilerOptions(), SetupResourceIncludeDirs(), CompileOptionsBase::SupportsCurrentPlatform(), ttCommandsOnly, wxEmptyString, wxICON_ERROR, and wxSetWorkingDirectory().

Referenced by CompilerMINGW::GetCommandGenerator(), CompilerOW::GetCommandGenerator(), and Compiler::GetCommandGenerator().

◆ MakeOptString()

wxString CompilerCommandGenerator::MakeOptString ( const wxArrayString &  arr,
const wxString &  opt,
wxChar  separator = _T(' ') 
)
staticprotected

◆ PathSearch()

wxString CompilerCommandGenerator::PathSearch ( const wxArrayString &  arr,
const wxString &  filename 
)
staticprotected

◆ SearchDirsFromBackticks()

void CompilerCommandGenerator::SearchDirsFromBackticks ( Compiler *  compiler,
ProjectBuildTarget *  target,
const wxString &  btOutput 
)
private

◆ SetupCompilerOptions()

wxString CompilerCommandGenerator::SetupCompilerOptions ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupIncludeDirs()

wxString CompilerCommandGenerator::SetupIncludeDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupLibrariesDirs()

wxString CompilerCommandGenerator::SetupLibrariesDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupLinkerOptions()

wxString CompilerCommandGenerator::SetupLinkerOptions ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupLinkLibraries()

wxString CompilerCommandGenerator::SetupLinkLibraries ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupOutputFilenames()

wxString CompilerCommandGenerator::SetupOutputFilenames ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupResourceCompilerOptions()

wxString CompilerCommandGenerator::SetupResourceCompilerOptions ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

◆ SetupResourceIncludeDirs()

wxString CompilerCommandGenerator::SetupResourceIncludeDirs ( Compiler *  compiler,
ProjectBuildTarget *  target 
)
protectedvirtual

Setup resource compiler include dirs for build target.

Definition at line 918 of file compilercommandgenerator.cpp.

References GetOrderedResourceIncludeDirs(), Compiler::GetSwitches(), CompilerSwitches::includeDirs, CompilerSwitches::includeDirSeparator, and MakeOptString().

Referenced by Init().

Member Data Documentation

◆ m_CFlags

OptionsMap CompilerCommandGenerator::m_CFlags
protected

compiler flags, per-target

Definition at line 93 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_CompilerSearchDirs

SearchDirsMap CompilerCommandGenerator::m_CompilerSearchDirs
protected

array of final compiler search dirs, per-target

Definition at line 100 of file compilercommandgenerator.h.

Referenced by GetCompilerSearchDirs(), GetOrderedIncludeDirs(), Init(), and SearchDirsFromBackticks().

◆ m_DefOutput

OptionsMap CompilerCommandGenerator::m_DefOutput
protected

def output filenames, per-target

Definition at line 89 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_Inc

OptionsMap CompilerCommandGenerator::m_Inc
protected

compiler 'include' dirs, per-target

Definition at line 90 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_LDAdd

OptionsMap CompilerCommandGenerator::m_LDAdd
protected

link libraries, per-target

Definition at line 96 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_LDFlags

OptionsMap CompilerCommandGenerator::m_LDFlags
protected

linker flags, per-target

Definition at line 95 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_Lib

OptionsMap CompilerCommandGenerator::m_Lib
protected

linker 'include' dirs, per-target

Definition at line 91 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_LinkerSearchDirs

SearchDirsMap CompilerCommandGenerator::m_LinkerSearchDirs
protected

array of final linker search dirs, per-target

Definition at line 101 of file compilercommandgenerator.h.

Referenced by GetLinkerSearchDirs(), GetOrderedLibrariesDirs(), Init(), and SearchDirsFromBackticks().

◆ m_NotLoadedScripts

wxArrayString CompilerCommandGenerator::m_NotLoadedScripts
private

Definition at line 106 of file compilercommandgenerator.h.

Referenced by DoBuildScripts(), and Init().

◆ m_Output

OptionsMap CompilerCommandGenerator::m_Output
protected

output filenames, per-target

Definition at line 87 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), Init(), and SetupOutputFilenames().

◆ m_PrjIncPath

wxString CompilerCommandGenerator::m_PrjIncPath
protected

directive to add the project's top-level path in compiler search dirs (ready for the command line)

Definition at line 98 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_RC

OptionsMap CompilerCommandGenerator::m_RC
protected

resource compiler 'include' dirs, per-target

Definition at line 92 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_RCFlags

OptionsMap CompilerCommandGenerator::m_RCFlags
protected

resource compiler flags, per-target

Definition at line 94 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), and Init().

◆ m_ScriptsWithErrors

wxArrayString CompilerCommandGenerator::m_ScriptsWithErrors
private

Definition at line 107 of file compilercommandgenerator.h.

Referenced by DoBuildScripts(), and Init().

◆ m_StaticOutput

OptionsMap CompilerCommandGenerator::m_StaticOutput
protected

static output filenames, per-target

Definition at line 88 of file compilercommandgenerator.h.

Referenced by GenerateCommandLine(), Init(), and SetupOutputFilenames().


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