Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

PATCH: MSVC import and compiler flags

(1/3) > >>

White-Tiger:
hello all, I've recently fixed the project importer a bit to actually do what it's supposed to do.
for MSVC 10+ projects, it should now import them with almost all config values so that you can import and compile right away (without the need to set up anything manually)
This was previously not given as it basically only imported files but no flags at all (debug wasn't debug, UNICODE not defined, no optimizations, missing libs etc.)

Sadly this patch is quite huge and changed almost everything, and some might not be happy with it at all :P Since I've only updated the msvc10loader not the 7 one... (as I don't care about that one and have no projects to test with anyway)
So the importer for 10+ is quite different to the 7 one.. (you guys tried to keep it in sync...)

Here's a list of actual changes compared to before:

* Import and understand every possible flag for the ability to compile right away. (not perfect, but works so far)
   such as: charset, obj dir, out dir, release/debug, lib name, optimization, runtime, warning level, disabled warnings, output file (also Console and StaticLibrary project types)
* Not only add compiler/linker flags, also add pre/post compile commands
* Ability to differentiate between global and target flags, also better parsing of values
* Macro replacement improved, it now uses the actual Workspace path for $(SolutionDir) etc.
* Adding some default shit for MSVC (libs, pdb file name etc.)
* Actually being able to parse MSVC 12+ files
* Small code cleanup, improvements and bug fixes

For msvc compiler flags:

* changed /DEBUG to lowercase
* I guess "check against "/NDEBUG"" should have been the define: "/DNDEBUG" (couldn't find /NDEBUG as an option and only know about NDEBUG as define)
* added option "Name .pdb same as output file" (which is necessary since the pdb files will otherwise be named after the VC version)
* added character set options such as UNICODE and deprecated MultiByte
* added missing linker warning parsing (caused me once a lot of troubles) also allow exclamation marks in paths (I know it's normally not used, but I use them from time to time, and it doesn't hurt to properly allow it ;) They are valid characters after all)
* added missing runtime library to known ones (static multi-threaded debug)
Also added exclamation marks (!) to global warning/error regexs

--- Code: (patch) ---Index: options_common_re-gf.xml
===================================================================
--- options_common_re-gf.xml (revision 9661)
+++ options_common_re-gf.xml (working copy)
@@ -6,7 +6,7 @@
            msg="4"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Preprocessor error"
            type="error"
@@ -13,7 +13,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
     </RegEx>
     <RegEx name="Compiler warning"
            type="warning"
@@ -20,7 +20,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Compiler error (2)"
            type="error"
@@ -27,7 +27,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
     </RegEx>
     <RegEx name="Compiler error (3)"
            type="error"
@@ -38,7 +38,7 @@
            type="warning"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Linker error"
            type="error"
@@ -45,19 +45,19 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
     </RegEx>
     <RegEx name="Linker error (2)"
            type="error"
            msg="2"
            file="1">
-        <![CDATA[[][{}() \t#%$~[:alnum:]&_:+/\.-]+\(.text\+[0-9A-Za-z]+\):([ \tA-Za-z0-9_:+/\.-]+):[ \t](.*)]]>
+        <![CDATA[[][{}() \t#%$!~[:alnum:]&_:+/\.-]+\(.text\+[0-9A-Za-z]+\):([ \tA-Za-z0-9_:+/\.-]+):[ \t](.*)]]>
     </RegEx>
     <RegEx name="Linker error (3)"
            type="error"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):(.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):(.*)]]>
     </RegEx>
     <RegEx name="Linker error (lib not found)"
            type="error"
@@ -75,7 +75,7 @@
            type="error"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):[ \t](undefined reference.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):[ \t](undefined reference.*)]]>
     </RegEx>
     <RegEx name="General warning"
            type="warning"
