Multiline command truncated in Pre Build

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:

Multiline command truncated in Pre Build

Post by plong »

How can I use a multiline Pre Build command? I have a custom-build project with Pre Build commands. One of those is a multiline sed command, i.e.,

Code: Select all

grep -q BOOST_HAS <BasicMessage.h || (sed 's:#include <boost/make_shared.hpp>:#ifdef BOOST_HAS_RVALUE_REFS\
#undef BOOST_HAS_RVALUE_REFS\
#include <boost/make_shared.hpp>\
#define BOOST_HAS_RVALUE_REFS\
#else\
#include <boost/make_shared.hpp>\
#endif:' <BasicMessage.h >bmh && cp bmh BasicMessage.h && rm bmh)
It doesn't matter for my question, but this is what I'm trying to do: If this sed mod hasn't already been applied to BasicMessage.h, apply it. The mod replaces a single #include line with multiple preprocessor lines.

This is what I see in the Build tab of Output View:

Code: Select all

MESSAGE: Entering directory `/home/plong/workspace/SimpleAmqpClient'
/bin/sh -f './SimpleAmqpClient.sh'
----------Building project:[ SimpleAmqpClient - Debug ]----------
Executing Pre Build commands ...
./SimpleAmqpClient.sh: line 4: unexpected EOF while looking for matching `''
./SimpleAmqpClient.sh: line 10: syntax error: unexpected end of file
0 errors, 0 warnings
and this is the contents of the SimpleAmqpClient.sh file that CodeLite creates to execute my Pre Build commands:

Code: Select all

echo Executing Pre Build commands ...
cd src/SimpleAmqpClient
grep -q BOOST_HAS <BasicMessage.h || (sed 's:#include <boost/make_shared.hpp>:#ifdef BOOST_HAS_RVALUE_REFS\
cd ../..
mkdir build; cd build
cmake -DCMAKE_TOOLCHAIN_FILE=~/Toolchain-z3.cmake -DBOOST_ROOT=$WRKSPC/boost -DRabbitmqc_DIR=$WRKSPC/rabbitmq-c/target ..
echo Done
make
CodeLite apparently doesn't expect a command to continue onto multiple lines like this.

Any idea how I can specify a multiline command without resorting to putting it in a file and referencing the file from a Pre Build command (I hate that)?
User avatar
eranif
CodeLite Plugin
Posts: 6375
Joined: Wed Feb 06, 2008 9:29 pm
Genuine User: Yes
IDE Question: C++
Contact:

Re: Multiline command truncated in Pre Build

Post by eranif »

There are 2 problems here:

- codelite pre(post)build was designed for a single line commands so it does not support line continuation using '\'
- Because of the above, each line is treated as a separate command, usually it would have worked out, however, your line starts with '#' which codelite recognizes as a comment... and this is why the script is truncated

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: Multiline command truncated in Pre Build

Post by eranif »

Update:

I added a fix in git head to support line continuation using '\'
this will make codelite treat the entire command as a single line

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: Multiline command truncated in Pre Build

Post by plong »

Cool! Thanks, Eran. Funny about the #'s. I hadn't thought about that.

BTW, I had been using VS2012 as my IDE, accessing source code on an Ubuntu VirtualBox VM via Samba and kicking off (Linux) builds via console commands in the VM. Worked relatively well, but Intellisense parsing was extremely slow presumably due to Samba. I just switched over to CodeLite running in the VM and couldn't be happier. I am also able to use the custom-, pre-, and post-build features to do the builds from within CodeLite, which is nice. Keep up the good work, but CodeLite is already very impressive.
Post Reply