Author Topic: XML based compilers  (Read 94980 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #75 on: July 23, 2012, 05:10:08 am »
Maybe this is a slightly tidier way to fix PCH for compilerXML.cpp:
Code: [Select]
-#include <wx/string.h>
+class wxString;
[...]
         wxString m_fileName;
That is wrong. You cannot use a fwd decl if you are using  an instance of wxString.
I must have been working without actually thinking... I completely did not see that variable (though I do not know how, as I was the one who wrote it :-[).

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #76 on: July 28, 2012, 03:43:45 am »
In this patch, converted to pure XML:
  • GNU GCC Compiler for AVR
  • Borland C++ Compiler (5.5, 5.82)
  • Digital Mars D Compiler

I cannot think of any major changes/additions (other than possibly converting a few more interfaces to pure XML) from my part to this branch that will occur in the near future, so I think this branch is ready for whatever the next step is (maybe a nightly?) to be considered for integration with the trunk.

(Again, I would recommend to anyone who is testing this that they start with a clean profile.)

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #77 on: July 28, 2012, 04:03:36 pm »
I cannot think of any major changes/additions (other than possibly converting a few more interfaces to pure XML)
I agree. The fact that you converted so many compiler already is also a proof f the concept. 8)
What's needed from my point of view is:
- testing under other platforms
- build test under Linux
- testing the use of macros for path's, executables etc...

I've merged  trunk into the branch so all devs/willing people can try this branch w/o loosing features from trunk.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #78 on: July 31, 2012, 03:15:49 am »
Compiler logging tweaks:
  • Clear progress bar on abort
  • Remove tabs from build messages (so they do not print as squares)
  • Auto adjust build message size
Code: [Select]
Index: src/sdk/loggers.cpp
===================================================================
--- src/sdk/loggers.cpp (revision 8175)
+++ src/sdk/loggers.cpp (working copy)
@@ -340,7 +340,7 @@
     control->Thaw();
 }
 
-void ListCtrlLogger::Append(const wxArrayString& colValues, Logger::level lv)
+void ListCtrlLogger::Append(const wxArrayString& colValues, Logger::level lv, int autoSize)
 {
     if (!control)
         return;
@@ -353,6 +353,8 @@
     int idx = control->GetItemCount() - 1;
     for (size_t i = 1; i < colValues.GetCount(); ++i)
         control->SetItem(idx, i, colValues[i]);
+    if (autoSize != -1)
+        control->SetColumnWidth(autoSize, wxLIST_AUTOSIZE);
     control->Thaw();
 }
 
Index: src/plugins/compilergcc/compilergcc.cpp
===================================================================
--- src/plugins/compilergcc/compilergcc.cpp (revision 8175)
+++ src/plugins/compilergcc/compilergcc.cpp (working copy)
@@ -3382,7 +3382,9 @@
     wxArrayString errors;
     errors.Add(filename);
     errors.Add(line);
-    errors.Add(msg);
+    wxString msgFix = msg;
+    msgFix.Replace(wxT("\t"), wxT("    "));
+    errors.Add(msgFix);
 
     Logger::level lv = Logger::info;
     if (lt == cltError)
@@ -3390,8 +3392,7 @@
     else if (lt == cltWarning)
         lv = Logger::warning;
 
-    m_pListLog->Append(errors, lv);
-//    m_pListLog->GetListControl()->SetColumnWidth(2, wxLIST_AUTOSIZE);
+    m_pListLog->Append(errors, lv, 2);
 
     // add to error keeping struct
     m_Errors.AddError(lt, prj, filename, line.IsEmpty() ? 0 : atoi(wxSafeConvertWX2MB(line)), msg);
@@ -3642,6 +3643,8 @@
             LogWarningOrError(cltNormal, 0, wxEmptyString, wxEmptyString,
                               wxString::Format(_("=== Build finished: %s ==="), msg.wx_str()));
             SaveBuildLog();
