VisualGDB- Use Visual studio macros.

Sysprogs forums Forums VisualGDB VisualGDB- Use Visual studio macros.

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #26979
    Elram Ashush
    Participant

    Hi,

    I am using your cross-platform tool – VisualGDB (ver: 5.4 R12)

    And I have a problem in your “Custom build steps” feature,

    when I want to make an action-event (before or after build), I want to use the Visual-Studio Macros (e.g. $(IntDir), $(Platform) $(Configuration), $(ProjectName) …)

    but the VisualGDB don’t recognize them.

    I know that VisualGDB has it own macros ( Like $(ProjectDir)..)

    But I want other macros that VisualGDB doesn’t have.

    Do you have a solution for my problem?

     

    Thanks’, Elram Ashush.

    #26980
    Elram Ashush
    Participant

    Hi,

    I will add some details:

    I use VisualGDB for Remote Build  on Linux Machine (From Windows-PC Visual-Studio-17)

    and I use the MSBuild option.

    #26981
    support
    Keymaster

    Hi,

    Due to the MSBuild design constraints, VisualGDB indeed only has access to a handful of MSBuild macros. Specifically, you can use:

    • $(ProjectDir) (derived from the .vgdbsettings file location)
    • $(ConfigurationName)
    • $(SolutionDir)
    • $(SolutionPath)

    You can view the available macros via a link at the bottom of the VisualGDB Project Properties window.

    If you would like to use MSBuild macros instead, please consider using the VS Project Properties -> C/C++ (or Linker) -> Custom Step option. This works on MSBuild level and allows referencing any MSBuild variables. It is also possible to add custom MSBuild targets (that would result in additional entries in the generated Makefile), although it is more complicated to setup. Let us know if you need more details on that option.

    #26983
    Elram Ashush
    Participant

    Hi,
    Thanks’ for your help, can you show me an example for how to make referencing to the MSBiuld variables.
    (if you will add a screen shot it will be great 👍😀)

    #26988
    support
    Keymaster

    No problem, here you go:

    Attachments:
    You must be logged in to view attached files.
    #26998
    Elram Ashush
    Participant

    Hi,

    Thanks’ for your help, its good to know that i have this feature,

    but its not meets my needs, as I said in my first post, I need to get access to the VS variables (e.g. $(IntDir)..) before creating the make file.

    Your solution is post compile/link event, I need the same thing, but before building,

    my need is – to edit the make file (pojectName.msbuild-mak) after the MSBuild create it, and before running it on the linux-machine. (before your command “make -f …”)

    I already do it with the “before-build-action” in the VisualGDB-settings, but by explicit path, I want to use a general path to other projects.

     

    Elram.

     

     

     

    #27002
    support
    Keymaster

    Thanks for clarifying this. The scenario you described could be accomplished using a custom MSBuild task, however it would require some additional scripting.

    Please try creating a custom MSBuild task class as shown on this page and ensure it has a “GeneratedMakefile” parameter. In your .vcxproj file, add the following target:

    <Target Name="PatchMakefile">
        <MyTaskName GeneratedMakefile="$(RemoteBuildMakefile)"/>
    </Target>

    Make sure you reference your custom task assembly using the <UsingTask> tag. Finally, edit the <VisualGDB Directory>\MSBuild\MSBuild\Targets\remote.targets file as shown below:

    <Target Name="CommitRemoteBuild" Condition="('$(IsRemoteBuild)' == 'true') and ('$(DesignTimeBuild)' != 'true')" DependsOnTargets="PatchMakefile">

    This will invoke the custom Makefile patching task after VisualGDB writes most of the targets there (the lines before the “.PHONY: $(PREPARE_TARGETS) …” line) but before it starts Make.

    Let us know if this works and we will update the remote.targets file shipped with VisualGDB to use a project-level variable so that you won’t need to patch it.

    If you would like to patch the Makefile after VisualGDB writes the final lines to it, please try inserting your task between the FinalizeRemoteBuildMakefile and LaunchVisualGDB tasks in remote.targets. If this works, we can update the file on our side to allow plugging custom tasks at this point as well.

    #27264
    Elram Ashush
    Participant

    Hi,

    I’m sorry that I didn’t responded to your solution,

    Thanks For your help it’s works,

    I create my custom C# tasks and “give” them to the MSBuild as dlls. Its works!!!

     

    #27269
    support
    Keymaster

    No problem and good to know it works. If you encounter any further problems, feel free to get back to us.

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