Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: ollydbg on September 16, 2023, 04:57:28 am

Title: I can't run a command only build target
Post by: ollydbg 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. :)
Title: Re: I can't run a command only build target
Post by: ollydbg on September 16, 2023, 05:03:14 am
I think this issue is related:

Code::Blocks / Tickets / #1395 Compilergcc (https://sourceforge.net/p/codeblocks/tickets/1395/)
Title: Re: I can't run a command only build target
Post by: ollydbg 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.
Title: Re: I can't run a command only build target
Post by: Miguel Gimenez 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 (https://sourceforge.net/p/codeblocks/tickets/1395/#1d8d).
Title: Re: I can't run a command only build target
Post by: ollydbg 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 (https://sourceforge.net/p/codeblocks/tickets/1395/#1d8d).

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.
Title: Re: I can't run a command only build target
Post by: Miguel Gimenez on September 16, 2023, 12:55:41 pm
Then, should the Run button be disabled always for Command only targets?
Title: Re: I can't run a command only build target
Post by: ollydbg 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