none
C++ custom build step with code generator RRS feed

  • Question

  • (Note: I'm using VS2013 and experimenting with VS2015, answers using either are welcome)

    I have a solution with two C++ projects: "Squee" (schema queue) produces a .exe that can parse ".squee" files to generate a ".cpp" and ".h" file; and "TDPlus", the end-product .exe which includes several ".squee" files that I need to parse to generate ".cpp" and ".h" files used by TDPlus.

    Currently I do this with a custom build step but it's not very transparent; is there a way to configure the project so that it knows to do this automatically, or to register "Squee" as a custom build tool for the ".squee" file type, or at least more-easily specify it as the build tool for specific files.

    Is this possible?

    Thursday, May 21, 2015 12:22 AM

Answers

  • It turns out the easiest way to do this was to find an old vc7 project, create a .rules file and then load that into VS2015, creating the .props, .targets and .xml files and showing me how to use them.

    <?xml version="1.0" encoding="utf-8"?>
    <VisualStudioToolFile
    Name="Squee Build Rules"
    Version="8.00"
    >
    <Rules>
        <CustomBuildRule
            Name="Squee"
            DisplayName="Squee"
            CommandLine="$(SolutionDir)$(Configuration)\squee.exe --cxx=%(RelativeDir)%(Filename).cxx --hxx=%(RelativeDir)%(Filename).hxx %(RelativeDir)(%Filename).squee"
            Outputs="%(RelativeDir)%(Filename).cxx;%(RelativeDir)%(Filename).hxx"
            AdditionalDependencies="*.squee"
            FileExtensions="*.squee"
            ExecutionDescription="Processing .squee files"
            >
            <Properties>
            </Properties>
        </CustomBuildRule>
    </Rules>
    </VisualStudioToolFile>
    The only thing missing is a dependency on the squee.exe itself so that it'll build it if it's missing before trying to compile a .squee file but also so that it will detect a recompile of squee.exe as a reason to recompile .squee files.



    Thursday, May 21, 2015 1:50 AM

All replies

  • It turns out the easiest way to do this was to find an old vc7 project, create a .rules file and then load that into VS2015, creating the .props, .targets and .xml files and showing me how to use them.

    <?xml version="1.0" encoding="utf-8"?>
    <VisualStudioToolFile
    Name="Squee Build Rules"
    Version="8.00"
    >
    <Rules>
        <CustomBuildRule
            Name="Squee"
            DisplayName="Squee"
            CommandLine="$(SolutionDir)$(Configuration)\squee.exe --cxx=%(RelativeDir)%(Filename).cxx --hxx=%(RelativeDir)%(Filename).hxx %(RelativeDir)(%Filename).squee"
            Outputs="%(RelativeDir)%(Filename).cxx;%(RelativeDir)%(Filename).hxx"
            AdditionalDependencies="*.squee"
            FileExtensions="*.squee"
            ExecutionDescription="Processing .squee files"
            >
            <Properties>
            </Properties>
        </CustomBuildRule>
    </Rules>
    </VisualStudioToolFile>
    The only thing missing is a dependency on the squee.exe itself so that it'll build it if it's missing before trying to compile a .squee file but also so that it will detect a recompile of squee.exe as a reason to recompile .squee files.



    Thursday, May 21, 2015 1:50 AM
  • Thanks for sharing you solution here, quietbrit!

    Have a nice day,

    Jack


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Thursday, May 21, 2015 10:06 AM
    Moderator