substitutions in custom project templates

Sysprogs forums Forums VisualGDB substitutions in custom project templates

Tagged: 

This topic contains 6 replies, has 2 voices, and was last updated by  support 1 month ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #27186

    richp
    Participant

    In version 5.1, Linux project templates had the ability to name files like “$$PROJECTNAMEBASE$$.cpp” that would be named with the project name in the resulting project directory.  Also, the files themselves could have textual replacements done so “$$PROJECTNAMEBASE_CPPID$$” would also get replaced with the project name.  None of this seems to work in version 5.4.  Is there a way to do project name substitutions with custom project templates?  Is there a way to run code on the Windows machine or the target machine as part of creating a new project?

    Also, custom project templates and it appears that the support for standard linux project templates from “program files\Sysprogs\VisualGDB\ProjectTemplates\Linux” has been removed. Is this correct?

    #27193

    support
    Keymaster

    Hi,

    The <VisualGDB>\ProjectTemplates\Linux folder is still present in VisualGDB 5.4 and 5.5 and the underlying logic has not changed much since v5.1.

    The custom project templates are still supported, although only with the classic project types (i.e. not with Arduino, Mbed or ESP-IDF). If you believe the path substitution is not working, please share the exact steps to reproduce the issue and we will advise you on the workaround.

    Regarding running custom code, it is not possible to run it during project creation, however it is possible to add it as a custom shortcut (VisualGDB Project Properties -> Custom Shortcuts) that will be available via the Project menu in Visual Studio. You can create a shortcut for the initialization commands that should be run after creating the project from the template and then run it after creating the project from the template.

    #27194

    richp
    Participant

    Thanks for the reply.

    In the “New Linux Project” wizard in 5.4, there is no longer a way to specify a template from the <VisualGDB>\ProjectTemplates\Linux folder.  The old wizard had a drop down selection of the templates that applied to Application/Shared Library/Static Library… The current wizard just has “Create a new project” with the ability to select binary type, the make tool-chain and the language standard.

    For custom project templates.  I have a template with file names ‘$$PROJECTNAMEBASE$$.cpp’ and ‘$$PROJECTNAMEBASE$$.h’ in the template zip file.  They are copied directly to the resulting project directory.  Within the files I had ‘$$PROJECTNAMEBASE_CPPID$$’ text that I expected to be replaced with the new project name.  The files were copied without any textual substitutions.  Perhaps there is some other mechanism to indicate that these changes should be done, like in the template.xml document.  I just had this in the xml document:

    <FileReference>
    <FileName>$$PROJECTNAMEBASE$$.cpp</FileName>
    <IsExternal>false</IsExternal>
    <IsExcludedFromBuild>false</IsExcludedFromBuild>
    <ItemType>ClCompile</ItemType>
    </FileReference>

    I did try ‘$(ProjectName).cpp’ for the FileName as well, but it didn’t help.

    I’ll include my custom template file.

    #27195

    richp
    Participant

    Trying the template renamed as zip.

    Attachments:
    You must be logged in to view attached files.
    #27211

    support
    Keymaster

    Thanks for the explanation. VisualGDB 5.4+ still uses the templates under <VisualGDB>\ProjectTemplates, however instead of showing a plain list of templates in the wizard, it allows automatically picks the best template based on the project type/build subsystem choices. As a side effect, this indeed makes it impossible to add custom templates via this mechanism.

    We have updated the logic that handles the .vgdbxpt files to substitute the $$PROJECTNAMEBASE$$ and $$PROJECTNAMEBASE_CPPID$$ variables. VisualGDB will also substitute those values inside the files that have the SubstituteProjectName property set to true in the template.xml file (re-create the template using the VisualGDB build below to see the new property).

    Please try this build: VisualGDB-5.5.3.3457.msi

    #27214

    richp
    Participant

    Thank you so much.  This seems to work great.

    I noticed this with 5.4 and it is still a problem in this 5.5.3 build. When creating a project for a Linux shared library with a custom template the target filename doesn’t get the ‘.so’ file extension, so I’ve had to add the extension to get the build to work. I see that the template.xml file has ProjectType as SharedLibrary, but there is nothing else in it about the target file name or extension.  This is from the newly created template from a project that does have .so on the output file name under Project Makefile Settings and $(TargetExtension) is ‘.so’; but a project created from the custom template does not.

    #27252

    support
    Keymaster

    No problem, please try this build: VisualGDB-5.5.3.3461.msi

    We have also added a checkbox in the Export Template window that allows automatically replacing the exported project’s name with $$PROJECTNAME$$ in file names and contents.

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.