Author Topic: Run shell script with the "Run" button  (Read 5377 times)

Offline Yargh

  • Single posting newcomer
  • *
  • Posts: 4
Run shell script with the "Run" button
« on: March 19, 2011, 07:39:54 pm »
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.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #1 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]".

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #2 on: March 19, 2011, 08:11:15 pm »
What I forgot:
you most likely have to uncheck "Auto-generate filename prefix" and "Auto-generate filename extension" .

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Run shell script with the "Run" button
« Reply #3 on: March 19, 2011, 08:39:46 pm »
Can't OP also goto "Project -> Set Programs' Arguments" and set the "Host Application"?

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #4 on: March 19, 2011, 10:17:56 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).

Offline Yargh

  • Single posting newcomer
  • *
  • Posts: 4
Re: Run shell script with the "Run" button
« Reply #5 on: March 20, 2011, 05:16:10 am »
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:
Code: [Select]
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.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #6 on: March 20, 2011, 09:31:27 am »
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.

Offline Yargh

  • Single posting newcomer
  • *
  • Posts: 4
Re: Run shell script with the "Run" button
« Reply #7 on: March 20, 2011, 07:54:39 pm »
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.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #8 on: March 20, 2011, 08:30:11 pm »
Please copy the content of the "Build log" after clicking on the run button and post it here.

Offline Yargh

  • Single posting newcomer
  • *
  • Posts: 4
Re: Run shell script with the "Run" button
« Reply #9 on: March 21, 2011, 12:58:15 am »
Code: [Select]
Nothing shows up in the build log.

Offline jens

  • Administrator
  • Lives here!
  • *****
  • Posts: 7265
    • Jens' unofficial debian-repository for the Code::Blocks - IDE
Re: Run shell script with the "Run" button
« Reply #10 on: March 21, 2011, 09:00:51 am »
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.