Index: options_common_re.xml
===================================================================
--- options_common_re.xml (revision 9661)
+++ options_common_re.xml (working copy)
@@ -10,7 +10,7 @@
            type="info"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):[ \t]+([iI]n ([cC]lass|[cC]onstructor|[dD]estructor|[fF]unction|[mM]ember [fF]unction).*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):[ \t]+([iI]n ([cC]lass|[cC]onstructor|[dD]estructor|[fF]unction|[mM]ember [fF]unction).*)]]>
     </RegEx>
     <RegEx name="'Skipping N instantiation contexts' info (2)"
            type="info"
@@ -17,7 +17,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+(\[[ \t]+[Ss]kipping [0-9]+ instantiation contexts[ \t]+\])]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+(\[[ \t]+[Ss]kipping [0-9]+ instantiation contexts[ \t]+\])]]>
     </RegEx>
     <RegEx name="'Skipping N instantiation contexts' info"
            type="info"
@@ -24,13 +24,13 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]+(\[[ \t]+[Ss]kipping [0-9]+ instantiation contexts[ \t]+\])]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]+(\[[ \t]+[Ss]kipping [0-9]+ instantiation contexts[ \t]+\])]]>
     </RegEx>
     <RegEx name="'In instantiation' warning"
            type="warning"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):[ \t]+([Ii]n [Ii]nstantiation.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):[ \t]+([Ii]n [Ii]nstantiation.*)]]>
     </RegEx>
     <RegEx name="'Required from' warning"
            type="warning"
@@ -37,7 +37,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+([Rr]equired from.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+([Rr]equired from.*)]]>
     </RegEx>
     <RegEx name="'Instantiated from' info (2)"
            type="info"
@@ -44,7 +44,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+([Ii]nstantiated from .*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]+([Ii]nstantiated from .*)]]>
     </RegEx>
     <RegEx name="'Instantiated from' info"
            type="info"
@@ -51,7 +51,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]+([Ii]nstantiated from .*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]+([Ii]nstantiated from .*)]]>
     </RegEx>
     <RegEx name="Resource compiler error"
            type="error"
@@ -58,7 +58,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[windres.exe:[ \t]([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
+        <![CDATA[windres.exe:[ \t]([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
     </RegEx>
     <RegEx name="Resource compiler error (2)"
            type="error"
@@ -70,7 +70,7 @@
            msg="4"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Compiler note (2)"
            type="info"
@@ -77,7 +77,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]([Nn]ote:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]([Nn]ote:[ \t].*)]]>
     </RegEx>
     <RegEx name="Compiler note"
            type="info"
@@ -84,7 +84,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Nn]ote:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Nn]ote:[ \t].*)]]>
     </RegEx>
     <RegEx name="General note"
            type="info"
@@ -96,7 +96,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
     </RegEx>
     <RegEx name="Compiler warning (2)"
            type="warning"
@@ -103,7 +103,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Compiler warning"
            type="warning"
@@ -110,7 +110,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Undefined reference (2)"
            type="error"
@@ -117,7 +117,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[[][{}() \t#%$~[:alnum:]&_:+/\.-]+\.o:([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](undefined reference.*)]]>
+        <![CDATA[[][{}() \t#%$!~[:alnum:]&_:+/\.-]+\.o:([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](undefined reference.*)]]>
     </RegEx>
     <RegEx name="Compiler error (2)"
            type="error"
@@ -124,7 +124,7 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
     </RegEx>
     <RegEx name="Compiler error"
            type="error"
@@ -131,13 +131,13 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[ \t](.*)]]>
     </RegEx>
     <RegEx name="Linker warning"
            type="warning"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):[ \t]([Ww]arning:[ \t].*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):[ \t]([Ww]arning:[ \t].*)]]>
     </RegEx>
     <RegEx name="Linker error"
            type="error"
@@ -144,19 +144,19 @@
            msg="3"
            file="1"
            line="2">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):([0-9]+):[0-9]+:[ \t](.*)]]>
     </RegEx>
     <RegEx name="Linker error (2)"
            type="error"
            msg="2"
            file="1">