+            if (!Manager::IsBatchBuild() && m_pLog->progress)
+                m_pLog->progress->SetValue(0);
         }
         else
         {
@@ -3665,9 +3668,6 @@
             Manager::Get()->ProcessEvent(evtSwitch);
 
             m_pListLog->FocusError(m_Errors.GetFirstError());
-            // Build is not completed, so clear the progress bar
-            if (m_pLog->progress)
-                m_pLog->progress->SetValue(0);
         }
         else
         {
Index: src/include/loggers.h
===================================================================
--- src/include/loggers.h (revision 8175)
+++ src/include/loggers.h (working copy)
@@ -136,7 +136,7 @@
     virtual void      CopyContentsToClipboard(bool selectionOnly = false);
     virtual void      UpdateSettings();
     virtual void      Append(const wxString& msg, Logger::level lv = info);
-    virtual void      Append(const wxArrayString& colValues, Logger::level lv = info);
+    virtual void      Append(const wxArrayString& colValues, Logger::level lv = info, int autoSize = -1);
     virtual size_t    GetItemsCount() const;
     virtual void      Clear();
     virtual wxWindow* CreateControl(wxWindow* parent);

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #79 on: July 31, 2012, 06:44:28 am »
@Jens: Do you / Did you try that "beast" under Linux already?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7143
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: XML based compilers
« Reply #80 on: July 31, 2012, 07:59:40 am »
@Jens: Do you / Did you try that "beast" under Linux already?

Yes, but no really deep tests.

At least it works fine to compile and debug C::B and the contrib-plugins and some other (makefile-based) projects (wxWidgets trunk with gtk2 and gtk3 and aui and notebooks samples).
All compiled with gcc, but makefile-based projects should not be changed (much?) anyway, I think.

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 9870
Re: XML based compilers
« Reply #81 on: July 31, 2012, 08:40:54 am »
Compiler logging tweaks:
  • Clear progress bar on abort
  • Remove tabs from build messages (so they do not print as squares)
  • Auto adjust build message size
Keep in mind that changing the interface of public for the SDK class requires an increase of the SDK version (the macros at the top of the cbplugin.h file).
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #82 on: July 31, 2012, 11:01:12 pm »
Keep in mind that changing the interface of public for the SDK class requires an increase of the SDK version (the macros at the top of the cbplugin.h file).
Yes (and I would assume that there are multiple other changes in this branch that would also require an SDK version increment), however, as this is a branch, would it not be better to only have a single increment upon merging with the trunk?

Another logging tweak and the removal of a GCC 4.7 warning:
Code: [Select]
Index: src/sdk/compiler.cpp
===================================================================
--- src/sdk/compiler.cpp (revision 8176)
+++ src/sdk/compiler.cpp (working copy)
@@ -1013,11 +1013,9 @@
         }
         else if (node->GetName() == wxT("RegEx"))
         {
-            CompilerLineType clt;
             wxString tp = node->GetAttribute(wxT("type"), wxEmptyString);
-            if (tp == wxT("normal"))
-                clt = cltNormal;
-            else if (tp == wxT("warning"))
+            CompilerLineType clt = cltNormal;
+            if (tp == wxT("warning"))
                 clt = cltWarning;
             else if (tp == wxT("error"))
                 clt = cltError;
Index: src/plugins/compilergcc/directcommands.cpp
===================================================================
--- src/plugins/compilergcc/directcommands.cpp (revision 8176)
+++ src/plugins/compilergcc/directcommands.cpp (working copy)
@@ -583,8 +583,8 @@
     if (!fileMissing.IsEmpty())
     {
         wxString warn;
-        warn.Printf(_("WARNING: Target '%s': Unable to resolve %d external dependencies:"),
-                    target->GetFullTitle().wx_str(), fileMissing.Count());
+        warn.Printf(_("WARNING: Target '%s': Unable to resolve %d external dependenc%s:"),
+                    target->GetFullTitle().wx_str(), fileMissing.Count(), wxString(fileMissing.Count() == 1 ? _("y") : _("ies")).wx_str());
         ret.Add(wxString(COMPILER_SIMPLE_LOG) + warn);
         for (size_t i=0; i<fileMissing.Count(); i++)
             ret.Add(wxString(COMPILER_SIMPLE_LOG) + fileMissing[i]);

Online oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 9870
Re: XML based compilers
« Reply #83 on: August 01, 2012, 12:05:47 am »
Yes (and I would assume that there are multiple other changes in this branch that would also require an SDK version increment), however, as this is a branch, would it not be better to only have a single increment upon merging with the trunk?
For me it is better to increment the sdk version number with every break of the api, you can't be sure if there are users running your code and if they have custom plugins or not.
<debugger plugin maintainer>
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #84 on: August 01, 2012, 06:22:14 am »
For me it is better to increment the sdk version number with every break of the api, you can't be sure if there are users running your code and if they have custom plugins or not.
Branches are for people knowing what they do. When merged, the SDK major version will increase anyways due to the massive change (as it was with the debugger re-factoring). But in principle you are right... ::)
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #85 on: August 02, 2012, 11:29:24 am »
Al-right, concerning the next movement/discussion between devs, here is something to share. Please continue all discussion on that topic here, not via PM.

Quote from: MortenMacFly
Maybe to clarify a few bits:
You have to differ between compiler settings like flags. Those are in XML files in C::B\share\CodeBlocks\compilers. Those are nicely grouped, i.e. common settings between compilers are shared.

If you change compiler flags (like adding a compiler flag in the compiler options) a copy of that XML file is created in C::B\share\CodeBlocks\compilers which superseeds the old one, but also includes ALL shared (common) parts.

Then you have user settings, like concrete path's which are mapped to the compiler's global settings available but are an "instance". Those are in default.conf and remain there (and belong there, too).

BTW:  Alpha did a very nice WiKi article explaining the concept here:
http://wiki.codeblocks.org/index.php?title=Compiler_options_file

I meanwhile found the following issues: Compiler ID's have indeed changed for:
armelfgcc -> arm_elf_gcc
avrgcc -> avr_gcc
msp430gcc -> msp430_gcc
ppcgcc -> ppc_gcc
tricoregcc -> tricore_gcc

I think I know why, because in the initial algorithm to compile the ID there was a comment stating that to make a compiler ID valid XML all underscores need to be removed. This is wrong (however), so Alpha asked me to remove that check and I said yes. That's why now there is an underscore. Actually this is more correct, but causes trouble. The solution here is, also to check for the old style, when reading, but write the new style. (to project files).
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #86 on: August 02, 2012, 11:54:21 am »
One issue, that is indeed true (and causes missing compiler flags) is the use of "-dumpversion" instead of "--version" for the compiler version detection regex. The result of dumpversion is 4.7 (so only major and minor), while --version shows more, e.g. 4.7.2 (including revision). Thats why the RegEx fails and therefore some compiler flags are missing.

So either we use --version, or make the RegEx just check for major.minor (which should be enough IMHO), or call both - the --version thing as a fallback.

Preferred solution?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9415
Re: XML based compilers
« Reply #87 on: August 02, 2012, 12:15:05 pm »
There is indeed a bug: If you make a copy of a compiler, the settings for the new compiler become applied to the last compiler already existing in the list.
I think the reason is here:
Code: [Select]
void Compiler::ReloadOptions()
{
    if (ConfigManager::LocateDataFile(wxT("compilers/options_") + GetID() + wxT(".xml"), sdDataUser | sdDataGlobal).IsEmpty())
        return; // Do not clear if the options cannot be reloaded
    m_Options.ClearOptions();
    LoadDefaultOptions(GetID());
    LoadDefaultRegExArray();
}
That fails, because there is no XML file with such a name (yet) as it is a user-defined compiler. So this should better check for the parent compiler's ID in addition.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: http://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: http://wiki.codeblocks.org/index.php?title=FAQ

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1506
Re: XML based compilers
« Reply #88 on: August 02, 2012, 03:19:03 pm »
For the curious, I also started documenting the file format for defining pure XML compilers (page is only partially complete).

I am looking into these issues, and should be back with solutions soon.

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 4986
Re: XML based compilers
« Reply #89 on: August 02, 2012, 03:21:58 pm »
don't use --version ==> for cross compilers this can become a mess, causing such regexes to fail very quickly.
-dumpversion, and just major/minor seems ok for me.