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)...
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?
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?)...
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...
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...
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