Defining pre build command to build one file each time

Sysprogs forums Forums VisualGDB Defining pre build command to build one file each time

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #35322
    gboy
    Participant

    I’m running Visual Studio Community 2015 w/ VisualGDB, working on an STM32 project.  I would like to instruct the tool to build one particular file with each build.  Is there a way to force recompilation on a file by file basis?  If so, where do I implement that command and what is the format for that command?

     

    #35323
    support
    Keymaster

    Hi,

    There isn’t any specific setting that would do that directly, but you could try adding a pre-build step that would regenerate some header file, and including that file from all sources that you would like to be rebuilt.

    #35324
    gboy
    Participant

    Thanks for the tip.  Where exactly are pre-build steps like that added in VisualGDB?  (and what’s the format of the command to regenerate such a header file?)

     

    #35325
    support
    Keymaster

    Hi,

    You can configure custom pre-build steps via VisualGDB Project Properties -> Custom Build Steps.

    As for the command line, it’s something for you to figure out. VisualGDB can run arbitrary command lines at different times during the build as configured via VisualGDB Project Properties, but it’s up to the user to make sure these command lines make sense and work as expected.

    #35378
    gboy
    Participant

    I tried to implement ‘Before building’ custom build step using the following command setup:

    custom_build_settings.PNG

    However, when I went to build the project, I got this set of messages:

    Run "del /F my_file.c.obj " in directory "C:/my_proj/build/VisualGDB/Debug/CMakeFiles/my_proj.dir" on local computer 

    Command-line action failed

    Do you know why this command to delete one of the object files is not succeeding?

    Attachments:
    You must be logged in to view attached files.
    #35391
    gboy
    Participant

    Note to the community:  I am able to achieve my objective by putting my system commands into a batch file (e.g. my_bat.bat) placed in the $(BuildDir) and then calling it as a pre build command using the command:

    .\my_bat.bat

     

    #35392
    support
    Keymaster

    Thanks for sharing this. This happens because “del” is not a separate executable, but is rather a built-in command of cmd.exe. If you don’t want to use a temporary batch file, you can also do this:

    Command cmd.exe
    Arguments /c del […]
    #35393
    gboy
    Participant

    Interesting.  Thanks for the clarification!

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.