13 #include <wx/confbase.h> 42 : m_pProject(project),
45 m_1_4_to_1_5_deftarget(-1),
58 return Open(filename,
nullptr);
77 root = doc.FirstChildElement(
"CodeBlocks_project_file");
81 root = doc.FirstChildElement(
"Code::Blocks_project_file");
84 pMsg->
DebugLog(
_T(
"Not a valid Code::Blocks project file..."));
88 proj = root->FirstChildElement(
"Project");
91 pMsg->
DebugLog(
_T(
"No 'Project' element in file..."));
96 TiXmlElement*
version = root->FirstChildElement(
"FileVersion");
102 version->QueryIntAttribute(
"major", &major);
103 version->QueryIntAttribute(
"minor", &minor);
105 m_IsPre_1_6 = major < 1 || (major == 1 && minor < 6);
108 (major == 1 && minor < 2))
111 pMsg->
DebugLog(
F(
_T(
"Project version is %d.%d. Defaults have changed since then..."), major, minor));
118 _(
"This project file was saved with a newer version of Code::Blocks.\n" 119 "Will try to load, but you should make sure all the settings were loaded correctly..."),
131 if (major == 1 && minor == 5)
133 msg <<
_(
"1.5 to 1.6:\n");
134 msg <<
_(
" * only saves values that differ from defaults (i.e. project files are smaller now).\n");
135 msg <<
_(
" * added object names generation mode setting (normal/extended).\n");
136 msg <<
_(
" * added project notes.\n");
139 warn_msg <<
_(
"* Project file updated to version 1.6:\n");
140 warn_msg <<
_(
" When a project file is saved as version 1.6, it will NO LONGER be read correctly\n");
141 warn_msg <<
_(
" by earlier Code::Blocks versions!\n");
142 warn_msg <<
_(
" So, if you plan on using this project with an earlier Code::Blocks version, you\n");
143 warn_msg <<
_(
" should probably NOT save this project as version 1.6...\n");
148 if (major == 1 && minor == 4)
150 msg <<
_(
"1.4 to 1.5:\n");
151 msg <<
_(
" * added virtual build targets.\n");
156 if (major == 1 && minor == 3)
158 msg <<
_(
"1.3 to 1.4:\n");
159 msg <<
_(
" * changed the way custom file build commands are stored (no auto-conversion).\n");
167 "The file will automatically be upgraded on save.\n" 168 "But please read the following list of changes, as some of them " 169 "might not automatically convert existing (old) settings.\n" 170 "If you don't understand what a change means, you probably don't " 171 "use that feature so you don't have to worry about it.\n\n" 172 "List of changes:\n"),
186 warn_msg.
Prepend(
_(
"!!! WARNING !!!\n\n"));
233 *ppExtensions =
nullptr;
236 TiXmlElement* node = proj->FirstChildElement(
"Extensions");
240 *ppExtensions =
new TiXmlElement(*node);
270 msg.
Printf(
_(
"Project \"%s\" was saved with an earlier version of Code::Blocks.\n" 271 "In the current version, link libraries are treated separately from linker options.\n" 272 "Do you want to auto-detect the libraries \"%s\" is using and configure it accordingly?"),
293 wxString compilerId =
object->GetCompilerID();
299 size_t libExtLen = libExt.
Length();
314 else if (opt.
Length() > libExtLen && opt.
Right(libExtLen) == libExt)
323 object->SetLinkerOptions(linkerOpts);
324 object->SetLinkLibs(linkLibs);
334 node = parentNode->FirstChildElement(
"Build");
335 if (node && node->Attribute(
"command"))
338 node = parentNode->FirstChildElement(
"CompileFile");
339 if (node && node->Attribute(
"command"))
342 node = parentNode->FirstChildElement(
"Clean");
343 if (node && node->Attribute(
"command"))
346 node = parentNode->FirstChildElement(
"DistClean");
347 if (node && node->Attribute(
"command"))
350 node = parentNode->FirstChildElement(
"AskRebuildNeeded");
351 if (node && node->Attribute(
"command"))
354 node = parentNode->FirstChildElement(
"SilentBuild");
355 if (node && node->Attribute(
"command"))
364 TiXmlElement* node = parentNode->FirstChildElement(
"Add");
370 if (node->Attribute(
"alias") && node->Attribute(
"targets"))
379 node = node->NextSiblingElement(
"Add");
385 TiXmlElement* node = parentNode->FirstChildElement(
"Option");
391 bool makefile_custom =
false;
395 bool extendedObjectNames =
false;
397 int platformsFinal =
spAll;
399 bool showNotes =
false;
400 bool checkFiles =
true;
406 if (node->Attribute(
"title"))
408 title =
cbC2U(node->Attribute(
"title"));
410 title =
_T(
"untitled");
413 else if (node->Attribute(
"platforms"))
416 else if (node->Attribute(
"makefile"))
419 else if (node->Attribute(
"makefile_is_custom"))
420 makefile_custom = strncmp(node->Attribute(
"makefile_is_custom"),
"1", 1) == 0;
422 else if (node->Attribute(
"execution_dir"))
431 else if (node->Attribute(
"default_target"))
432 defaultTarget =
cbC2U(node->Attribute(
"default_target"));
434 else if (node->Attribute(
"compiler"))
437 else if (node->Attribute(
"extended_obj_names"))
438 extendedObjectNames = strncmp(node->Attribute(
"extended_obj_names"),
"1", 1) == 0;
440 else if (node->Attribute(
"pch_mode"))
441 pch_mode = (
PCHMode)atoi(node->Attribute(
"pch_mode"));
443 else if (node->Attribute(
"virtualFolders"))
446 else if (node->Attribute(
"show_notes"))
448 TiXmlHandle parentHandle(node);
449 TiXmlText* t = (TiXmlText *) parentHandle.FirstChild(
"notes").FirstChild().Node();
451 notes =
cbC2U(t->Value());
452 showNotes = !notes.
IsEmpty() && strncmp(node->Attribute(
"show_notes"),
"1", 1) == 0;
454 else if (node->Attribute(
"check_files"))
455 checkFiles = strncmp(node->Attribute(
"check_files"),
"0", 1) != 0;
457 node = node->NextSiblingElement(
"Option");
480 TiXmlElement* node = parentNode->FirstChildElement(
"Build");
483 TiXmlElement* opt = node->FirstChildElement(
"Script");
486 if (opt->Attribute(
"file"))
489 opt = opt->NextSiblingElement(
"Script");
494 node = node->NextSiblingElement(
"Build");
500 TiXmlElement* node = parentNode->FirstChildElement(
"Target");
524 node = node->NextSiblingElement(
"Target");
530 TiXmlElement* node = parentNode->FirstChildElement(
"Option");
534 bool use_console_runner =
true;
544 int platformsFinal =
spAll;
548 bool runHostApplicationInTerminal =
false;
549 bool includeInTargetAll =
m_IsPre_1_2 ? true :
false;
550 bool createStaticLib =
false;
551 bool createDefFile =
false;
552 int projectCompilerOptionsRelation = 3;
553 int projectLinkerOptionsRelation = 3;
554 int projectIncludeDirsRelation = 3;
555 int projectLibDirsRelation = 3;
556 int projectResIncludeDirsRelation = 3;
562 if (node->Attribute(
"platforms"))
565 if (node->Attribute(
"use_console_runner"))
566 use_console_runner = strncmp(node->Attribute(
"use_console_runner"),
"0", 1) != 0;
568 if (node->Attribute(
"output"))
571 if (node->Attribute(
"imp_lib"))
574 if (node->Attribute(
"def_file"))
577 if (node->Attribute(
"prefix_auto"))
580 if (node->Attribute(
"extension_auto"))
583 if (node->Attribute(
"working_dir"))
586 if (node->Attribute(
"object_output"))
589 if (node->Attribute(
"deps_output"))
592 if (node->Attribute(
"external_deps"))
595 if (node->Attribute(
"additional_output"))
598 if (node->Attribute(
"type"))
599 type = atoi(node->Attribute(
"type"));
601 if (node->Attribute(
"compiler"))
604 if (node->Attribute(
"parameters"))
605 parameters =
cbC2U(node->Attribute(
"parameters"));
607 if (node->Attribute(
"host_application"))
610 if (node->Attribute(
"run_host_application_in_terminal"))
612 wxString runInTerminal =
cbC2U(node->Attribute(
"run_host_application_in_terminal"));
613 runHostApplicationInTerminal = (runInTerminal ==
wxT(
"1"));
617 if (node->Attribute(
"includeInTargetAll"))
618 includeInTargetAll = atoi(node->Attribute(
"includeInTargetAll")) != 0;
620 if (node->Attribute(
"createDefFile"))
621 createDefFile = atoi(node->Attribute(
"createDefFile")) != 0;
623 if (node->Attribute(
"createStaticLib"))
624 createStaticLib = atoi(node->Attribute(
"createStaticLib")) != 0;
626 if (node->Attribute(
"projectCompilerOptionsRelation"))
627 projectCompilerOptionsRelation = atoi(node->Attribute(
"projectCompilerOptionsRelation"));
629 if (node->Attribute(
"projectLinkerOptionsRelation"))
630 projectLinkerOptionsRelation = atoi(node->Attribute(
"projectLinkerOptionsRelation"));
632 if (node->Attribute(
"projectIncludeDirsRelation"))
633 projectIncludeDirsRelation = atoi(node->Attribute(
"projectIncludeDirsRelation"));
635 if (node->Attribute(
"projectLibDirsRelation"))
636 projectLibDirsRelation = atoi(node->Attribute(
"projectLibDirsRelation"));
638 if (node->Attribute(
"projectResourceIncludeDirsRelation"))
640 projectResIncludeDirsRelation = atoi(node->Attribute(
"projectResourceIncludeDirsRelation"));
643 if (projectResIncludeDirsRelation < 0 || projectResIncludeDirsRelation >=
ortLast)
644 projectResIncludeDirsRelation = 3;
647 node = node->NextSiblingElement(
"Option");
650 node = parentNode->FirstChildElement(
"Script");
653 if (node->Attribute(
"file"))
656 node = node->NextSiblingElement(
"Script");
689 DoMakeCommands(parentNode->FirstChildElement(
"MakeCommands"), target);
695 TiXmlElement* node = parentNode->FirstChildElement(
"Compiler");
699 TiXmlElement* child = node->FirstChildElement(
"Add");
719 child = child->NextSiblingElement(
"Add");
725 TiXmlElement* node = parentNode->FirstChildElement(
"ResourceCompiler");
729 TiXmlElement* child = node->FirstChildElement(
"Add");
749 child = child->NextSiblingElement(
"Add");
755 TiXmlElement* node = parentNode->FirstChildElement(
"Linker");
759 TiXmlElement* child = node->FirstChildElement(
"Add");
787 child = child->NextSiblingElement(
"Add");
793 TiXmlElement* node = parentNode->FirstChildElement(
"IncludeDirs");
797 TiXmlElement* child = node->FirstChildElement(
"Add");
809 child = child->NextSiblingElement(
"Add");
815 TiXmlElement* node = parentNode->FirstChildElement(
"LibDirs");
819 TiXmlElement* child = node->FirstChildElement(
"Add");
831 child = child->NextSiblingElement(
"Add");
837 TiXmlElement* node = parentNode->FirstChildElement(
"ExtraCommands");
841 TiXmlElement* child = node->FirstChildElement(
"Mode");
845 if (mode ==
_T(
"always"))
848 child = child->NextSiblingElement(
"Mode");
851 child = node->FirstChildElement(
"Add");
857 if (child->Attribute(
"before"))
858 before =
cbC2U(child->Attribute(
"before"));
859 if (child->Attribute(
"after"))
860 after =
cbC2U(child->Attribute(
"after"));
867 child = child->NextSiblingElement(
"Add");
869 node = node->NextSiblingElement(
"ExtraCommands");
878 TiXmlElement* node = parentNode->FirstChildElement(
"Environment");
881 TiXmlElement* child = node->FirstChildElement(
"Variable");
889 child = child->NextSiblingElement(
"Variable");
891 node = node->NextSiblingElement(
"Environment");
924 for(std::size_t index = 0U; index < paths.Count(); ++index)
927 path = makePathRelativeIfNeeded(path, basePath);
945 std::vector<wxString> finalFiles;
946 for(std::size_t file = 0; file < files.Count(); ++file)
948 const wxString& fileName = files[file];
949 bool MatchesWildCard =
false;
950 for (std::size_t x = 0; x < wilds.
GetCount(); ++x)
952 if (fileName.
Matches(wilds[x].Lower()))
954 MatchesWildCard =
true;
960 finalFiles.push_back(fileName);
966 std::vector<wxString> filesInDir(
const wxString& directory,
const wxString& wildCard,
bool recursive,
const wxString& basePath)
968 const wxString directoryPath = makePathAbsoluteIfNeeded(directory, basePath);
969 std::vector<wxString> files;
978 filesUnfiltered = makePathsRelativeIfNeeded(filesUnfiltered, basePath);
979 return filterOnWildcards(filesUnfiltered, wildCard);
991 std::vector<cbProject::Glob> unitsGlobs;
993 const std::string UnitsGlobLabel(
"UnitsGlob");
994 const TiXmlElement* unitsGlob = parentNode->FirstChildElement(UnitsGlobLabel.c_str());
997 const wxString directory =
cbC2U(unitsGlob->Attribute(
"directory"));
998 const wxString wildCard =
cbC2U(unitsGlob->Attribute(
"wildcard"));
1001 unitsGlob->QueryIntAttribute(
"recursive", &recursive);
1005 const bool isRecursive = (recursive)?
true:
false;
1006 unitsGlobs.push_back(
cbProject::Glob(directory, wildCard, isRecursive));
1007 std::vector<wxString> files = filesInDir(directory, wildCard, isRecursive,
m_pProject->
GetBasePath());
1008 for (std::size_t index = 0; index < files.size(); ++index)
1010 const wxString filename = files[index];
1017 const TiXmlElement dummyUnitWithoutOptions(
"Unit");
1022 unitsGlob = unitsGlob->NextSiblingElement(UnitsGlobLabel.c_str());
1026 const TiXmlElement* unit = parentNode->FirstChildElement(
"Unit");
1029 const wxString filename =
cbC2U(unit->Attribute(
"filename"));
1042 unit = unit->NextSiblingElement(
"Unit");
1051 bool foundCompile =
false;
1052 bool foundLink =
false;
1053 bool foundCompilerVar =
false;
1054 bool foundTarget =
false;
1055 bool noTarget =
false;
1059 const TiXmlElement* node = parentNode->FirstChildElement(
"Option");
1062 if (node->Attribute(
"compilerVar"))
1065 foundCompilerVar =
true;
1068 if (node->QueryIntAttribute(
"compile", &tempval) == TIXML_SUCCESS)
1071 foundCompile =
true;
1074 if (node->QueryIntAttribute(
"link", &tempval) == TIXML_SUCCESS)
1076 file->
link = tempval != 0;
1080 if (node->QueryIntAttribute(
"weight", &tempval) == TIXML_SUCCESS)
1083 if (node->Attribute(
"virtualFolder"))
1086 if (node->Attribute(
"buildCommand") && node->Attribute(
"compiler"))
1090 if (!cmp.
IsEmpty() && !tmp.IsEmpty())
1094 if (node->QueryIntAttribute(
"use", &tempval) == TIXML_SUCCESS)
1099 if (node->Attribute(
"target"))
1111 node = node->NextSiblingElement(
"Option");
1122 if (!foundCompilerVar)
1126 if (!foundTarget && !noTarget)
1148 TiXmlElement elem(name);
1151 elem.SetAttribute(attr,
cbU2C(attribute));
1153 return parent->InsertEndChild(elem)->ToElement();
1159 TiXmlElement elem(name);
1162 elem.SetAttribute(attr, attribute);
1164 return parent->InsertEndChild(elem)->ToElement();
1173 for (
unsigned int i = 0; i < array.
GetCount(); ++i)
1175 if (array[i].IsEmpty())
1191 typedef std::map<wxString, wxString> SortedMap;
1193 for (StringHash::const_iterator it = v.begin(); it != v.end(); ++it)
1194 map[it->first] = it->second;
1196 TiXmlElement* node =
AddElement(parent,
"Environment");
1197 for (SortedMap::const_iterator it = map.begin(); it != map.end(); ++it)
1199 TiXmlElement* elem =
AddElement(node,
"Variable",
"name", it->first);
1200 elem->SetAttribute(
"value",
cbU2C(it->second));
1206 return Save(filename,
nullptr);
1221 const char* ROOT_TAG =
"CodeBlocks_project_file";
1224 doc.SetCondenseWhiteSpace(
false);
1225 doc.InsertEndChild(TiXmlDeclaration(
"1.0",
"UTF-8",
"yes"));
1226 TiXmlElement* rootnode =
static_cast<TiXmlElement*
>(doc.InsertEndChild(TiXmlElement(ROOT_TAG)));
1232 rootnode->InsertEndChild(TiXmlElement(
"FileVersion"));
1236 rootnode->InsertEndChild(TiXmlElement(
"Project"));
1237 TiXmlElement* prjnode = rootnode->FirstChildElement(
"Project");
1243 AddElement(prjnode,
"Option",
"platforms", platforms);
1248 AddElement(prjnode,
"Option",
"makefile_is_custom", 1);
1258 if (virtualFolders.GetCount() > 0)
1261 for (
size_t i = 0; i < virtualFolders.GetCount(); i++)
1268 AddElement(prjnode,
"Option",
"virtualFolders", result);
1272 AddElement(prjnode,
"Option",
"extended_obj_names", 1);
1278 TiXmlElement* notes =
AddElement(notesBase,
"notes");
1281 notes->InsertEndChild(t);
1285 AddElement(prjnode,
"Option",
"check_files", 0);
1289 TiXmlElement* makenode =
AddElement(prjnode,
"MakeCommands");
1298 prjnode->InsertEndChild(TiXmlElement(
"Build"));
1299 TiXmlElement* buildnode = prjnode->FirstChildElement(
"Build");
1315 if (onlytgt && onlytgt != target)
1318 TiXmlElement* tgtnode =
AddElement(buildnode,
"Target",
"title", target->
GetTitle());
1322 AddElement(tgtnode,
"Option",
"platforms", platforms);
1351 if (outputFileNameFile.StartsWith(compilerLibPrefix))
1353 outputFileNameWOPrefix = outputFileNameFile.
Mid(compilerLibPrefix.Len());
1354 if (!outputFileNameWOPrefix.IsEmpty())
1372 outnode->SetAttribute(
"extension_auto", extensionPolicy ==
tgfpPlatformDefault ?
"1" :
"0");
1388 AddElement(tgtnode,
"Option",
"use_console_runner", 0);
1395 AddElement(tgtnode,
"Option",
"run_host_application_in_terminal", 1);
1397 AddElement(tgtnode,
"Option",
"run_host_application_in_terminal", 0);
1404 AddElement(tgtnode,
"Option",
"createDefFile", 1);
1406 AddElement(tgtnode,
"Option",
"createStaticLib", 1);
1421 TiXmlElement* node =
AddElement(tgtnode,
"Compiler");
1424 if (node->NoChildren())
1425 tgtnode->RemoveChild(node);
1427 node =
AddElement(tgtnode,
"ResourceCompiler");
1430 if (node->NoChildren())
1431 tgtnode->RemoveChild(node);
1437 if (node->NoChildren())
1438 tgtnode->RemoveChild(node);
1443 if (node->NoChildren())
1444 tgtnode->RemoveChild(node);
1455 TiXmlElement* makenode =
AddElement(tgtnode,
"MakeCommands");
1468 TiXmlElement* virtnode =
AddElement(prjnode,
"VirtualTargets");
1470 for (
size_t i = 0; i < virtuals.
GetCount(); ++i)
1476 TiXmlElement* elem =
AddElement(virtnode,
"Add",
"alias", virtuals[i]);
1477 elem->SetAttribute(
"targets",
cbU2C(groupStr));
1480 if (virtnode->NoChildren())
1481 prjnode->RemoveChild(virtnode);
1486 TiXmlElement* node =
AddElement(prjnode,
"Compiler");
1489 if (node->NoChildren())
1490 prjnode->RemoveChild(node);
1492 node =
AddElement(prjnode,
"ResourceCompiler");
1495 if (node->NoChildren())
1496 prjnode->RemoveChild(node);
1502 if (node->NoChildren())
1503 prjnode->RemoveChild(node);
1508 if (node->NoChildren())
1509 prjnode->RemoveChild(node);
1516 std::vector<wxString> filesThrougGlobs;
1518 for (std::size_t index = 0; index < unitGlobs.size(); ++index)
1521 if (TiXmlElement* unitsGlobNode =
AddElement(prjnode,
"UnitsGlob",
"directory", glob.
m_Path))
1523 unitsGlobNode->SetAttribute(
"recursive", glob.
m_Recursive ?
"1" :
"0");
1527 std::copy(files.begin(), files.end(), std::back_inserter(filesThrougGlobs));
1540 if (std::find(filesThrougGlobs.begin(), filesThrougGlobs.end(), f->
relativeFilename) != filesThrougGlobs.end())
1549 for (
size_t i=0; i<pfa.GetCount(); ++i)
1591 TiXmlElement* elem =
AddElement(unitnode,
"Option",
"compiler", it->first);
1593 elem->SetAttribute(
"buildCommand",
cbU2C(tmp));
1606 AddElement(unitnode,
"Option",
"target",
_T(
"<{~None~}>"));
1610 TiXmlElement* extnode = pExtensions
1611 ? prjnode->InsertEndChild(*pExtensions)->ToElement()
1636 if (proposal.
ToLong(&idx))
1642 if(!(
Manager::Get()->GetConfigManager(
_T(
"app"))->ReadBool(
_T(
"/environment/ignore_invalid_targets"),
true)))
1645 msg.
Printf(
_(
"The defined compiler for %s cannot be located (ID: %s).\n" 1646 "Please choose the compiler you want to use instead and click \"OK\".\n" 1647 "If you click \"Cancel\", the project/target will be excluded from the build."), scope.
c_str(),
1664 return compiler->GetID();
void DoUnits(const TiXmlElement *parentNode)
wxString AfterLast(wxUniChar ch) const
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 SetOptionRelation(OptionsRelationType type, OptionsRelation rel)
Set the target's options relation for type to rel.
virtual void GetTargetFilenameGenerationPolicy(TargetFilenameGenerationPolicy &prefixOut, TargetFilenameGenerationPolicy &extensionOut) const
#define PROJECT_FILE_VERSION_MAJOR
void SetMakefileCustom(bool custom)
Mark if the project should use a custom Makefile for compilation.
virtual void SetMakeCommandFor(MakeCommand cmd, const wxString &make)
Set the "make" command used for cmd.
bool Matches(const wxString &mask) const
unsigned short int weight
The weight.
TargetFilenameGenerationPolicy
A target's filename can either be auto-generated based on the running platform, or completely specifi...
void DoUnitOptions(const TiXmlElement *parentNode, ProjectFile *file)
void SetVirtualFolders(const wxArrayString &folders)
Set the virtual folders list.
void SetModeForPCH(PCHMode mode)
Set the mode to handle precompiled headers.
virtual bool GetCreateDefFile() const
Valid only for targets generating dynamic libraries (DLLs or SOs).
wxString relativeFilename
The relative (to the project) filename of this file.
DLLIMPORT void CallHooks(cbProject *project, TiXmlElement *elem, bool isLoading)
Call all registered hooks using the supplied parameters.
bool Save(const wxString &filename) override
Save a file.
virtual bool GetUseConsoleRunner() const
Valid only for targets generating a console executable.
~ProjectLoader() override
Destructor.
void DoBuildTarget(TiXmlElement *parentNode)
virtual const wxString & GetAdditionalOutputFiles() const
virtual void SetObjectOutput(const wxString &dirname)
Set the target's objects output dir.
void SetDefaultExecuteTarget(const wxString &name)
Set the build target index which will be pre-selected when the "Select target" dialog appears when ru...
void SetFullName(const wxString &fullname)
CompilerSubstitutes m_CompilerSubstitutes
virtual wxString GetDepsOutput() const
Read the target's dependencies output dir.
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
bool DefineVirtualBuildTarget(const wxString &alias, const wxArrayString &targets)
Define a new virtual build target.
virtual void AddCommandsAfterBuild(const wxString &command)
virtual const wxString & GetExecutionParameters() const
Read the target's execution parameters.
Linker include dir option.
virtual void SetCreateDefFile(bool createIt)
Set if the target creates a DEF imports file.
virtual const wxString & GetHostApplication() const
Read the target's host application.
void SetShowNotesOnLoad(bool show)
Set show project notes on load automatically.
void DoExtraCommands(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
virtual const wxString & GetExternalDeps() const
bool compile
Compile flag.
void SaveEnvironment(TiXmlElement *parent, CompileOptionsBase *base)
void SetModified(bool modified=true) override
Mark the project as modified or not.
unsigned int GetGroupsCount() const
Return total number of groups.
PCHMode GetModeForPCH() const
void DoBuildTargetOptions(TiXmlElement *parentNode, ProjectBuildTarget *target)
bool GetCheckForExternallyModifiedFiles() const
Get check for externally modified files.
PCHMode
Precompiled headers mode.
virtual void AddBuildScript(const wxString &script)
virtual const wxArrayString & GetCompilerOptions() const
static Compiler * GetCompiler(size_t index)
virtual void AddIncludeDir(const wxString &option)
FileType
Known file types.
bool LoadDocument(const wxString &filename, TiXmlDocument *doc)
void AddArrayOfElements(TiXmlElement *parent, const char *name, const char *attr, const wxArrayString &array, bool isPath=false)
void EndAddFiles()
Notify that file(s) addition finished.
wxString GetValidCompilerID(const wxString &proposal, const wxString &scope)
virtual void SetIncludeInTargetAll(bool buildIt)
Deprecated, do not use at all! Set if this target should be built when the virtual target "All" is se...
const DLLIMPORT wxString C_EXT
const wxCharBuffer mb_str(const wxMBConv &conv=wxConvLibc) const
DLLIMPORT wxString GetStringFromArray(const wxArrayString &array, const wxString &separator=DEFAULT_ARRAY_SEP, bool SeparatorAtEnd=true)
bool IsAbsolute(wxPathFormat format=wxPATH_NATIVE) const
DLLIMPORT FileType FileTypeOf(const wxString &filename)
virtual void SetTargetFilenameGenerationPolicy(TargetFilenameGenerationPolicy prefix, TargetFilenameGenerationPolicy extension)
A target's filename can either be auto-generated based on the running platform, or completely specifi...
virtual void SetExecutionParameters(const wxString ¶ms)
Set the target's execution parameters to params.
wxString & Remove(size_t pos)
static size_t GetAllFiles(const wxString &dirname, wxArrayString *files, const wxString &filespec=wxEmptyString, int flags=wxDIR_DEFAULT)
virtual void SetUseConsoleRunner(bool useIt)
Set if ConsoleRunner should be used.
virtual void SetImportLibraryFilename(const wxString &filename)
Set the target's import library filename.
virtual const wxArrayString & GetBuildScripts() const
virtual bool MakeCommandsModified() const
True if any of the "make" commands is modified.
Represents a file in a Code::Blocks project.
virtual wxString GetOutputFilename()
Read the target's output filename.
virtual bool GetCreateStaticLib()
Valid only for targets generating dynamic libraries (DLLs or SOs).
void BeginAddFiles()
Notify that file(s) will be added shortly.
virtual void SetCompilerID(const wxString &id)
! Set the flag if the host app should be run in terminal
virtual bool GetRunHostApplicationInTerminal() const
Get the flag if the host app should be run in terminal.
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 SetDefinitionFileFilename(const wxString &filename)
Set the target's definition file filename.
static Compiler * SelectCompilerUI(const wxString &message=_("Select compiler"), const wxString &preselectedID=wxEmptyString)
bool ExportTargetAsProject(const wxString &filename, const wxString &onlyTarget, TiXmlElement *pExtensions)
Export a target as a new project.
const wxString & GetMakefile()
wxString GetFileMasks(unsigned int group) const
Return a specific group file mask.
bool MakeRelativeTo(const wxString &pathBase=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
void DoCompilerOptions(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
virtual void AddResourceIncludeDir(const wxString &option)
void SetCompilerID(const wxString &id) override
! Set the flag if the host app should be run in terminal
void DoVirtualTargets(TiXmlElement *parentNode)
virtual OptionsRelation GetOptionRelation(OptionsRelationType type) const
Read the target's options relation for type.
virtual void SetHostApplication(const wxString &app)
Set the target's host application to app.
DLLIMPORT wxString UnixFilename(const wxString &filename, wxPathFormat format=wxPATH_NATIVE)
virtual const wxArrayString & GetResourceIncludeDirs() const
Represents a Code::Blocks project.
virtual const wxArrayString & GetLinkerOptions() const
virtual void AddLinkLib(const wxString &option)
virtual void AddCommandsBeforeBuild(const wxString &command)
virtual const wxArrayString & GetLinkLibs() const
virtual void AddCompilerOption(const wxString &option)
virtual wxString GetDynamicLibImportFilename()
Read the target's dynamic library import filename (produced if target type is ttDynamicLib) ...
virtual void SetOutputFilename(const wxString &filename)
Set the target's output filename.
virtual wxString GetMakeCommandFor(MakeCommand cmd) const
Get the "make" command used for cmd.
wxString GetMakefileExecutionDir()
DLLIMPORT wxString cbC2U(const char *str)
Return str as a proper unicode-compatible string.
virtual const wxString & GetTitle() const
Read the target's title.
void DoBuild(TiXmlElement *parentNode)
Resource compiler include dir option.
virtual void AddLibDir(const wxString &option)
virtual const wxArrayString & GetResourceCompilerOptions() const
Target produces a dynamic library.
size_t Replace(const wxString &strOld, const wxString &strNew, bool replaceAll=true)
OptionsRelation
Option's relation.
#define PROJECT_FILE_VERSION_MINOR
bool Open(const wxString &filename) override
Open a file.
void SetCheckForExternallyModifiedFiles(bool check)
Set check for externally modified files.
bool IsSameAs(const wxString &s, bool caseSensitive=true) const
TiXmlElement * AddElement(TiXmlElement *parent, const char *name, const char *attr=nullptr, const wxString &attribute=wxEmptyString)
static bool IsBatchBuild()
LogManager * GetLogManager() const
wxString & Item(size_t nIndex)
pfCustomBuildMap customBuild
A map for custom builds.
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
Compiler include dir option.
virtual const wxArrayString & GetCommandsAfterBuild() const
virtual wxString GetWorkingDir()
Read the target's working dir for execution (valid only for executable targets)
virtual void SetExternalDeps(const wxString &deps)
Set a list of all the external files this targets depends on.
This is a base class for all classes needing compilation parameters.
virtual void SetWorkingDir(const wxString &dirname)
Set the target's working dir on execution (valid only for executable targets)
virtual void AddResourceCompilerOption(const wxString &option)
const wxArrayString & GetVirtualBuildTargetGroup(const wxString &alias) const
Access a virtual build target's group of build targets.
wxString Right(size_t count) const
virtual void SetAlwaysRunPostBuildSteps(bool always)
static int CompareProjectFiles(ProjectFile *item1, ProjectFile *item2)
Compare relative names of projectfiles.
const wxString & GetNotes() const
Get notes on the project.
ProjectFile * AddFile(const wxString &targetName, const wxString &filename, bool compile=true, bool link=true, unsigned short int weight=50)
Add a file to the project.
virtual void SetCreateStaticLib(bool createIt)
Set if an import library should be created.
void SetCustomBuildCommand(const wxString &compilerId, const wxString &newBuildCommand)
Modify customBuild command for a compilerId.
No automatic generation; let the user specify the full filename.
const wxString & _(const wxString &string)
wxString & Trim(bool fromRight=true)
void DoLibsOptions(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
int GetBuildTargetsCount()
virtual FilesList & GetFilesList()
Provides an easy way to iterate all the files belonging in this target.
void SetMakefile(const wxString &makefile)
Set the Makefile filename used when exporting a Makefile for the project, or when using a custom Make...
virtual const wxArrayString & GetIncludeDirs() const
In a dir (named by the PCH) on the same level as the source header (default).
ProjectFilesVector generatedFiles
Auto-generated files when compiling this file.
bool useCustomBuildCommand
wxString compilerVar
The compiler variable used for this file (e.g CPP, CC, etc).
wxArrayString GetVirtualBuildTargets() const
Get a list of all defined virtual build targets.
Target produces a static library.
void SetGlobs(const std::vector< Glob > &globs)
Set the globs to the project, this are directory paths do retrieve files from to be added to the proj...
virtual void SetDepsOutput(const wxString &dirname)
Set the target's dependencies output dir.
ProjectBuildTarget * GetBuildTarget(int index)
Access a build target.
bool ToLong(long *val, int base=10) const
Abstract base class for compilers.
const wxString & GetDefaultExecuteTarget() const
const wxArrayString & GetVirtualFolders() const
Get a list of the virtual folders.
bool GetExtendedObjectNamesGeneration() const
Gets object names generation mode (extended/normal).
void DoProjectOptions(TiXmlElement *parentNode)
virtual bool GetAlwaysRunPostBuildSteps() const
virtual const wxArrayString & GetLibDirs() const
virtual const wxString & GetCompilerID() const
Read the target's compiler.
Target produces a console executable (without GUI) (distinction between ttExecutable and ttConsoleOnl...
virtual bool SetVar(const wxString &key, const wxString &value, bool onlyIfExists=false)
bool GetShowNotesOnLoad() const
Get show project notes on load automatically.
wxString GetFullName() const
void DebugLog(const wxString &msg, Logger::level lv=Logger::info)
virtual const CompilerSwitches & GetSwitches() const
Get the compiler's generic switches.
void DoEnvironment(TiXmlElement *parentNode, CompileOptionsBase *base)
wxString virtual_path
A string that represents the virtual folder this file will appear in.
void SetTargetType(TargetType pt) override
Set the target's type to pt.
wxString & Prepend(const wxString &str)
void ConvertVersion_Pre_1_1()
void DoIncludesOptions(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
size_t Add(const wxString &str, size_t copies=1)
bool HasVirtualBuildTarget(const wxString &alias) const
Does a virtual build target exist?
bool StartsWith(const wxString &prefix, wxString *rest=NULL) const
void SetTitle(const wxString &title) override
Changes project title.
void ConvertLibraries(CompileTargetBase *object)
void DoLinkerOptions(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
Represents a Code::Blocks project build target.
void SetExtendedObjectNamesGeneration(bool ext)
Sets object names generation to extended/normal mode.
ProjectFile * AutoGeneratedBy() const
If this is an auto-generated file, which file is generating it?
void SetUseCustomBuildCommand(const wxString &compilerId, bool useCustomBuildCommand)
Modify 'Use custom command to build this file' for a compilerId.
void SetNotes(const wxString ¬es)
Set notes on the project.
int m_1_4_to_1_5_deftarget
ProjectBuildTarget * AddBuildTarget(const wxString &targetName)
Add a new build target.
virtual void AddLinkerOption(const wxString &option)
void DoMakeCommands(TiXmlElement *parentNode, CompileTargetBase *target)
bool MakeAbsolute(const wxString &cwd=wxEmptyString, wxPathFormat format=wxPATH_NATIVE)
void AddBuildTarget(const wxString &targetName)
Make this file belong to an additional build target.
void RemoveAt(size_t nIndex, size_t count=1)
int Printf(const wxString &pszFormat,...)
virtual wxString GetObjectOutput() const
Read the target's objects output dir.
void DoResourceCompilerOptions(TiXmlElement *parentNode, ProjectBuildTarget *target=nullptr)
wxString GetFullPath(wxPathFormat format=wxPATH_NATIVE) const
TargetType
Enum to define the type of output the target produces.
virtual const StringHash & GetAllVars() const
DLLIMPORT bool cbSaveTinyXMLDocument(TiXmlDocument *doc, const wxString &filename)
Saves a TinyXML document correctly, even if the path contains unicode characters. ...
virtual wxString GetDynamicLibDefFilename()
Read the target's dynamic library definition file filename (produced if target type is ttDynamicLib) ...
virtual void SetRunHostApplicationInTerminal(bool in_terminal)
const DLLIMPORT wxString RESOURCE_EXT
wxArtID wxART_INFORMATION
static wxString Format(const wxString &format,...)
virtual bool GetIncludeInTargetAll() const
Deprecated, do not use at all!
wxString Mid(size_t first, size_t nCount=wxString::npos) const
virtual void SetAdditionalOutputFiles(const wxString &files)
Set a list of all additional output files this targets creates, besides its main output.
void SetMakefileExecutionDir(const wxString &dir)
Allow the specification of specific execution directory if the project use a custom Makefile...
Dialog that contains a "Don't annoy me" checkbox.
DLLIMPORT int cbMessageBox(const wxString &message, const wxString &caption=wxEmptyString, int style=wxOK, wxWindow *parent=NULL, int x=-1, int y=-1)
wxMessageBox wrapper.
std::vector< Glob > GetGlobs() const
Retrieve the current globs from the project.
wxArrayString buildTargets
An array of strings, containing the names of all the build targets this file belongs to...
wxString GetFirstValidBuildTargetName(bool virtuals_too=true) const
DLLIMPORT bool HasRegisteredHooks()
Are there any hooks registered?
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.
virtual const wxArrayString & GetCommandsBeforeBuild() const