Menu

Pre-build option?

Osito
2007-08-08
2012-09-26
  • Osito

    Osito - 2007-08-08

    Does Dev-C++ have an option to run a pre-build program? I use a program that extracts the version number from svn and places it in a header file that then gets used in the compilation to indicate the revision on my Help-About screen. Right now I have to run a batch file to do the extraction, then compile in Dev-C++. A colleague who uses the MS tools says he can do it all in one step from within the IDE. Just wondering if there's an option (or a trick) to doing that here.

     
    • Nobody/Anonymous

      Dev-C++ uses an autmatic-created makefile (Makefile.win). You can order include any script file in it. Example: MakeExtension.mak (a regular text file) using Project Optins -> Makefile -> "Include the following files into the Makefile".

      Doing so, the Makefile appears as this:

      [...]
      .PHONY: all all-before all-after clean clean-custom

      all: all-before MyXXXXX.exe all-after

      include MakeExtension.mak

      clean: clean-custom
      ${RM} $(OBJ) $(BIN)
      [...]

      The MakeExtension.mak file can include some as:

      ----------------------------------------

      My extension for Dev-Cpp makefile

      do some thing before, and copy the last exe version to some place after

      all-after:
      copy /Y $(BIN) ....\SomePlace\MyResultDirectory

      all-before
      some command....

      -------------------------------------

      Don't forgot insert a TAB before "copy" and "some"

      You can play around this.

      HTH

      Old newbie

       
      • Osito

        Osito - 2007-08-08

        OK, I got it half right so far. I added the custom makefile and I know it tried to use it because the first time I got an error about my all-before line (missing a colon) and once I fixed that, no more errors. Here's my compile log:

        Compiler: Default compiler
        Building Makefile: "C:\Bittware\chamber\Makefile.win"
        Finding dependencies for file: C:\Bittware\chamber\chamber.c
        Executing make...
        make.exe -f "C:\Bittware\chamber\Makefile.win" all
        gcc.exe chamber.o chamber_private.res -o "The Chamber Maid.exe" -L"C:/Bittware/Dev-Cpp/lib" -mwindows -lcomctl32 visaext.lib agvisa32.lib agvisaext.lib visa32.lib

        gcc.exe chamber.o chamber_private.res -o "The Chamber Maid.exe" -L"C:/Bittware/Dev-Cpp/lib" -mwindows -lcomctl32 visaext.lib agvisa32.lib agvisaext.lib visa32.lib

        gcc.exe chamber.o chamber_private.res -o "The Chamber Maid.exe" -L"C:/Bittware/Dev-Cpp/lib" -mwindows -lcomctl32 visaext.lib agvisa32.lib agvisaext.lib visa32.lib

        Execution terminated
        Compilation successful

        Why are there three gcc lines? Anyway, here's my custom makefile:

        Automatically retrieves svn version prior to build

        all-before:
        "c:\program files\tortoisesvn\bin\subwcrev.exe" C:\Bittware\chamber C:\Bittware\chamber\version\bwversion.repo C:\Bittware\chamber\bwversion.h

        Done

        If I paste the line into a dos window, it does what I want. But when I just compile in Dev-C++, it doesn't seem to do anything, including giving me any warnings or errors.

        This is what Dev-C++ sticks into the default makefile:

        all: all-before "The Chamber Maid.exe" all-after

        include version/bwversion.mak

        clean: clean-custom

         
    • Osito

      Osito - 2007-08-08

      By the way, I did put the tab in before the "c:... line. It just doesn't show up here.

       
    • Osito

      Osito - 2007-08-08

      DOH! I put the tab in but it got converted to spaces by the editor. When I opened the file in Notepad and put the real tab back, everything worked. Thanks for the info. I'm still curious why the gcc line shows up three times, but it works so I'm not complaining.

       
    • Nobody/Anonymous

      >> I'm still curious why the gcc line shows up three times, ...

      To be honest, me too :-P

      Old newbie

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.