28 #include "scripting/sqplus/sqplus.h" 72 cbThrow(
_T(
"Default compiler is invalid!"));
181 msg <<
_(
"Scripts that failed to load either because they don't exist\n" 182 "or because they contain syntax errors:\n\n");
191 msg <<
_(
"Scripts that failed to load because the mandatory function\n" 192 "SetBuildOptions() is missing:\n\n");
215 #ifdef command_line_generation 241 CompilerExe compExec = ceUnknown;
289 if (
Manager::Get()->GetConfigManager(
_T(
"compiler"))->ReadBool(
_T(
"/include_file_cwd"),
false))
321 if (
Manager::Get()->GetConfigManager(
_T(
"compiler"))->ReadBool(
_T(
"/include_prj_cwd"),
false))
348 #ifdef command_line_generation 357 wxString tmpFlatObject = flat_object;
362 #ifdef command_line_generation 363 Manager::Get()->
GetLogManager()->
DebugLog(
F(
_T(
"GenerateCommandLine[2]: tmpFile='%s', tmpDeps='%s', tmpObject='%s', tmpFlatObject='%s',\ntmpFname.GetName='%s', tmpFname.GetPath='%s', tmpFname.GetExt='%s'."),
372 #ifdef command_line_generation 383 else if (compExec == ceCPP)
388 for (
size_t i = 0; i < remFlags.
GetCount(); ++i)
390 int index = aCflags.
Index(remFlags[i]);
397 wxString allObjectsQuoted(tmpObject);
400 allObjectsQuoted +=
m_LDAdd[target];
401 if (allObjectsQuoted.
Find(
_T(
'"')) != -1)
404 allObjectsQuoted =
_T(
"\"") + allObjectsQuoted +
_T(
"\"");
407 macro.
Replace(
_T(
"$compiler"), compilerStr);
414 macro.
Replace(
_T(
"$includes"), tmpIncludes);
415 macro.
Replace(
_T(
"$res_includes"), tmpResIncludes);
423 macro.
Replace(
_T(
"$dep_object"), tmpDeps);
425 #ifdef command_line_generation 433 tmp = target->GetObjectOutput();
435 macro.
Replace(
_T(
"$objects_output_dir"), tmp);
438 macro.
Replace(
_T(
"$resource_output"), tmpObject);
447 macro.
Replace(
_T(
"$exe_output"), output);
448 tmpOutFname.
Assign(output);
459 macro.
Replace(
_T(
"$link_resobjects"), tmpDeps);
460 macro.
Replace(
_T(
"$link_objects"), tmpObject);
461 macro.
Replace(
_T(
"$link_flat_objects"), tmpFlatObject);
464 macro.
Replace(
_T(
"$+link_objects"), tmpObject);
465 macro.
Replace(
_T(
"$-link_objects"), tmpObject);
466 macro.
Replace(
_T(
"$-+link_objects"), tmpObject);
467 macro.
Replace(
_T(
"$+-link_objects"), tmpObject);
468 macro.
Replace(
_T(
"$all_link_objects_quoted"), allObjectsQuoted);
470 #ifdef command_line_generation 483 || (target->GetCreateStaticLib()) )
487 macro.
Replace(
_T(
"-Wl,--out-implib=$static_output"),
_T(
""));
491 if (target->GetCreateDefFile())
495 macro.
Replace(
_T(
"-Wl,--output-def=$def_output"),
_T(
""));
500 #ifdef command_line_generation 508 #ifdef command_line_generation 517 static const wxString clearout_buildscripts =
_T(
"SetBuildOptions <- null;");
519 for (
size_t i = 0; i < scripts.
GetCount(); ++i)
521 wxString script_nomacro = scripts[i];
536 if (!
Manager::Get()->GetScriptingManager()->LoadScript(script_nomacro))
544 SqPlus::SquirrelFunction<void> f(
cbU2C(funcName));
547 catch (SquirrelError& e)
562 while (i < inAndOut.
Length())
585 #ifdef command_line_generation 613 if (!current_ext.
IsSameAs(requested_ext,
false))
621 #ifdef command_line_generation 640 if (!current_ext.
IsSameAs(requested_ext,
false))
641 definitionFileFileName.
SetFullName(definitionFileFileName.
GetFullName() + wxFILE_SEP_EXT + requested_ext);
647 #ifdef command_line_generation 682 if ( (platform::windows && !current_ext.
IsSameAs(requested_ext,
false))
683 || (!current_ext.
IsSameAs(requested_ext)) )
695 #ifdef command_line_generation 705 #ifdef command_line_generation 712 #ifdef command_line_generation 731 for (
unsigned int x = 0; x < searchDirs.
GetCount(); ++x)
734 if (
Manager::Get()->GetConfigManager(
_T(
"compiler"))->ReadBool(
_T(
"/include_prj_cwd"),
false) )
737 searchDirs.
Add(
_T(
"."));
746 for (
unsigned int x = 0; x < carr.GetCount(); ++x)
749 for (
unsigned int x = 0; x < result.
GetCount(); ++x)
780 for (
unsigned int x = 0; x < searchDirs.
GetCount(); ++x)
799 for (
unsigned int x = 0; x < carr.GetCount(); ++x)
802 for (
unsigned int x = 0; x < result.
GetCount(); ++x)
829 for (
unsigned int x = 0; x < carr.GetCount(); ++x)
832 for (
unsigned int x = 0; x < result.
GetCount(); ++x)
859 for (
unsigned int x = 0; x < arr.
GetCount(); ++x)
871 for (
unsigned int x = 0; x < arr.
GetCount(); ++x)
878 result << opt << tmp;
888 for (
unsigned int x = 0; x < arr.
GetCount(); ++x)
890 wxString fn(arr[x] + wxFILE_SEP_PATH + filename);
997 if (result.
Find(
'/') == -1 && result.
Find(
'\\') == -1)
1000 bool hadLibPrefix =
false;
1006 hadLibPrefix =
true;
1023 result <<
_T(
".") << libExt;
1041 for (
unsigned int x = 0; x < carr.GetCount(); ++x)
1044 for (
unsigned int x = 0; x < libs.
GetCount(); ++x)
1050 for (
unsigned int x = 0; x < libs.
GetCount(); ++x)
1057 for (
unsigned int x = 0; x < libs.
GetCount(); ++x)
1133 result << project_options;
1136 result << target_options;
1139 result << target_options << project_options;
1142 result << project_options << target_options;
1161 for (
size_t i = 0; i < project_options.
GetCount(); ++i)
1162 result.
Add(project_options[i]);
1165 for (
size_t i = 0; i < target_options.
GetCount(); ++i)
1166 result.
Add(target_options[i]);
1169 for (
size_t i = 0; i < target_options.
GetCount(); ++i)
1170 result.
Add(target_options[i]);
1171 for (
size_t i = 0; i < project_options.
GetCount(); ++i)
1172 result.
Add(project_options[i]);
1175 for (
size_t i = 0; i < project_options.
GetCount(); ++i)
1176 result.
Add(project_options[i]);
1177 for (
size_t i = 0; i < target_options.
GetCount(); ++i)
1178 result.
Add(target_options[i]);
1191 for (
size_t x = 0; x < inc_dirs.
GetCount(); ++x)
1204 inc_string << inc_switch << inc_dir <<
_T(
' ');
1231 size_t pos2 = btOutput.
find(
_T(
' '), pos);
1251 size_t pos2 = btOutput.
find(
_T(
' '), pos);
bool linkerNeedsLibExtension
wxString F(const wxChar *msg,...)
sprintf-like function
DLLIMPORT wxArrayString GetArrayFromString(const wxString &text, const wxString &separator=DEFAULT_ARRAY_SEP, bool trimSpaces=true)
virtual void GetTargetFilenameGenerationPolicy(TargetFilenameGenerationPolicy &prefixOut, TargetFilenameGenerationPolicy &extensionOut) const
bool Matches(const wxString &mask) const
virtual wxArrayString GetOrderedResourceIncludeDirs(Compiler *compiler, ProjectBuildTarget *target)
TargetFilenameGenerationPolicy
A target's filename can either be auto-generated based on the running platform, or completely specifi...
wxString UnquoteStringIfNeeded(const wxString &str)
OptionsMap m_DefOutput
def output filenames, per-target
virtual ~CompilerCommandGenerator()
void Assign(const wxFileName &filepath)
void SetFullName(const wxString &fullname)
ConfigManager * GetConfigManager(const wxString &name_space) const
void DebugLogError(const wxString &msg)
OptionsMap m_Inc
compiler 'include' dirs, per-target
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
void SetBuildTargetName(const wxString &target)
virtual void FixPathSeparators(Compiler *compiler, wxString &inAndOut)
SearchDirsMap m_LinkerSearchDirs
array of final linker search dirs, per-target
Linker include dir option.
virtual wxString SetupLinkLibraries(Compiler *compiler, ProjectBuildTarget *target)
Setup link libraries for build target.
The option uses parent options only.
The option uses target options appended to parent options.
bool wxFileExists(const wxString &filename)
static Compiler * GetDefaultCompiler()
wxString GetShortPath() const
virtual wxString FixupLinkLibraries(Compiler *compiler, const wxString &lib)
Fix library name based on advanced compiler settings.
bool ReadBool(const wxString &name, bool defaultVal=false)
int Index(const wxString &sz, bool bCase=true, bool bFromEnd=false) const
void SetModified(bool modified=true) override
Mark the project as modified or not.
virtual wxString SetupLibrariesDirs(Compiler *compiler, ProjectBuildTarget *target)
Setup linker include dirs for build target.
void LogToStdOut(const wxString &msg, Logger::level lv=Logger::info)
Target produces an executable.
virtual const wxArrayString & GetCompilerOptions() const
virtual const wxArrayString & GetCompilerSearchDirs(ProjectBuildTarget *target)
Get the full include dirs used in the actual command line.
static Compiler * GetCompiler(size_t index)
OptionsMap m_RC
resource compiler 'include' dirs, per-target
DLLIMPORT wxString GetStringFromArray(const wxArrayString &array, const wxString &separator=DEFAULT_ARRAY_SEP, bool SeparatorAtEnd=true)
bool IsAbsolute(wxPathFormat format=wxPATH_NATIVE) const
wxString GetProcessedIncludeDir(Compiler *compiler, ProjectBuildTarget *target, const wxArrayString &inc_dirs, const wxString &inc_switch)
Processes include dirs by default.
virtual wxArrayString GetOrderedLibrariesDirs(Compiler *compiler, ProjectBuildTarget *target)
const wxString & GetCPPOnlyFlags()
wxString & Remove(size_t pos)
virtual wxString SetupOutputFilenames(Compiler *compiler, ProjectBuildTarget *target)
Setup output filename for build target.
virtual void GenerateCommandLine(wxString ¯o, 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.
virtual wxString GetOrderedOptions(const ProjectBuildTarget *target, OptionsRelationType rel, const wxString &project_options, const wxString &target_options)
Arrange order of options.
OptionsMap m_Lib
linker 'include' dirs, per-target
virtual const wxArrayString & GetBuildScripts() const
wxString m_PrjIncPath
directive to add the project's top-level path in compiler search dirs (ready for the command line) ...
EVTIMPORT const wxEventType cbEVT_COMPILER_SET_BUILD_OPTIONS
Represents a file in a Code::Blocks project.
size_t find(const wxString &str, size_t nStart=0) const
A generic Code::Blocks event.
virtual wxString GetOutputFilename()
Read the target's output filename.
virtual cbProject * GetParentProject()
virtual wxArrayString GetOrderedIncludeDirs(Compiler *compiler, ProjectBuildTarget *target)
DLLIMPORT const wxWX2MBbuf cbU2C(const wxString &str)
Return multibyte (C string) representation of the string.
virtual TargetType GetTargetType() const
Read the target's type.
virtual void Init(cbProject *project)
Initialize for use with the specified project.
wxUSE_UNICODE_dependent wxChar
bool Contains(const wxString &str) const
virtual OptionsRelation GetOptionRelation(OptionsRelationType type) const
Read the target's options relation for type.
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
wxArrayString m_ScriptsWithErrors
virtual const wxArrayString & GetResourceIncludeDirs() const
Represents a Code::Blocks project.
virtual const wxArrayString & GetLinkerOptions() const
const wxString & GetCOnlyFlags()
bool wxSetWorkingDirectory(const wxString &dir)
wxString & RemoveLast(size_t n=1)
virtual const wxArrayString & GetLinkLibs() const
virtual wxString GetDynamicLibImportFilename()
Read the target's dynamic library import filename (produced if target type is ttDynamicLib) ...
virtual const wxString & GetTitle() const
Read the target's title.
Resource compiler include dir option.
Target produces a dynamic library.
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
OptionsRelation
Option's relation.
The option uses parent options appended to target options.
wxChar includeDirSeparator
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
static bool IsBatchBuild()
virtual const CompilerPrograms & GetPrograms() const
Get the compiler's programs.
Target produces a native binary.
LogManager * GetLogManager() const
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
OptionsMap m_LDAdd
link libraries, per-target
Compiler include dir option.
void DisplayErrors(SquirrelError *exception=nullptr, bool clearErrors=true)
Display error dialog.
void SetChar(size_t n, wxUniChar ch)
OptionsMap m_CFlags
compiler flags, per-target
const wxStringCharType * wx_str() const
virtual wxString SetupResourceIncludeDirs(Compiler *compiler, ProjectBuildTarget *target)
Setup resource compiler include dirs for build target.
wxString Right(size_t count) const
MacrosManager * GetMacrosManager() const
const wxString & _(const wxString &string)
virtual wxString SetupLinkerOptions(Compiler *compiler, ProjectBuildTarget *target)
Setup linker flags for build target.
DLLIMPORT void QuoteStringIfNeeded(wxString &str)
wxString & Trim(bool fromRight=true)
void ReplaceMacros(wxString &buffer, ProjectBuildTarget *target=nullptr, bool subrequest=false)
virtual wxString SetupIncludeDirs(Compiler *compiler, ProjectBuildTarget *target)
Setup compiler include dirs for build target.
int GetBuildTargetsCount()
virtual const wxArrayString & GetIncludeDirs() const
wxString compilerVar
The compiler variable used for this file (e.g CPP, CC, etc).
Target produces a static library.
ProjectBuildTarget * GetBuildTarget(int index)
Access a build target.
const DLLIMPORT wxString EXECUTABLE_EXT
Abstract base class for compilers.
virtual const wxArrayString & GetLinkerSearchDirs(ProjectBuildTarget *target)
Get the full linker dirs used in the actual command line.
virtual const wxArrayString & GetLibDirs() const
wxString GetPath(int flags=wxPATH_GET_VOLUME, wxPathFormat format=wxPATH_NATIVE) const
virtual const wxString & GetCompilerID() const
Read the target's compiler.
Target produces a console executable (without GUI) (distinction between ttExecutable and ttConsoleOnl...
bool IsRelative(wxPathFormat format=wxPATH_NATIVE) const
void Log(const wxString &msg, int i=app_log, Logger::level lv=Logger::info)
wxString GetFullName() const
SearchDirsMap m_CompilerSearchDirs
array of final compiler search dirs, per-target
static wxString PathSearch(const wxArrayString &arr, const wxString &filename)
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
virtual const CompilerSwitches & GetSwitches() const
Get the compiler's generic switches.
bool ProcessEvent(CodeBlocksEvent &event)
bool EndsWith(const wxString &suffix, wxString *rest=NULL) const
OptionsMap m_RCFlags
resource compiler flags, per-target
wxString GetCommonTopLevelPath() const
bool GetModified() const override
void SetExt(const wxString &ext)
size_t Add(const wxString &str, size_t copies=1)
wxArrayString m_NotLoadedScripts
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
OptionsMap m_StaticOutput
static output filenames, per-target
bool linkerNeedsLibPrefix
Represents a Code::Blocks project build target.
int Find(wxUniChar ch, bool fromEnd=false) const
wxUniChar GetChar(size_t n) const
OptionsMap m_LDFlags
linker flags, per-target
DLLIMPORT wxString ExpandBackticks(wxString &str)
ScriptingManager * GetScriptingManager() const
bool MakeAbsolute(const wxString &cwd=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
void RemoveAt(size_t nIndex, size_t count=1)
void SearchDirsFromBackticks(Compiler *compiler, ProjectBuildTarget *target, const wxString &btOutput)
void SetName(const wxString &name)
The option uses target options only.
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
bool LoadBuffer(const wxString &buffer, const wxString &debugName=_T("CommandLine"))
Loads a string buffer.
static wxString MakeOptString(const wxArrayString &arr, const wxString &opt, wxChar separator=_T(' '))
virtual wxString GetDynamicLibDefFilename()
Read the target's dynamic library definition file filename (produced if target type is ttDynamicLib) ...
OptionsRelationType
Enum that defines the option's relation types.
wxString Mid(size_t first, size_t nCount=wxString::npos) const
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
virtual void DoBuildScripts(cbProject *project, CompileTargetBase *target, const wxString &funcName)
Apply pre-build scripts for base.
virtual wxString SetupResourceCompilerOptions(Compiler *compiler, ProjectBuildTarget *target)
Setup resource compiler flags for build target.
virtual wxString SetupCompilerOptions(Compiler *compiler, ProjectBuildTarget *target)
Setup compiler flags for build target.
bool linkerNeedsPathResolved
OptionsMap m_Output
output filenames, per-target
CompilerCommandGenerator()
Base class for build target classes Each Code::Blocks project consists of at least one target...
Target only runs commands in pre-build and/or post-build steps.