mirror of
https://git.rtems.org/rtems-docs/
synced 2025-07-23 02:43:15 +08:00
waf: Fix version.py to support older versions of git.
This commit is contained in:
parent
5d8b0ddd0a
commit
d721375610
@ -69,14 +69,31 @@ _version = 'invalid'
|
|||||||
_date = 'unknown date'
|
_date = 'unknown date'
|
||||||
_released = False
|
_released = False
|
||||||
|
|
||||||
def _pretty_day(day):
|
def _pretty_day(ctx, date):
|
||||||
|
''' Format is YYYY-MM-DD'''
|
||||||
|
import datetime
|
||||||
|
ds = date.split('-')
|
||||||
|
if len(ds) != 3:
|
||||||
|
ctx.fatal('invalid date format from git: %s' % (date))
|
||||||
|
try:
|
||||||
|
year = int(ds[0])
|
||||||
|
except:
|
||||||
|
ctx.fatal('invalid date format from git, converting year: %s' % (date))
|
||||||
|
try:
|
||||||
|
month = int(ds[1])
|
||||||
|
except:
|
||||||
|
ctx.fatal('invalid date format from git, converting month: %s' % (date))
|
||||||
|
try:
|
||||||
|
day = int(ds[2])
|
||||||
|
except:
|
||||||
|
ctx.fatal('invalid date format from git, converting day: %s' % (date))
|
||||||
|
try:
|
||||||
|
when = datetime.date(year, month, day)
|
||||||
|
except:
|
||||||
|
ctx.fatal('invalid date format from git: %s' % (date))
|
||||||
if day == 3:
|
if day == 3:
|
||||||
s = 'rd'
|
s = 'rd'
|
||||||
elif day == 11:
|
elif day == 11 or day == 12:
|
||||||
s = 'th'
|
|
||||||
elif day == 12:
|
|
||||||
s = 'th'
|
|
||||||
elif day == 13:
|
|
||||||
s = 'th'
|
s = 'th'
|
||||||
elif day % 10 == 1:
|
elif day % 10 == 1:
|
||||||
s = 'st'
|
s = 'st'
|
||||||
@ -84,7 +101,10 @@ def _pretty_day(day):
|
|||||||
s = 'nd'
|
s = 'nd'
|
||||||
else:
|
else:
|
||||||
s = 'th'
|
s = 'th'
|
||||||
return str(day) + s
|
s = when.strftime('%%d%s %%B %%Y' % (s))
|
||||||
|
if day < 10:
|
||||||
|
s = s[1:]
|
||||||
|
return s
|
||||||
|
|
||||||
def get(ctx, rtems_major_version):
|
def get(ctx, rtems_major_version):
|
||||||
global _version
|
global _version
|
||||||
@ -122,19 +142,16 @@ def get(ctx, rtems_major_version):
|
|||||||
#
|
#
|
||||||
# Get date and version from Git
|
# Get date and version from Git
|
||||||
#
|
#
|
||||||
if ctx.exec_command(['git', 'diff-index', '--quiet', 'HEAD']) == 0:
|
if ctx.exec_command([ctx.env.GIT[0], 'diff-index', '--quiet', 'HEAD']) == 0:
|
||||||
modified = ''
|
modified = ''
|
||||||
else:
|
else:
|
||||||
modified = '-modified'
|
modified = '-modified'
|
||||||
try:
|
out = ctx.cmd_and_log([ctx.env.GIT[0], 'log', '-1',
|
||||||
out = ctx.cmd_and_log(['git', 'log', '-1',
|
'--format=%h,%cd', '--date=short'],
|
||||||
'--format=%h,%cd', '--date=format:%e,%B,%Y'],
|
quiet = True)
|
||||||
quiet = True)
|
f = out.strip('\n').split(',')
|
||||||
f = out.strip('\n').split(',')
|
version = version + '.' + f[0] + modified
|
||||||
version = version + '.' + f[0] + modified
|
date = _pretty_day(ctx, f[1])
|
||||||
date = _pretty_day(int(f[1])) + ' ' + f[2] + ' ' + f[3]
|
|
||||||
except waflib.Build.Errors.WafError:
|
|
||||||
date = 'unknown date'
|
|
||||||
_version = version
|
_version = version
|
||||||
_date = date
|
_date = date
|
||||||
_release = released
|
_release = released
|
||||||
|
1
wscript
1
wscript
@ -44,6 +44,7 @@ def options(opt):
|
|||||||
docs_waf.cmd_options(opt)
|
docs_waf.cmd_options(opt)
|
||||||
|
|
||||||
def configure(conf):
|
def configure(conf):
|
||||||
|
conf.find_program('git')
|
||||||
for b in building:
|
for b in building:
|
||||||
conf.recurse(b)
|
conf.recurse(b)
|
||||||
conf.env['BUILD_FROM_TOP'] = 'yes'
|
conf.env['BUILD_FROM_TOP'] = 'yes'
|
||||||
|
Loading…
x
Reference in New Issue
Block a user