Page 1 of 1

Correctly declare variables in post build?

Posted: Thu Jan 09, 2014 1:50 pm
by CrHasher
I’m trying to copy some files after build by using the post build step in project settings. I would like to declare a variable so I don’t have to repeat the same thing over and over again.

What I tried so far and can’t get this to work:
  • TARGET_PATH=./pathpart1/pathpart2
    cp –f lib.a $TARGET_PATH
    cp –f lib.dll $TARGET_PATH
    - tries to copy lib.a and lib.dll to ARGET_PATH
  • TARGET_PATH:=./pathpart1/pathpart2
    cp –f lib.a $(TARGET_PATH)
    cp –f lib.dll $(TARGET_PATH)
    - says that ./pathpart1/pathpart2 directory does not exist even though running and echoing pwd outputs the path to the dir where ./pathpart1/pathpart2 exists.
This works but I don’t like it:
  • cp –f lib.a ./pathpart1/pathpart2
    cp –f lib.dll ./pathpart1/pathpart2 <- same path repeated

Re: Correctly declare variables in post build?

Posted: Thu Jan 09, 2014 2:02 pm
by eranif
CrHasher wrote:TARGET_PATH=./pathpart1/pathpart2
Assuming you are using the default build system of codelite ( i.e. no custom makefiles ) the post build commands are created as part of the generated makefile ( <Project Name>.mk )

This means, that this line:

Code: Select all

TARGET_PATH=./pathpart1/pathpart2
is an invalid Makefile command - so it will not work

If you want to declare a variable is by using the environment variables.
There are 2 ways to do it:

project settings -> common settings -> environment
and define the environment variable there:

Code: Select all

TARGET_PATH=./pathpart1/pathpart2
And in your post-build tab, use it like this:

Code: Select all

cp –f lib.a $(TARGET_PATH)
The second way to define the environment variable as global from : settings -> environment variables (the rest is the same)

Eran