Author Topic: I can't run a command only build target  (Read 3295 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5855
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I can't run a command only build target
« on: September 16, 2023, 04:57:28 am »
Hi, I have a build target named "MakePackage", in this target, I select its type is "command only".

In the pre-build or post-build script, I wrote the command like:

Code
cmd /c MakePackageRelease.cmd

With this command, I just copy all the exes and dlls to a specified folder.

I used this for a long time. But with the recent SVN C::B, I see this function does not work, because when I click the "run" button of the target, it will prompt

Code
[Window Title]
codeblocks.exe

[Content]
You must select a host application to "run" a commands-only target...

[OK]

Which means I have to specify a host program?

So, I believe this is a regression. :)
« Last Edit: September 16, 2023, 05:05:49 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5855
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I can't run a command only build target
« Reply #1 on: September 16, 2023, 05:03:14 am »
I think this issue is related:

Code::Blocks / Tickets / #1395 Compilergcc
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5855
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I can't run a command only build target
« Reply #2 on: September 16, 2023, 06:07:51 am »
Please note that the "commands only" type build target has the "executable" option disable, so I can't set a executable of this target.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1489
Re: I can't run a command only build target
« Reply #3 on: September 16, 2023, 11:48:14 am »
The commits in that ticket are related to the Run button enabled state, not to execution. See my reply in the ticket.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5855
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I can't run a command only build target
« Reply #4 on: September 16, 2023, 12:43:38 pm »
The commits in that ticket are related to the Run button enabled state, not to execution. See my reply in the ticket.

Oh, sorry, I think I have made a mistake.

For a commands only target, it can be "build", I mean The commands I wrote in the "pre-build" and "post-build" option, which can be run if I click the "Build" button.

But this kinds of targets can NOT be executed, so the "Run button" get disabled.

That's a normal behavior, and I have made a mistake, I should click the build button, not the run button. Sorry about the noise.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Miguel Gimenez

  • Developer
  • Lives here!
  • *****
  • Posts: 1489
Re: I can't run a command only build target
« Reply #5 on: September 16, 2023, 12:55:41 pm »
Then, should the Run button be disabled always for Command only targets?

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5855
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I can't run a command only build target
« Reply #6 on: September 16, 2023, 03:35:33 pm »
Then, should the Run button be disabled always for Command only targets?

I think for a command only targets, when I build this target, it just run some commands.
What is the result of the running commands, maybe it generate an exe file? In this case, "Run" button is needed.

In-fact, I have other minor issues about the "command only targets", I see that the "Search directories" in the Build option is disabled. Which means if I have a to add some code in my command to add a directory to the PATH variable when I "Build" the target. I'm not sure you understand this, I mean in normal Console or GUI targets, the "Linker's search directories" is automatically added to the PATH when I "Build" or "Run" the targets. But currently I can't edit that field.

This is a example cmd(named AAA.cmd), the contents are like below:

Code
@echo off
set "current_path=%~dp0"
set "new_path1=%current_path%lib"
set PATH=%new_path1%;%PATH%
start "" /wait "C:\Program Files (x86)\AAAAA\ABC.exe"

Then I have put the below code in the "pre or post build steps" in the command only target's build options.

Code
cmd /c AAA.cmd
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.