News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

backtick support

Started by dmoore, April 13, 2009, 10:10:45 PM

Previous topic - Next topic

dmoore

While helping epsilon_da setup a wizard for GTK, we discovered the "other options" (including backticks) don't receive the macro substitution treatment that other build settings receive.

This patch rectifies that:


Index: src/sdk/compilercommandgenerator.cpp
===================================================================
--- src/sdk/compilercommandgenerator.cpp (revision 5535)
+++ src/sdk/compilercommandgenerator.cpp (working copy)
@@ -697,7 +697,11 @@
     // compiler options
     result << GetStringFromArray(compiler->GetCompilerOptions(), _T(' ')) << _T(" ");

-    wxString bt = ExpandBackticks(result);
+    Manager::Get()->GetMacrosManager()->ReplaceMacros(result, target);
+//    QuoteStringIfNeeded(result); //CAUSED PROBLEMS
+    FixPathSeparators(compiler, result);
+
+ wxString bt = ExpandBackticks(result);
     SearchDirsFromBackticks(compiler, target, bt);

     // add in array
@@ -724,7 +728,11 @@
     // linker options
     result << GetStringFromArray(compiler->GetLinkerOptions(), _T(' '));

-    wxString bt = ExpandBackticks(result);
+    Manager::Get()->GetMacrosManager()->ReplaceMacros(result, target);
+//    QuoteStringIfNeeded(result); //CAUSES PROBS
+    FixPathSeparators(compiler, result);
+
+ wxString bt = ExpandBackticks(result);
     SearchDirsFromBackticks(compiler, target, bt);

     // add in array


Reason to include this patch: Can help to make maintaining project options simpler (e.g. use a global variable $(#GTK_PKG_CONFIG) to point to the gtk pkg-config utility on windows so that projects can supply portable backticks like `$(#GTK_PKG_CONFIG) gtk+-2.0 --cflags`).

Reason *NOT* to include this patch: You tell me...
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: dmoore on April 13, 2009, 10:10:45 PM
Reason *NOT* to include this patch: You tell me...
I don't see any... my projects with such functionality still work fine. Other devs?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Jenna

Nothing against the patch in general.

But one question/objection: why do you call FixPathSeperator here ?

Think of this case:
The compiler used has forceFwdSlashes set to true, and the user wants to define a string at the commandline like:
-DTEST="\"The String\""

in build options we have to write TEST="\\"The String\\"" in defines tab.

The string will be "fixed" to -DTEST="//"The String//""

what leads to an error at compile-time: g++: String//: No such file or directory

dmoore

thanks for responding guys.

Quote from: jens on April 14, 2009, 12:33:31 PM
Nothing against the patch in general.

But one question/objection: why do you call FixPathSeperator here ?

copy and paste from how its done else where in the code - didn't think about it at the time, your example illustrates the problem. the patch just got simpler. :)

I'm struggling to think of any cases where the macro substitution itself could clash with legitimate compiler or linker options.
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]