Menu

#344 Build scripts run too many times

Undefined
open
nobody
None
Undefined
2025-12-31
2016-04-27
Riot
No

Build scripts (as in the Squirrel scripts, that are added by project->properties->build scripts->add) are currently executed an apparently arbitrary and large number of times, both before and after the build.

To reproduce, create a simple script containing

function SetBuildOptions(base) {
  ShowMessage(_T("This pops up too many times."));
}

and attach it to a project which has pre/post build steps etc. On the project I'm testing, the script is executed 8 times, even for an already built project for which there's nothing to be done.

The wiki seems to suggest that the build script is run once, at the start of the build process. As it is currently, the build scripts feature is not actually useful for anything except setting compiler options.

Discussion

  • ollydbg

    ollydbg - 2016-10-23

    Where do you put the script code?
    For me, I can only open the build option dialog, and see "pre/post" edit control. What is the code snippet you put in those edit controls?

     
    • Riot

      Riot - 2016-10-23

      This is not in the build options. It's in the project properties. As I said in the first sentence of the above report, we're talking about Squirrel build scripts, added by project->properties->build scripts->add:

       
  • T-640

    T-640 - 2025-12-31

    Quite an old bug, and a pretty nasty one I might add. I needed to write a build script that goes beyond simply setting compiler options, but because it gets executed multiple times, upon error being encountered, I was bombarded with a barrage of popup windows telling about the error, having to violently smash the enter key until they were all gone. What makes things worse is that there is more to it than just multiple redundant executions.

    I have attached an environment where the issue is reproduced.

    There are two projects in there, A and B. B depends on A. A declares and defines a global Squirrel variable and B reads it, printing its value.

    You'd think that according to dependency rules A's script will be executed first and then B's, but this is not the case. If you open the unaltered workspace file B's script is actually executed first, and A's is not executed at all! Because A's script was not executed, the global variable was not set, and B is trying to read a nonexistent variable, and thus fails.

    Now right click on A and choose "Reparse project". A's script is now executed, variable is set.
    Now right click on B and choose "Reparse project" as well. No error this time, the variable is printed via the LogError call.

    Double left click on A to make it the current active project. Exit Code::Blocks. No error upon startup, but now B has not executed its script. Right click on it, select "Reparse project", and it will get executed.

    Finally select Build -> Clean workspace. Afterwards in the "Logs & others" menu go to the Code::Blocks tab and you will see that each script has printed its messages at least 4 times.

     

    Last edit: T-640 2026-01-01

Log in to post a comment.

MongoDB Logo MongoDB