We have multiple builds in our project. I would like to add a post-fix of the build to the version number, to identify the different builds. For example:
Build A: Version should be: “1.2.3-A”
Build B: Version should be: “1.2.3-B”
With Application Settings (generated.c/h) it seems not possible to add a post-fix to the version number. Is that correct?
I figured that because it is not possible with generated.c/h, I should disable the code generation and build my own code. I tried to make a copy of generated.c and .h, keeping the same contents. My builds with “Enable code generation” disabled (in Application settings), fail with the following error message: make: *** No rule to make target build.properties', needed byMSW01_01_pack.zip’. Stop.
If I diff the build.properties I see that version, company and name are missing . Which steps do I need to take to build my code without automatic code generation?
I am using Developer Studio V2.3.2 in combination with the internal makefile builder.
DS appends automatically a “qualifier” to the version when generating the code (if the preference is enabled, as it should be by default).
This qualifier is updated each time the application code is modified.
So with this qualifier it is not possible to automate my build process: I need to add a fixed qualifier which is different per build, which is not possible with the Java SimpleDateFormat class.
Therefore I would like to know is which steps I need to take to make code link without errors without using the code generation (generated.c/.h).
I can build version numbers with a fixed qualifier using string concatenation, I already build that.
See my opening post for the error that I receive linking without code generation.
Hmmmm, sounds like makefile builder is not compatible with disabling the code generation.
Anyway, you can give a try by disabling it anyway, and add a pre-build step (in Project Properties > C/C++ Build > Settings > Build Steps)
This step needs to stand in one command line, but you can use a call to a custom script (“cmd /c prebuild.bat”) responsible to generate both a .c file and the build.properties file required by the following steps.
When you’re talking about “all builds”, do you mean successive builds of the same project with the same Build Configuration, or a simple build (same source code) with different Build Configurations? I’m not sure to fully understand your use case.
We have single source code that should generate different outputs. For this I implemented a build per output, and use build-all to build all outputs with a single press of the button. So a simple build (same source code) with different Build Configurations.
Oh, OK, and that’s why your’re using the makefile builder, because the Build All Configurations is not working well with the Internal Builder.
And so your real need is to have a different qualifier per Build Configuration, in order to identify your different builds once deployed on the field, correct?
Correct 100%. And we identified already that it is currently only possible to generate a time qualifier. For this reasoning I disabled “automatic code generation” but this results in linker errors because build.properties is missing entries, see my post below.
As a workaround I developed a post-build script which generates my own build.properties. However I would like to pass the version number to this post-build script call.
Is it possible to make a variable that I can both use in my source code and in my post-build call?
A define in my code cannot be added as parameter for the post-build script.
A “Build Variable” cannot be used in the source code.
How can I make a single parameter that I can use both in the post-build script and my version number inside my source code?