Question

I am using autotools/eclipse/linux. I want to run a script to increment the build number in a header file every time I hit the build button. Do I add it in the Makefile.am? What is the syntax for this?

Était-ce utile?

La solution

You can do it like this: add it to the all target so that it gets run every time, and declare it as .PHONY so that make doesn't try to relate it to an existing file.

all: update-build-number

.PHONY: update-build-number
update-build-number:
    $(srcdir)/my_increment_script

Autres conseils

This may be useful to others trying to do version control with git and automate their version numbering

Here is my number generator:

#!/bin/sh
#echo "Test version of version_script runs OK!"
    majorversion=1
    #echo "Commits"
    #git rev-list HEAD
    lastmerge=`git rev-list --merges HEAD | head -n1`
    #echo "Last Merge"
    #echo $lastmerge
    #echo "Merges (Sub version)"
    #git rev-list --merges HEAD
    subvn=`git rev-list --merges HEAD | wc -l`
    #echo $subvn
    #echo "Commits+1 since last merge (Sub sub version)"
    subsubvn=`git rev-list HEAD | grep -B99999 -e$lastmerge - | wc -l`
    #echo $subsubvn
    #echo "No merges"
    #git rev-list --no-merges HEAD
    #git rev-list --no-merges HEAD | wc -l
    #echo $majorversion.$subvn.$subsubvn > versionnumfile
    echo $majorversion.$subvn.$sub

Major version is hard coded (at the moment), sub version is number of merges, sub-sub version is number of commits (+1) since last merge

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top