Macro in Debug Working Path

CodeLite installation/troubleshooting forum
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Macro in Debug Working Path

Post by stegemma »

I have configured CodeLite to works on Windows/Mac, with wxWidgets 2.9.4. To maintains the same exact projects work without changes in Win/Mac, i make a large use of Environment Variables like this:

⁃Win:
⁃ SYSTEM=WIN
⁃ WXWIN=D:/AWX/wxWidgets-2.9.4
⁃ CLROOT=D:
⁃ PLATFORMLIBS=odbc32
⁃Mac:
⁃ SYSTEM=MAC
⁃ WXWIN=/Users/stefano/Documents/AWX/wxWidgets-2.9.4
⁃ CLROOT=/Users/stefano/Documents
⁃ PLATFORMLIBS=odbc
⁃Common:
⁃ LIGSDIR=${CLROOT}/A/WAM/Componenti/Ligs
⁃ CLDIR=${CLROOT}/A/CL
⁃ LIGSLIB=${CLDIR}/LigsLibrary
⁃ CLDIROUT=${CLDIR}/OUT/${ConfigurationName}/${SYSTEM}
⁃ OUTLIBDIR=${CLDIROUT}/Lib
⁃ OUTLIB=${OUTLIBDIR}/lib${ProjectName}.a
⁃ OUTAPPDIR=
⁃ Win: ${CLDIROUT}/App/${ProjectName}
⁃ Mac: ${CLDIROUT}/App/${ProjectName}/$(ProjectName).app/Contents/MacOS
⁃ OUTAPP=
⁃ Win: ${OUTAPPDIR}/${ProjectName}.exe
⁃ Mac: ${OUTAPPDIR}/${ProjectName}.app
⁃ CLTEMP=${CLDIROUT}/Temp/${ProjectName}

The problem is that, to start debugger under Mac, i need to set the Working directory accordingly in this way:

${CLDIROUT}/App/${ProjectName}

but CodeLite seems not to translate ${CLDIROUT} macro to the path and gives me this output:

Using gdbinit file: /Users/stefano/.gdbinit
Current working dir: /Users/stefano/Documents/A/CL/Apps/Satana
Launching gdb from : ${CLDIROUT}/App/${ProjectName}
...

The "Lanching gdb from:" should be instead expanded to:

/Users/stefano/Documents/A/CL/OUT/Debug/MAC/App/Satana

if i put this path manually it works, if i use my macros it doesn't. I don't want to put the path manually, because that way i couldn't let project be fully portable between Win/Mac.

Thanks for any answer.

Maybe in CodeLite macro handling is missing from Working path of the debugger section?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by eranif »

stegemma wrote:${CLDIROUT}/App/${ProjectName}
codelite does not understand this synatx.

Try instead (notice the use of braces instead of the curly ones):
stegemma wrote:$(CLDIROUT)/App/$(ProjectName)

Eran
Make sure you have read the HOW TO POST thread
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by stegemma »

Sorry but it doesn't works. I use curly braces everywhere (instead of simple braces), in CodeLite settings, and they works very fine but not in this path. I've tried at first simple braces but they seems not works in some setting, so i use only curly braces.

For now i solve this issue using "attach to process" or setting tha path manually.

I like CodeLite, i've tried other IDEs (Code::Blocks, Eclipse and so on) and this one seems to simpler one and the only one that works very well both in Windows and MAC OS X. Maybe i could help in developing or debugging the IDE, if you need it.

PS: i'm developing (using CodeLite) "Satana", my new chess program... and i would like to finish before october, where initiate the Italian Computer Chess Championship
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by eranif »

stegemma wrote:CodeLite settings, and they works very fine
only by accident..

Code: Select all

${ProjectName}
can not be expanded by codelite as it uses this regular expression:

Code: Select all

wxRegEx reVarPattern(wxT("\\$\\(( *)([a-zA-Z0-9_]+)( *)\\)"));
which only takes into account braces (not curly ones)

If it worked elsewhere, its only by accident e.g. codelite copies your entire environment variables section into the generated makefile, so probably because 'make' understands {} it worked.

However, in areas (e.g. debugger) where makefile is not involved, it failed.

I will try to reproduce it here and see why it fails - stay tuned ;)

Eran
Make sure you have read the HOW TO POST thread
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by eranif »

I just tried the following:

- From Settings -> Environment variables, I defined this environment variable:

Code: Select all

MY_HOME=/home/eran/devl/
- Next, in my project, I defined the "Program to Debug / Run" like this:

Code: Select all

./$(ProjectName)
and 'Working folder' is set to:

Code: Select all

