Fix defines and git version fetch

This commit is contained in:
Nedko Arnaudov 2009-07-13 01:44:43 +03:00
parent 3b5d8a0549
commit 5d7f71d453
4 changed files with 44 additions and 81 deletions

View File

@ -23,6 +23,7 @@
#define _GNU_SOURCE
#include "config.h"
#include "version.h"
#include <string.h>
#include <getopt.h>
@ -99,12 +100,11 @@ main(int argc,
}
}
// if (!default_dir)
// default_dir = DEFAULT_PROJECT_DIR;
if (!default_dir)
default_dir = DEFAULT_PROJECT_DIR;
lash_info("------------------");
//lash_info("LASH activated. Version %s (%s) built on %s",
// PACKAGE_VERSION, SVN_VERSION, timestamp_str);
lash_info("LASH activated. Version %s (%s) built on %s", PACKAGE_VERSION, GIT_VERSION, timestamp_str);
lash_debug("Default dir: '%s'", default_dir);

View File

@ -1,17 +0,0 @@
#!/bin/sh
if test $# -eq 1
then
DIR=${1}
else
DIR=.
fi
if test -d ${DIR}/.svn
then
pushd ${DIR} > /dev/null
svnversion
popd > /dev/null
else
sed 's/^#define SVN_VERSION "\(.*\)"$/\1/' ${DIR}/svnversion.h
fi

View File

@ -1,60 +0,0 @@
#!/bin/sh
#set -x
if test $# -ne 1 -a $# -ne 2
then
echo "Usage: "`basename "$0"`" <file> [define_name]"
exit 1
fi
OUTPUT_FILE="${1}"
TEMP_FILE="${OUTPUT_FILE}.tmp"
if test $# -eq 2
then
DEFINE=${2}
else
DEFINE=SVN_VERSION
fi
if test -d .svn
then
SVNVERSION=`svnversion`
else
if test -d .git
then
git status >/dev/null # updates dirty state
SVNVERSION=`git show | grep '^ *git-svn-id:' | sed 's/.*@\([0-9]*\) .*/\1/'`
if test ${SVNVERSION}
then
test -z "$(git diff-index --name-only HEAD)" || SVNVERSION="${SVNVERSION}M"
else
SVNVERSION=0+`git rev-parse HEAD`
test -z "$(git diff-index --name-only HEAD)" || SVNVERSION="${SVNVERSION}-dirty"
fi
fi
fi
if test -z ${SVNVERSION}
then
SVNVERSION=exported
fi
echo "#define ${DEFINE} \"${SVNVERSION}\"" > ${TEMP_FILE}
if test ! -f ${OUTPUT_FILE}
then
echo "Generated ${OUTPUT_FILE}"
cp ${TEMP_FILE} ${OUTPUT_FILE}
if test $? -ne 0; then exit 1; fi
else
if ! cmp -s ${OUTPUT_FILE} ${TEMP_FILE}
then echo "Regenerated ${OUTPUT_FILE}"
cp ${TEMP_FILE} ${OUTPUT_FILE}
if test $? -ne 0; then exit 1; fi
fi
fi
rm ${TEMP_FILE}
exit $?

40
wscript
View File

@ -64,6 +64,8 @@ def configure(conf):
errmsg = "not installed, see http://xmlsoft.org/",
args='--cflags --libs')
conf.define('DEFAULT_PROJECT_DIR', "audio-projects")
conf.define('PACKAGE_VERSION', VERSION)
conf.write_config_header('config.h')
display_msg(conf)
@ -102,6 +104,7 @@ def build(bld):
daemon.target = 'ladishd'
daemon.includes = "build/default" # XXX config.h version.h and other generated files
daemon.uselib = 'DBUS-1 LIBXML-2.0 UUID'
daemon.ver_header = 'version.h'
daemon.env.append_value("LINKFLAGS", ["-lutil"])
daemon.source = []
for source in [
@ -194,3 +197,40 @@ def build(bld):
def dist_hook():
pass
import commands
from Constants import RUN_ME
from TaskGen import feature, after
import Task, Utils
@feature('cc')
@after('apply_core')
def process_git(self):
if getattr(self, 'ver_header', None):
tsk = self.create_task('git_ver')
tsk.set_outputs(self.path.find_or_declare(self.ver_header))
def git_ver(self):
self.ver = "unknown"
self.ver = commands.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
if commands.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
self.ver += "-dirty"
Utils.pprint('BLUE', "git revision " + self.ver)
fi = open(self.outputs[0].abspath(self.env), 'w')
fi.write('#define GIT_VERSION "%s"\n' % self.ver)
fi.close()
cls = Task.task_type_from_func('git_ver', vars=[], func=git_ver, color='BLUE', before='cc')
def always(self):
return RUN_ME
cls.runnable_status = always
def post_run(self):
sg = Utils.h_list(self.ver)
node = self.outputs[0]
variant = node.variant(self.env)
self.generator.bld.node_sigs[variant][node.id] = sg
cls.post_run = post_run