-        <![CDATA[[][{}() \t#%$~[:alnum:]&_:+/\.-]+\(.text\+[0-9A-Za-z]+\):([ \tA-Za-z0-9_:+/\.-]+):[ \t](.*)]]>
+        <![CDATA[[][{}() \t#%$!~[:alnum:]&_:+/\.-]+\(.text\+[0-9A-Za-z]+\):([ \tA-Za-z0-9_:+/\.-]+):[ \t](.*)]]>
     </RegEx>
     <RegEx name="Linker error (3)"
            type="error"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):(.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):\(\.text\+[0-9a-fA-FxX]+\):(.*)]]>
     </RegEx>
     <RegEx name="Linker error (lib not found)"
            type="error"
@@ -191,7 +191,7 @@
            type="error"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):[ \t](undefined reference.*)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):[ \t](undefined reference.*)]]>
     </RegEx>
     <RegEx name="General error"
            type="error"
@@ -212,6 +212,6 @@
            type="warning"
            msg="2"
            file="1">
-        <![CDATA[([][{}() \t#%$~[:alnum:]&_:+/\.-]+):[ \t]+(duplicate section.*has different size)]]>
+        <![CDATA[([][{}() \t#%$!~[:alnum:]&_:+/\.-]+):[ \t]+(duplicate section.*has different size)]]>
     </RegEx>
 </CodeBlocks_compiler_options>

--- End code ---
(could only attach 2 attachments... so inline....)

PS: does anyone know how to case insensitively replace stuff? wxString.Replace doesn't seem to be able to... wxRegEx is able to, but I cannot use backslashes (\) in my "replace with" string... but in this case I need paths xD Bad to replace those backslashes with double backslash or slash prior to replace...
Those MSVC macros are not case sensitive.. so it's bad to have the projects importer to handle them that way only because wxWidgets sucks...
I wish they had adopted this 12 years old patch: http://trac.wxwidgets.org/ticket/5422

Melchior:
@White-Tiger
would this patch still work today??

Because I follow many groups and they all of course use MS Visual Studios..
two of them use VS 2015 and the rest idk...


but installing VS is a mess.. because it auto steals ALL of my programming FILE TYPE associations
I had to redo them all.. meh...

plus the Project Importer  could maybe be updated to work with importing up to and including VS 2017
O-o  please.. O_o X_x hmm...

White-Tiger:
well... more or less it should... it's possible that I had to do some modifications as Code::Blocks changed code.
Though it's not entirely superior yet. IIRC I couldn't compile the full Miranda NG source base just by importing, still had to change one or two things.

Though, I'm currently not working on Miranda NG and thus my interest is quite low.. especially since there wasn't much feedback about it at all... I would like to complete Code::Blocks MSVC / VS support including an easy project import/export feature so that projects can provide GCC and MSVC / VS support, but that's quite some work. (in this regard, T-Clock also uses cross-IDE project files and sometimes I forget to keep them in sync... + I have to do so manually and on multiple files)

I suspect you won't be able to compile it yourself? I could upload you a nightly so you can try it out and compare the changes^^ Though it would also include lots of other changes like improved Doxygen parser and some reverted Code::Blocks commits.. (mainly the toggle comment handling + compiler output auto column size)

Melchior:
I have... MinGW (v4.8.1) Downgraded from v5.3.0 because it was causing the only other program I compile to crash  when it use to run fine..

I also have another folder of MinGW with the latest and greatest (v6.3.0).. yeah I did tha tupdate yesterday so I haven't used or tested at all..

idk.... I have a local repo of C::B and I have compiled before...

if you want.. I just haven't worked up the nerve to do the compel myself yet...
because I did a few simple mods to the project files.. to

replaced - <Variable name="WX_SUFFIX" value="u" />
with        - <Variable name="WX_SUFFIX" value="ud" />
for debugging version of Wx...

oBFusCATed:
@White-Tiger: These two patches are in my immediate todo list; If you update them to be compatible with current sources it will be a lot easier for me to apply them.

Navigation

[0] Message Index

[#] Next page

Go to full version