News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Run shell script with the "Run" button

Started by Yargh, March 19, 2011, 07:39:54 PM

Previous topic - Next topic

Yargh

I am currently working on a C::B project that requires custom tools to build and run (Compiles with a makefile through cygwin). Since it needs a custom command line to run, and cannot be run from an executable, I am wondering: Is it possible to have the "Run" button call a custom script instead of run an executable? What I am currently doing is I added "make run" to the post-build custom build steps, but that doesn't work if I want to compile but not run the project.

Jenna

You can try to create a batchfile (I guess you are on windows, because you use cygwin, on linux use a shell-script) that calls the commands you need and set it as "Output filename" in the projects "Properties -> Build targets -> [the target you use]".

Jenna

What I forgot:
you most likely have to uncheck "Auto-generate filename prefix" and "Auto-generate filename extension" .

dmoore

Can't OP also goto "Project -> Set Programs' Arguments" and set the "Host Application"?
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Jenna

Quote from: dmoore on March 19, 2011, 08:39:46 PM
Can't OP also goto "Project -> Set Programs' Arguments" and set the "Host Application"?
In this case he has to declare the application as dynamic or static library, but he would have to set up a terminal to run it in (if console output is needed) on his own.

Using the script as "Output filename" works better in my opinion. At least in custom makefile projects, in C::B projects the script would be overwritten during the build (of course).

Yargh

Quote from: jens on March 19, 2011, 07:52:31 PM
You can try to create a batchfile (I guess you are on windows, because you use cygwin, on linux use a shell-script) that calls the commands you need and set it as "Output filename" in the projects "Properties -> Build targets -> [the target you use]".
That method doesn't seem to work. I have auto-generate file prefix and extension off, and I made a run.bat file to run the command and set that as the output file name. Clicking the run button does nothing. However, opening cmd and cd'ing to the directory which it is set to run in and calling it ("..\run.bat") launches it fine. Also, I don't need console output as I'm running it in qemu.

Configuration:


Run.bat:
C:\qemu\qemu.exe -m 32 -fda kernel.img -boot a


The run.bat file should work fine if it's actually getting run in the correct directory.

EDIT: By does nothing, I mean that qemu doesn't open and no output shows up in the console.

Jenna

If the batch-file is not in the projects root directory, you have to specify the path to it in the "Output file" text-box.
The easiest way is to use the button ( [...] ) of the text-box to pick up the correct filename and path with the file-dialog.

Yargh

The batch file IS in the project's root directory, and I have used the browse button to locate the path. It still does nothing.

Jenna

Please copy the content of the "Build log" after clicking on the run button and post it here.

Yargh


Jenna

Does the compiler you have set in the "Build options" exist ?

Turn on full commandline logging:
http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
And past the output of the "Build log" after building your sources.