$(MY_HOME)/SImpleMain/Debug
When I started to debug, I get this output from gdb:

Code: Select all

Using gdbinit file: /home/eran/.gdbinit
Current working dir: /home/eran/devl/SImpleMain
Launching gdb from : /home/eran/devl//SImpleMain/Debug
Starting debugger  : gdb --tty=/dev/pts/12 --interpreter=mi "./SImpleMain"
Can you see anything that I am doing different from you? (i.e. why is it working for me and fails for you?)

Eran
Make sure you have read the HOW TO POST thread
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by stegemma »

It is an interesting accident ;) but now i change all curly braces to simple ones, in all my projects and libraries... then i could say if still it doesn't works.

I'm working on a Mac, so the compiler should creates a "bundle". This is a little different from your sample, let me try and i'll give soon a feedback.
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by stegemma »

Try this, in your sample:

MY_HOME=/home/eran/devl/$(ConfigurationName)

and then

MY_HOME=/home/eran/devl/${ConfigurationName}

but setting Output file to $(MY_HOME).

In the first case, $(ConfigurationName) will results empty, in the second case it will be correctly translated to "Debug". Thats happens to me:

for a library:

Output file: $(OUTLIB)

Environment variables:

CLROOT=/Users/stefano/Documents
CLDIR=$(CLROOT)/A/CL
LIGSLIB=$(CLDIR)/LigsLibrary
CLDIROUT=$(CLDIR)/OUT/${ConfigurationName}/$(SYSTEM)
OUTLIBDIR=$(CLDIROUT)/Lib
OUTLIB=$(OUTLIBDIR)/lib$(ProjectName).a

It works only if ${ConfigurationName} is in curly braces but this is not good for gdb, as you correctly said... it is an accident of the make command. Still, it seems that there are no simple solution: i cannot use { because it works only for make but i cant use only ( because it doesn't works in environment variable parsing (almost so it appears to me).
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by stegemma »

This solution, even if not very clear, works:

1) using all {} in environment variable but this one:

DBGDIR=$(CLROOT)/A/CL/OUT

2) setting Debug Path to this one:

$(DBGDIR)/$(ConfigurationName)/$(SYSTEM)/App/$(ProjectName)

This way i can take all OS stuff defined in environment variables and let project settings be the same in both Win/Mac platforms.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by eranif »

stegemma wrote:MY_HOME=/home/eran/devl/$(ConfigurationName)

and then

MY_HOME=/home/eran/devl/${ConfigurationName}

but setting Output file to $(MY_HOME).

In the first case, $(ConfigurationName) will results empty, in the second case it will be correctly translated to "Debug"
Did you try defining it like this:

Code: Select all

MY_HOME=/home/eran/devl/$(ConfigurationName)


Again, when debugging, macros *MUST* be defined with braces. Anything else will not be translated

If you dont believe me, check the source here:
http://codelite.svn.sourceforge.net/vie ... iew=markup

and here:
http://codelite.svn.sourceforge.net/vie ... iew=markup (line 2169)

Eran
Make sure you have read the HOW TO POST thread
stegemma
CodeLite Curious
Posts: 6
Joined: Thu Aug 09, 2012 11:26 am
Genuine User: Yes
IDE Question: C++
Contact:

Re: Macro in Debug Working Path

Post by stegemma »

eranif wrote:...
Again, when debugging, macros *MUST* be defined with braces. Anything else will not be translated

If you dont believe me, check the source here:
...
Eran
I believe in you and further investigating i think to have found the "bug". It is not a CodeLite bug but a problem for what i want to do in the way i want to do it. Maybe the problem is that Environment Variables were parsed when starting CodeLite and doesn't get parsed again before to prepare makefile for build? If this is the case, this explains all. The macro $(ConfigurationName) does not have sense at the start of CodeLite and gets blank in makefile. The macros ${ConfigurationName} does not have sense to CodeLite but is recognized by make (in makefile $() and ${} are the same) and receive the correct value for g++.

In debugging there's not make at all and ${} doesn't have sense nor for CodeLite nor for gdb.

Maybe this a problem only for me and i don't want to make you loose your time. I'm just glad enough to (maybe) have find this problem and a solution to let me go further.

PS: looking at the source code of CodeLite, maybe is a little different:

expandedString = manager->GetEnv()->ExpandVariables(expandedString, true);

this will be called at end of macro expansion, so you always expand your expression to substitute environment variable but there's not a substitution of program setting macros (like ConfiguratinName) in environment variable; this could only be solved, eventually, by substituting environment variables itselfs by calling the Expand function (using maybe a boolean flag to avoid infinite loops); too complicated maybe for a "one man problem" ;)
Post Reply