Sysprogs forums › Forums › VisualGDB › How to pass AdditionalIncludeDirectories to pre-build step?
- This topic has 2 replies, 2 voices, and was last updated 6 years ago by
UdoEberhardt.
-
AuthorPosts
-
December 6, 2019 at 10:56 #26760
UdoEberhardt
ParticipantHi,
I’m running a .cmd script as pre-build step and pass a few build variables to it:
Command: cmd.exe Arguments: /c pre-build.cmd "$(ToolchainDir)" "$(TargetDir)" "$(TargetFileNameWithoutExtension)" "$(ConfigurationName)" "%(AdditionalIncludeDirectories)"
While this works fine for $(ConfigurationName) etc. it does not work for %(AdditionalIncludeDirectories). The variable does not get resolved.
The script receives “%(AdditionalIncludeDirectories)” literally.How can I pass the include path specified in project properties to my script?
Thanks,
UdoDecember 6, 2019 at 17:57 #26778support
KeymasterHi,
The AdditionalIncludeDirectories variable exists on the MSBuild level and is not generally passed to the VisualGDB level (to make things more complicated, it is not a global MSBuild variable, but a property of each individual ClCompile item).
To work around it, you would need to create a custom MSBuild target, translate %(ClCompile.AdditionalIncludeDirectories) into a global variable (just placing <PropertyGroup> inside the custom target might work) and then use the <Exec> task to launch the custom tool. The rest of the variables you mentioned are available both on VisualGDB and MSBuild level, so they will work in this scenario as well.
An easier alternative would be to create a basic property sheet defining the include directories (see the stm32.props file created by VisualGDB for embedded STM32 projects), referencing it from your project and parsing its contents from the custom tool. This will avoid complex MSBuild scripting and will still avoid having multiple redundant definitions of the include directories.
December 10, 2019 at 07:49 #26832UdoEberhardt
ParticipantHi,
Thanks for your comments. To implement your first suggestion, I roughly followed these instructions and redefined the BuildDependsOn property. This works. I can access %(ClCompile.AdditionalIncludeDirectories) and %(ClCompile.PreprocessorDefinitions) and use them in my custom prebuild target. There are still a couple of details to solve, e.g. transforming the semicolon-separated list of path items into a sequence of -I options for gcc.
What I really want to achieve is preprocessing my linker script. I’m wondering if this wouldn’t be a nice feature for VGDB to support out of the box. I will open a separate topic to discuss this.
Udo
-
AuthorPosts
- You must be logged in to reply to this topic.