Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

Generated source files from :pre_build: command hook aren't compiled

Open alofthouse opened this issue 1 year ago • 3 comments

Hi,

Firstly, I want to say thanks for all your work on Ceedling.

I have a (probably niche) issue when using Ceedling with the command_hooks plugin, specifically with the pre_build hook.

Due to the nature of the project, we have some source files (.c and .h) that need to be generated before running our tests. I've setup a command hook which just calls a script to generate these files. They are created in the test/support folder.

:command_hooks:
  :pre_build:
    :executable: cmd.exe
    :arguments:
      - /c
      - "scripts\\pre_build.bat"

This all works as expected and the hook runs successfully. However, it appears that Ceedling generates its list of source/support files before the pre_build hook is run. This means that the generated files aren't compiled as they weren't picked up earlier.

This only happens the first time you run the Ceedling project with a clean repository. By the second time you run it, then the source files have already been generated, and everything works as expected.

Without being familiar with the code base, an easy fix for this seems to be just to move the invocation of the pre_build hook to somewhere closer to Ceedling starting up.

Thanks, Adam


Environment:

  • Windows 11
  • Ceedling Version:
ceedling version
Welcome to Ceedling!

  Ceedling => 1.0.0-f899db8
  ----------------------
  C:/tools/ruby33/lib/ruby/gems/3.3.0/gems/ceedling-1.0.0/

  Build Frameworks
  ----------------------
       CMock => 2.6.0
       Unity => 2.6.0
  CException => 1.3.4

alofthouse avatar Nov 27 '24 15:11 alofthouse

I am having the same issue too, but using pre_release on command_hooks plugin.

claudiiolima avatar Dec 12 '24 12:12 claudiiolima

This is a good use-case that we'll have to look at after this upcoming release. It's going to require some thought. There's a catch-22 here. The pre_build and pre_release hooks are meant to fire just before a build or release... which we need to know what we're building/releasing before that point. Your usage makes a lot of sense, though. We'll just have to think of how to support both.

mvandervoord avatar Dec 28 '24 17:12 mvandervoord

Perhaps a new generate_source hook? It's fairly common to generate sources in a project, for example a version.h file with Git and build metadata. Thanks again

alofthouse avatar Jan 06 '25 09:01 alofthouse