Post Generate (Target) Command
Hi,
I'm struggling to do something that should apparently be relatively simple. I want to import a different touchgfx.props file to the .vcxproject depending on a variable. Now, you might wonder why I want to do that, so let me explain quickly the reason before jumping to my problem. I want my touchgfx project to support two different screen resolutions, which touchgfx designer doesn't allow by default. My idea is therefore to have two different touchgfx designer projects configured each with a different resolution and with different 'asset folders' that compile to the same VS project.
So far so good, I've managed to do that and everything works fine. Now, I'd like to add a precompiler definition to the project based on which resolution I use cuz I might need to do some specific things on the child views based on the resolutions.
I figured some 'precompiler definitions' are imported from a file called touchgfx-sdl2.props located in the /generated/simulator/msvs file, and that the .vcxproject allows conditions, therefore I thought it would be quite easy, as I could just create two different .prop files with a different precompiler definition and import one or the other based on a variable… And here comes my problem… I don't know how to import this variable to the .vcx project?
I thought at first the easiest would just be to create and set an environment variable in a batch file but for some reason, .vcxproject doesn't recognize environment variables? (even though VS documentation says it does). None of those works:
<Import Project="..\..\generated\simulator\msvs\touchgfx_sdl2.props" Condition="exists('$(MY_ENVIRONMENT_VAR)')"/>
<Import Project="..\..\generated\simulator\msvs\touchgfx_sdl2-2.props" Condition="'$(MY_ENVIRONMENT_VARIABLE)'=='true'"/>
And yes, the variable exists and is set correctly… So it kind of forced me to consider another approach… Which is passing directly an argument to the msbuild command with /:p and just use it in the .vxcproject. But where is the msbuild command actually called?
I'm not too familiar with makefiles nor with build tools and I'm getting a bit lost here as I haven't found this command called once… But in order to build the VS application, this command must be called somewhere right?
Touchgfx allows to pass a post generate command and a post generate target command. What is the difference between the two? In which order are they called?
The default post generate command is this one:
touchgfx update_project --project-file=simulator/msvs/Application.vcxproj
Why can't I pass an argument to this command? If I remove the command, my project won't update obviously, so I can't even call a.bat file to set the environment variable as I wanted to… Touchgfx_update_project is a command that's only understood by the touchgfx designer, right?
Touchgfx documentation on this is really scarce and not well explained tbh. If I remove the post generate target command (which is by default touchgfx update_project, which seems to me so similar to the post generate command), what happens?
Also, as of now, I've only been talking about VS but I'd like to do something similar with the IAR project and I don't even know where to start with this one…
Thanks in advance for any help. Hope I've made myself clear!
