Author Topic: XML based compilers  (Read 342092 times)

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: XML based compilers
« Reply #195 on: October 28, 2013, 01:26:27 pm »
I tried your patch but I obtain a compilation error : [...]
I wonder why it worked for me then...
Try this:
Code
Index: src/plugins/compilergcc/compilerXML.cpp
===================================================================
--- src/plugins/compilergcc/compilerXML.cpp (revision 9423)
+++ src/plugins/compilergcc/compilerXML.cpp (working copy)
@@ -15,7 +15,7 @@
 #include "compilerXML.h"
 
 CompilerXML::CompilerXML(const wxString& name, const wxString& ID, const wxString& file)
-    : Compiler(name, ID), m_fileName(file)
+    : Compiler(wxGetTranslation(name), ID), m_fileName(file)
 {
     wxXmlDocument compiler;
     compiler.Load(m_fileName);
Index: src/sdk/compiler.cpp
===================================================================
--- src/sdk/compiler.cpp (revision 9423)
+++ src/sdk/compiler.cpp (working copy)
@@ -963,12 +963,12 @@
             wxString exclusive;
             if (!node->GetAttribute(wxT("exclusive"), &exclusive))
                 exclusive = (exclu ? wxT("true") : wxT("false"));
-            m_Options.AddOption(node->GetAttribute(wxT("name"), wxEmptyString),
+            m_Options.AddOption(wxGetTranslation(node->GetAttribute(wxT("name"), wxEmptyString)),
                                 node->GetAttribute(wxT("option"), wxEmptyString),
-                                category,
+                                wxGetTranslation(category),
                                 node->GetAttribute(wxT("additionalLibs"), wxEmptyString),
                                 node->GetAttribute(wxT("checkAgainst"), wxEmptyString),
-                                node->GetAttribute(wxT("checkMessage"), wxEmptyString),
+                                wxGetTranslation(node->GetAttribute(wxT("checkMessage"), wxEmptyString)),
                                 node->GetAttribute(wxT("supersedes"), wxEmptyString),
                                 exclusive == wxT("true"));
         }
@@ -1121,7 +1121,7 @@
             else if (tp == wxT("info"))
                 clt = cltInfo;
             wxArrayString msg = GetArrayFromString(node->GetAttribute(wxT("msg"), wxEmptyString) + wxT(";0;0"));
-            m_RegExes.Add(RegExStruct(node->GetAttribute(wxT("name"), wxEmptyString), clt,
+            m_RegExes.Add(RegExStruct(wxGetTranslation(node->GetAttribute(wxT("name"), wxEmptyString)), clt,
                                       node->GetNodeContent().Trim().Trim(false), wxAtoi(msg[0]),
                                       wxAtoi(node->GetAttribute(wxT("file"), wxT("0"))),
                                       wxAtoi(node->GetAttribute(wxT("line"), wxT("0"))),

Offline gd_on

  • Lives here!
  • ****
  • Posts: 800
Re: XML based compilers
« Reply #196 on: October 28, 2013, 02:19:53 pm »
With this last patch, it works  ;) (at least on the string I mentioned in my previous post).
Now, my job is : extract all "name" strings from .xml file and add them in my .po file.
Thanks

gd_on
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.5 (tests with 3.3), Msys2 Compilers 14.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3352
Re: XML based compilers
« Reply #197 on: October 28, 2013, 06:58:56 pm »
This is OT but anyway:
Do you really think localizating the compiler flags is a good idea? I mean, if you learn c/c++ or programming in general, you will be forced to learn and use english. If now a noob, who want learn to code, uses a localized IDE (only the compiler flags here) needs help, he will find it with more difficulties, because of the localization. GCC introduced localization a few releases back. I used it 2 times, and tried then to remove it, because i didn't could find any help in my language...
In short: Is compiler specific translation a goof idea?

greetings

Offline gd_on

  • Lives here!
  • ****
  • Posts: 800
Re: XML based compilers
« Reply #198 on: October 28, 2013, 07:43:18 pm »
This is the text accompanying and explaining the flag which is translated, not the flag itself!
So, I think that translating this text may help, a noob or a standard (experienced) user.
Myself, when I doubt on a translation (even on mine  :o), I revert C::B to English, and can see the "official" meaning. Just one or two click and a C::B restart !
I know that many people prefer to use C::B in English and not in their native language. This is their choice.
Myself, I generally prefer to see most of the interface in French, even if in English I understand generally. This is my choice, because I'm more comfortable then.
Both choices have their advantages and disadvantages.

So, yes I like a localized IDE ;). And you are not obliged to use it.

gd_on
« Last Edit: October 30, 2013, 10:57:27 am by gd_on »
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.5 (tests with 3.3), Msys2 Compilers 14.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: XML based compilers
« Reply #199 on: October 30, 2013, 01:03:02 am »
With this last patch, it works  ;) (at least on the string I mentioned in my previous post).
Okay, I will commit soon, if no further problems are identified.

Now, my job is : extract all "name" strings from .xml file and add them in my .po file.
Maybe a script could extract the strings?  It would likely be easier in the long run, for when the .xml files are updated.

Offline gd_on

  • Lives here!
  • ****
  • Posts: 800
Re: XML based compilers
« Reply #200 on: October 30, 2013, 10:55:20 am »
Quote
Maybe a script could extract the strings? 
It's exactly what I do. I have updated my extracting tool and testing it.
The previous version can be found in the forum (links in Code::Blocks' translation posts).
I have added those lines,
Code
echo ""
echo "************************************************"
echo "* extracting strings from .xml compilers files *"
echo "************************************************"
echo ""
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "CodeBlocks_compiler name" > src_xml.cpp 2>> log.txt
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "Option name" >>  src_xml.cpp 2>> log.txt
find ../plugins/compilergcc/resources/compilers | grep -F .xml | xargs grep -F "checkMessage" >> src_xml.cpp 2>> log.txt
grep -v mabi src_xml.cpp | grep -v mno | grep -v apcs | grep -v mtpcs | grep -v mshed | grep -v msoft | grep -v mhard | grep -v mfpe | grep -v msched | grep -v mlong | grep -v mpic | grep -v mcirrus | grep -v mcalle | grep -v mpoke | grep -v mwords > src_xml2.cpp
xgettext -a -o xml.pot src_xml2.cpp
find xml.pot >> files.txt
but I think it could be improved because it still extract some lines that do not need translation.

gd_on
Windows 11 64 bits (23H2), svn C::B (last version or almost!), wxWidgets 3.2.5 (tests with 3.3), Msys2 Compilers 14.1.0, 64 bits (seh, posix : gcc, g++ and gfortran in C:\msys64\mingw64) or 32 bits (dwarf2, posix  in C:\msys64\mingw32).

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: XML based compilers
« Reply #201 on: October 26, 2014, 09:13:04 pm »
An afterthought:

Looking back on this, I think I made a major design failure.  Moving default settings and flags to .xml I still believe was a good choice, however, as soon as I started trying to do things like <if platform="windows"> ... </if>, it became a hack on the purpose of XML.  Logic does not belong at all in a data file.  This should have been either left in code, or (better) migrated to a script.

I guess this is another item to add to my todo list, and a lesson on planning ahead  :-\ .

Offline gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: XML based compilers
« Reply #202 on: November 24, 2020, 09:48:45 am »
An afterthought:

Looking back on this, I think I made a major design failure.  Moving default settings and flags to .xml I still believe was a good choice, however, as soon as I started trying to do things like <if platform="windows"> ... </if>, it became a hack on the purpose of XML.  Logic does not belong at all in a data file.  This should have been either left in code, or (better) migrated to a script.

I guess this is another item to add to my todo list, and a lesson on planning ahead  :-\ .

Sorry to post on this old thread. I acknowledged any CodeBlocks developers' works but I have to say your XML based compiler really caused me to suffer for almost a whole day. I don't want to be rude but I had to say you did make a completely design failure and I do not think XML was a good choice for anything. Sorry.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13406
    • Travis build status
Re: XML based compilers
« Reply #203 on: November 24, 2020, 12:29:23 pm »
Sorry to post on this old thread. I acknowledged any CodeBlocks developers' works but I have to say your XML based compiler really caused me to suffer for almost a whole day. I don't want to be rude but I had to say you did make a completely design failure and I do not think XML was a good choice for anything. Sorry.
+1 here. Squirrel would have been the better choice for defining compiler configurations, but now it is already too late.
If you want to design the same system based on squirrel scripts I could help you with the review and guidance :)
(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 gh_origin

  • Multiple posting newcomer
  • *
  • Posts: 48
Re: XML based compilers
« Reply #204 on: November 25, 2020, 06:56:41 am »
+1 here. Squirrel would have been the better choice for defining compiler configurations, but now it is already too late.
If you want to design the same system based on squirrel scripts I could help you with the review and guidance :)
Thank you but I'm only a high school teacher and I don't have the skills needed to do professional coding. I'm not originally teach programming either but because the school's shortage of teacher I attended a short course and started to teach programming alongside with my own elementary algebra. I only know an outdated subset of C++98 and so do my students but recently some of the curious ones started playing with C++11. I can't help with this, sorry.