make git_ver work with tarball
This commit is contained in:
parent
50a72744c8
commit
0d1ac13dd3
41
wscript
41
wscript
|
@ -4,6 +4,8 @@
|
||||||
import os
|
import os
|
||||||
import Options
|
import Options
|
||||||
import Utils
|
import Utils
|
||||||
|
import shutil
|
||||||
|
import re
|
||||||
|
|
||||||
APPNAME='ladish'
|
APPNAME='ladish'
|
||||||
VERSION='0.1'
|
VERSION='0.1'
|
||||||
|
@ -131,10 +133,13 @@ def configure(conf):
|
||||||
display_msg(conf, "==================")
|
display_msg(conf, "==================")
|
||||||
version_msg = APPNAME + "-" + VERSION
|
version_msg = APPNAME + "-" + VERSION
|
||||||
|
|
||||||
#if svnrev:
|
if os.access('version.h', os.R_OK):
|
||||||
# version_msg += " exported from r" + rev
|
data = file('version.h').read()
|
||||||
#else:
|
m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
|
||||||
# version_msg += " git revision will checked and eventually updated during build"
|
if m != None:
|
||||||
|
version_msg += " exported from " + m.group(1)
|
||||||
|
elif os.access('.git', os.R_OK):
|
||||||
|
version_msg += " git revision will checked and eventually updated during build"
|
||||||
|
|
||||||
display_msg(conf, version_msg)
|
display_msg(conf, version_msg)
|
||||||
|
|
||||||
|
@ -337,7 +342,7 @@ def build(bld):
|
||||||
# install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png')
|
# install_as(os.path.normpath(bld.env()['DATADIR'] + '/icons/hicolor/' + icon_size + '/apps/'), bld.env()['APP_INSTALL_NAME'] + '.png', 'icons/' + icon_size + '/patchage.png')
|
||||||
|
|
||||||
def dist_hook():
|
def dist_hook():
|
||||||
pass
|
shutil.copy('../build/default/version.h', "./")
|
||||||
|
|
||||||
import commands
|
import commands
|
||||||
from Constants import RUN_ME
|
from Constants import RUN_ME
|
||||||
|
@ -352,14 +357,28 @@ def process_git(self):
|
||||||
tsk.set_outputs(self.path.find_or_declare(self.ver_header))
|
tsk.set_outputs(self.path.find_or_declare(self.ver_header))
|
||||||
|
|
||||||
def git_ver(self):
|
def git_ver(self):
|
||||||
self.ver = "unknown"
|
header = self.outputs[0].abspath(self.env)
|
||||||
self.ver = commands.getoutput("LANG= git rev-parse HEAD").splitlines()[0]
|
if os.access('../version.h', os.R_OK):
|
||||||
if commands.getoutput("LANG= git diff-index --name-only HEAD").splitlines():
|
shutil.copy('../version.h', header)
|
||||||
self.ver += "-dirty"
|
data = file(header).read()
|
||||||
|
m = re.match(r'^#define GIT_VERSION "([^"]*)"$', data)
|
||||||
|
if m != None:
|
||||||
|
self.ver = m.group(1)
|
||||||
|
Utils.pprint('BLUE', "tarball from git revision " + self.ver)
|
||||||
|
else:
|
||||||
|
self.ver = "tarball"
|
||||||
|
return
|
||||||
|
|
||||||
Utils.pprint('BLUE', "git revision " + self.ver)
|
if os.access('../.git', os.R_OK):
|
||||||
|
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"
|
||||||
|
|
||||||
fi = open(self.outputs[0].abspath(self.env), 'w')
|
Utils.pprint('BLUE', "git revision " + self.ver)
|
||||||
|
else:
|
||||||
|
self.ver = "unknown"
|
||||||
|
|
||||||
|
fi = open(header, 'w')
|
||||||
fi.write('#define GIT_VERSION "%s"\n' % self.ver)
|
fi.write('#define GIT_VERSION "%s"\n' % self.ver)
|
||||||
fi.close()
|
fi.close()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue