Menu

Custom build rule for VS2005

Help
2007-08-29
2013-05-28
  • Glenn Ramsey

    Glenn Ramsey - 2007-08-29

    I have created a custom build rule for VS2005 to create *_sm.cpp and *_sm.h files from .sm files, appended below.

    This almost works. It correctly compiles the sm files, but it compiles every time, not just when the output files are out of date.

    Anyone know how to make it work properly and only compile when the .sm has been changed?

    Glenn

    <?xml version="1.0" encoding="utf-8"?>
    <VisualStudioToolFile
        Name="StateMachineCompiler"
        Version="8.00"
        >
        <Rules>
            <CustomBuildRule
                Name="State Machine Compiler"
                DisplayName="State Machine Compiler"
                CommandLine="java -jar &quot;C:\Libraries\smc_4_3_0\bin\Smc.jar&quot; -c++ -g [inputs]"
                Outputs="$(InputName)_sm.cpp $(InputName)_sm.h"
                FileExtensions="*.sm"
                ExecutionDescription="Executing SMC... $(InputName)"
                >
                <Properties>
                </Properties>
            </CustomBuildRule>
        </Rules>
    </VisualStudioToolFile>

     
    • Bill Thorpe

      Bill Thorpe - 2007-08-29
       
    • Glenn Ramsey

      Glenn Ramsey - 2007-08-30

      Thanks Bill,

      It seems that for C++ custom builds it isn't as difficult to set up the rules as it appears to be for C#, as in that discussion.

      Microsoft have this example where they do it for flex and bison.

      http://www.microsoft.com/downloads/details.aspx?familyid=36873774-ca5b-4b49-acb7-94b8cd4ef502&displaylang=en

      The relevant part is:

      <VisualStudioToolFile
          Name="Flex and Bison Tools"
          Version="8.00"
          >
          <Rules>
              <CustomBuildRule
                  Name="FlexGenerator"
                  DisplayName="Flex Generator"
                  CommandLine="flex.exe [AllOptions] [AdditionalOptions] [Inputs]"
                  Outputs="lex.$(InputName).c"
                  FileExtensions="*.l"
                  ExecutionDescription="Generating lexical analyser..."
                  >
      -----8<-----

      As far as I can tell my rule for SMC should work the same as in the example.

      Is it possible that SMC does something with the file's timestamp that msbuild recognises as needing to be rebuilt?

      Glenn

       

Log in to post a comment.

MongoDB Logo MongoDB