Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>As I wrote before after some testing I found that the original solution has a problem since the version number is not updated every time a new build is done. In a lot of cases I had edited a source file, run the build, but still got the same build number ... The building process just decided that nothing was changed and skipped the step which would have updated the build number. I first attempted to find a way to force that step, but couldn't figure it out. Finally I decided to go a different way. Now I use the script to generate a header file <code>build_number.h</code> which contains a <code>#define BUILD</code> with the updated number behind. So Calebs script is now a bit modified (<code>build_number.sh</code>) :</p> <pre><code>#!/bin/bash number=`cat build_number` let number++ echo "$number" | tee build_number #&lt;-- output and save the number back to file echo "#define BUILD ""$number" | tee ../MyProject/build_number.h </code></pre> <p>The incrementing number is still stored within a file called <code>build_number</code>. I could have avoided a third file by parsing the generated header-file for the number, but decided against it. Note that the script and the generated header are located in the projects directory while the <code>build_number</code> file is in the build directory. That's not perfect, but I can live with it.</p> <p>In order to put things together there are now some more things to do. First the generated header-file needs to be added to the project in the Qt Designer ... Right-click on Header-Files and "Add existing file". Second, it has to be included in the C++-file where the BUILD define inside is accessed ... <code>#include "build_number.h"</code> ... and last but not least some additions have to be made to the project file (<code>MyProject.pro</code>). Note that I deleted the stuff from Calebs solution, so we start from scratch here :</p> <pre><code>build_nr.commands = ../MyProject/build_number.sh build_nr.depends = FORCE QMAKE_EXTRA_TARGETS += build_nr PRE_TARGETDEPS += build_nr </code></pre> <p>These lines (I put them before the HEADERS section) force the execution of the script, which reads the last build number from <code>build_number</code>, increments it, writes it back and also generates an updated version of the <code>build_number.h</code> file. Since that's part of the source of the project the new value gets linked into the code every time.</p> <p>There's one thing to mention - now the building process is <em>never</em> at the opinion that nothing has changed. So even if you leave your code unchanged a new run of make will generate a new version number and build a new binary. The old solution left the number when code changed, this new solution forces a new build even when the source is unchanged, since I force a change in that one header file. One would have prefered something in between but since the header is only included in one place the rebuild is very fast and doesn't hurt much. But still, if somebody knows how to get the best of both worlds please advise. At least now I'll not have two different binaries with the same version number.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload