Code::Blocks Forums

User forums => Help => Topic started by: Jewe on January 17, 2008, 09:18:38 am

Title: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: Jewe on January 17, 2008, 09:18:38 am
Hi,

I am creating a small tool to copy the result dll from a project to a certain directory
Name: Copy file
Exe: Copy
Para: ${TARGET_OUTPUT_FILE} "c:\Program Files\FitTrainer"
Dir: ${TARGET_OUTPUT_DIR}

Everything is getting filled in except the ${TARGET_OUTPUT_FILE}.
What am I doing wrong?

cheers,

Jewe
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: thomas on January 17, 2008, 09:47:14 am
Hard to tell what you're doing wrong, if anything.

Apart from the possibility of a bug (unlikely, since I've used that variable in the past, and it worked), this variable is only defined during the build (more specifically, only inside target scope, so for example it is not defined during the project's post-build steps). Thus, if you use different place, it will not be replaced.
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: Jewe on January 17, 2008, 11:34:26 am
Thanks Thomas for the explanation.

if this is done by design, please remove the macro keyword from the window.
it looks like you could use this key word at any time.

cheers,

Jeffrey
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: mariocup on January 17, 2008, 11:38:00 am
You could do such simple things in a postbuilt step of your project and then you have access to the CB variables.

Code
cmd /c copy $(TARGET_OUTPUT_FILE) <pathname>
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: thomas on January 17, 2008, 07:18:48 pm
if this is done by design, please remove the macro keyword from the window.
it looks like you could use this key word at any time.
Well, it can be used at any time, it just doesn't make sense to do so. What this variable points to is the output file of the currently active target. Such a thing as a "currently active" target obviously only exists while the build is running and a target is being built. At all other times, any target in the project is just as much "active" or "not active" like any other.
What value different from "empty" would you expect the variable to have?
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: MortenMacFly on January 17, 2008, 07:48:13 pm
if this is done by design, please remove the macro keyword from the window.
it looks like you could use this key word at any time.
Replace "TARGET" with the actual targets name, e.g. "DEFAULT" -> so that it reads $(DEFAULT_OUTPUT_FILE) and it'll work for the tools menu. Thomas and you spoke about different things. Thomas spoke about pre/post-build steps and you are about the tool menu.
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: thomas on January 17, 2008, 08:30:49 pm
Thomas spoke about pre/post-build steps and you are about the tool menu.
Same thing. It's not defined in either :)

Quote
Replace "TARGET" with the actual targets name, e.g. "DEFAULT" -> so that it reads $(DEFAULT_OUTPUT_FILE)
This will work (but it's an entirely different thing too, it refers to precisely one particular target, not the active one).
Title: Re: using ${TARGET_OUTPUT_FILE} in tools is giving other result then expected
Post by: MortenMacFly on January 18, 2008, 07:51:13 am
Same thing. It's not defined in either :)
But I still believe he ment $([HOWEVER_THE_TARGETS_NAME_IS]_OUTPUT_FILE) which *does* exist. ;-)