News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

Help? My pre build script fails; but only under CB.

Started by rioki, August 29, 2009, 08:21:22 PM

Previous topic - Next topic

rioki

Hi,

I am trying to get my post pre script to run, it works in cmd but not under CB.

I am running:
 - Window XP SP3
 - CB 8.02 (Build: Feb 27 2008 20:59:09)

Basically everything works as expected except if I am trying to run


rd /Q /S $(TARGET_OBJECT_DIR)\*


The entire script is:


xcopy /Y $(TARGET_OUTPUT_BASENAME).nsi $(TARGET_OBJECT_DIR)
mkdir $(TARGET_OBJECT_DIR)include
mkdir $(TARGET_OBJECT_DIR)lib
mkdir $(TARGET_OBJECT_DIR)bin
xcopy /Y ..\..\Tools\IcedResource\bin\$(TARGET_NAME)\IcedResource.exe $(TARGET_OBJECT_DIR)\bin
$(#nsis)\makensis $(TARGET_OBJECT_DIR)\$(TARGET_OUTPUT_BASENAME).nsi
xcopy /Y $(TARGET_OBJECT_DIR)$(TARGET_OUTPUT_BASENAME).exe $(TARGET_OUTPUT_DIR)
rd /S /Q $(TARGET_OBJECT_DIR)\*


When I execute the code under windows command line all works as expected...

I kinda hit a wall here, any help or ideas are very very welcome. I am thinking of writing a shell script and pass that by MSys (bash)...

MortenMacFly

Quote from: rioki on August 29, 2009, 08:21:22 PM

rd /Q /S $(TARGET_OBJECT_DIR)\*

What do you see at the command line if you put an echo before that?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

rioki

Quote from: MortenMacFly on August 29, 2009, 08:27:07 PM
Quote from: rioki on August 29, 2009, 08:21:22 PM

rd /Q /S $(TARGET_OBJECT_DIR)\*

What do you see at the command line if you put an echo before that?


echo rd /S /Q $(TARGET_OBJECT_DIR)\*


gives:


echo rd /S /Q obj\Debug\*
Execution of 'echo rd /S /Q obj\Debug\*' in 'D:\Development\IcedLiquid\Trunk\IcedBlue\Installers\IcedBlue-SDK' failed.


Could that be that something is not properly escaped?

rioki

It is even worse:


echo "Hello World"
Execution of 'echo "Hello World"' in 'D:\Development\IcedLiquid\Trunk\IcedBlue\Installers\IcedBlue-SDK' failed.


Something is definitely broken (on my end?)...

rioki


MortenMacFly

#5
Quote from: rioki on August 29, 2009, 08:38:27 PM

echo "Hello World"

Ah - sorry, that cannot work, indeed. You can try to put everything in a batch file and run it providing the batch file with the required macro as command line params.
Quote from: rioki on August 29, 2009, 08:38:27 PM
Execution of 'echo "Hello World"' in 'D:\Development\IcedLiquid\Trunk\IcedBlue\Installers\IcedBlue-SDK' failed.
Would that be the right base folder so that the command (especially "(TARGET_OBJECT_DIR)\*") makes sense in that folder?

Edit: Another Idea: Do you have a conflicting RD executable in the path (for example in the compiler directory) that would not have the same command line params (e.g. a unix derivate)?
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

rioki

Ok:


set TARGET_OUTPUT_BASENAME=IcedBlue-SDK
set TARGET_OUTPUT_DIR=bin\Debug\
set TARGET_OBJECT_DIR=obj\Debug\
set TARGET_NAME=Debug
set nsis=C:\Program Files\NSIS

xcopy /Y %TARGET_OUTPUT_BASENAME%.nsi %TARGET_OBJECT_DIR%
mkdir %TARGET_OBJECT_DIR%include
mkdir %TARGET_OBJECT_DIR%lib
mkdir %TARGET_OBJECT_DIR%bin
xcopy /Y ..\..\Tools\IcedResource\bin\%TARGET_NAME%\IcedResource.exe %TARGET_OBJECT_DIR%\bin
"%nsis%\makensis" %TARGET_OBJECT_DIR%\%TARGET_OUTPUT_BASENAME%.nsi
xcopy /Y %TARGET_OBJECT_DIR%%TARGET_OUTPUT_BASENAME%.exe %TARGET_OUTPUT_DIR%
rd /S /Q %TARGET_OBJECT_DIR%


Works like a charm...

rioki

FIXED:

Using the following command works:


cmd /C "rd /Q /S $(TARGET_OBJECT_DIR"


Why? Well in cmd rd or rmdir is not a program like on *nix. It is a built in command that is translated to API call.

Actually I would like "Shell to run command in:" option for win two... Would either add bash from MSys or cmd...

oBFusCATed

If you want to have unix tools on windows you can install UnixTools or GnuWin32.
I'm using the former and I'm happy wiNIX user :) :)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

rioki

I have MSys (MinGW) installed. Yes I ended up writing a shell script... Much more sane...

But I thing the way the pre and post-build scripts are executed is broken. In Code::Blocks (it seems) that every line is taken on its own and it is fed to something like exec(). Instead of passing the entire chunk to cmd or <insert configurable tool here>. You end up with the situation that you can't cd into a different directory and execute some command there.

I (was forced to) use Visual Studio (at my paying job) and coming from there I assumed that the post and pre build scripts run in cmd and you can basically copy and past cmd scripts there. Me bad for assuming that.

Pecan

#10
Quote from: rioki on August 31, 2009, 09:55:59 AM
I have MSys (MinGW) installed. Yes I ended up writing a shell script... Much more sane...

But I thing the way the pre and post-build scripts are executed is broken. In Code::Blocks (it seems) that every line is taken on its own and it is fed to something like exec(). Instead of passing the entire chunk to cmd or <insert configurable tool here>. You end up with the situation that you can't cd into a different directory and execute some command there.

I (was forced to) use Visual Studio (at my paying job) and coming from there I assumed that the post and pre build scripts run in cmd and you can basically copy and past cmd scripts there. Me bad for assuming that.

For me, grouping all the one-liners into a single .cmd file that accepts the CB macros works ok.

For example:

cmd /c showargs.cmd $(TARGET_OBJECT_DIR)


with contexts:
echo %0 %1
echo finished

would produce

Target is up to date.
Running target post-build steps
cmd /c showargs.cmd gcc_mswu\toolbar
C:\Usr\Proj\test\toolbar>echo showargs.cmd gcc_mswu\toolbar
showargs.cmd gcc_mswu\toolbar
C:\Usr\Proj\test\toolbar>echo finished
finished
Process terminated with status 0 (0 minutes, 0 seconds)
0 errors, 0 warnings