Wildcard doesn't work in post-build command

General questions regarding the usage of CodeLite
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Wildcard doesn't work in post-build command

Post by plong »

How can I get wildcards to work in post-build commands? If I use a wildcard file reference in a post-build command, such as

cp $WRKSPC/boost/usr/lib/libboost_system.so.* $PRJROOT/filesys/fs/usr/lib

I get this output when I build the project:

Executing Post Build commands ...
cp: cannot stat `/home/plong/workspace/boost/usr/lib/libboost_system.so.*': No such file or directory

This command works when I enter it in a bash shell. It also works as a post-build command if I remove the wildcard, as in

cp $WRKSPC/boost/usr/lib/libboost_system.so.1.52.0 $PRJROOT/filesys/fs/usr/lib

What gives?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by eranif »

plong wrote:cp $WRKSPC/boost/usr/lib/libboost_system.so.* $PRJROOT/filesys/fs/usr/lib
Where did you define WRKSPC and PRJROOT ?

Are these environment variables? If yes, then codelite should replace them with their proper content.
However, if you defined them somewhere in your ~/.bashrc or something similar, you should make sure to start codelite from the terminal that these variables are defined.

You could also define them within codelite from Settings -> Environment variables

Eran
Make sure you have read the HOW TO POST thread
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by plong »

Oh, yeah, they're exported from ~/.profile. They get expanded correctly as you can see in the build output, so that's not the issue. The problem is with the *.

For example, this works:
cp $WRKSPC/boost/usr/lib/libboost_system.so.1.52.0 $PRJROOT/filesys/fs/usr/lib
but this doesn't:
cp $WRKSPC/boost/usr/lib/libboost_system.so.* $PRJROOT/filesys/fs/usr/lib

Just to make sure, I replaced those variables with their values, and * still doesn't work.
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by plong »

Oh, I wonder if this is the culprit. Does CodeLite execute those commands in a bash shell with the -f option? If so, bash doesn't do filename expansion, and the cp command is trying to copy a file with an asterisk in the filename. If this is the cause, is there a workaround, or is there any way to enable filename expansion?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by eranif »

plong wrote:They get expanded correctly as you can see in the build output
/me looks harder, but still can't see the build output

I think that posting the *complete build log* of your problem will clear things up

Eran
Make sure you have read the HOW TO POST thread
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by plong »

Sorry. In my query, I said,
If I use a wildcard file reference in a post-build command, such as

cp $WRKSPC/boost/usr/lib/libboost_system.so.* $PRJROOT/filesys/fs/usr/lib

I get this output when I build the project:

Executing Post Build commands ...
cp: cannot stat `/home/plong/workspace/boost/usr/lib/libboost_system.so.*': No such file or directory
Those last two lines appear in the Build tab of Output View. That's what I meant by "build output."

I think this pretty much proves that $WRKSPC expands to /home/plong/workspace. But, like I said earlier, I replaced those variables with their values and still get the same, "cannot stat" error message, so shell parameter expansion is a red herring.

I've been poking around some more and am pretty sure file expansion is disabled for custom build steps http://www.gnu.org/software/bash/manual ... -Expansion.
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by eranif »

plong wrote:Oh, I wonder if this is the culprit. Does CodeLite execute those commands in a bash shell with the -f option? If so, bash doesn't do filename expansion, and the cp command is trying to copy a file with an asterisk in the filename
For custom build projects (you should have mentioned this earlier...) - codelite wraps all the post-build commands in a temporary script file and execute it with '/bin/sh -f' ... this is a bug which is now fixed in git head

Eran
Make sure you have read the HOW TO POST thread
plong
CodeLite Enthusiast
Posts: 10
Joined: Thu Apr 18, 2013 9:33 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Wildcard doesn't work in post-build command

Post by plong »

Sorry. Thanks for your attention.
Post Reply