Changeset 3202e31 in rtems-docs


Ignore:
Timestamp:
Jan 4, 2019, 10:02:45 AM (13 days ago)
Author:
Sebastian Huber <sebastian.huber@…>
Branches:
master
Children:
cd408b5
Parents:
c1d296a
git-author:
Sebastian Huber <sebastian.huber@…> (01/04/19 10:02:45)
git-committer:
Sebastian Huber <sebastian.huber@…> (01/09/19 08:23:58)
Message:

Replace build date with Git hash and commit date

The usage of a build date prevents reproducible builds.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • common/conf.py

    rc1d296a r3202e31  
    1 import datetime
    2 
    3 def build_date():
    4     now = datetime.date.today()
    5     m = now.strftime('%B')
    6     y = now.strftime('%Y')
    7     if now.day == 11:
    8         s = 'th'
    9     elif now.day % 10 == 1:
    10         s = 'st'
    11     elif now.day == 12:
    12         s = 'th'
    13     elif now.day % 10 == 2:
    14         s = 'nd'
    15     elif now.day == 13:
    16         s = 'th'
    17     elif now.day == 3:
    18         s = 'rd'
    19     else:
    20         s = 'th'
    21     d = '%2d%s' % (now.day, s)
    22     return '%s %s %s' % (d, m, y)
    23 
    241extensions = [
    252        "sphinx.ext.autodoc",
     
    4825# General information about the project.
    4926project = u'RTEMS Documentation Project'
    50 copyright = u'2018, RTEMS Project (built %s)' % (build_date())
     27copyright = u'2018, RTEMS Project'
    5128
    5229# The version info for the project you're documenting, acts as replacement for
  • common/waf.py

    rc1d296a r3202e31  
    1818sphinx_min_version = (1, 3)
    1919
    20 def build_date():
    21     import datetime
    22     now = datetime.date.today()
    23     m = now.strftime('%B')
    24     y = now.strftime('%Y')
    25     if now.day % 10 == 1:
    26         s = 'st'
    27     elif now.day % 10 == 2:
    28         s = 'nd'
    29     elif now.day == 3:
    30         s = 'rd'
    31     else:
    32         s = 'th'
    33     d = '%2d%s' % (now.day, s)
    34     return '%s %s %s' % (d, m, y)
    35 
    3620def version_cmdline(ctx):
    37     return '-Drelease="%s" -Dversion="%s"' % (ctx.env.VERSION, ctx.env.VERSION)
     21    return '-Drelease="%s" -Dversion="%s"' % (ctx.env.RELEASE, ctx.env.VERSION)
    3822
    3923def sphinx_cmdline(ctx, build_type, conf_dir, doctrees,
     
    208192    check_sphinx = not ctx.env.BIN_SPHINX_BUILD
    209193    if check_sphinx:
    210         ctx.msg('Checking version', ctx.env.VERSION)
    211 
    212194        ctx.find_program("sphinx-build", var="BIN_SPHINX_BUILD", mandatory = True)
    213195        ctx.find_program("aspell", var = "BIN_ASPELL", mandatory = False)
     
    503485
    504486    root = cat.createElement('rtems-docs')
    505     root.setAttribute('date', build_date())
     487    root.setAttribute('date', ctx.env.DATE)
    506488    cat.appendChild(root)
    507489
  • wscript

    rc1d296a r3202e31  
    99import waflib
    1010import waf as docs_waf
    11 
    12 version = '5.0.0 (master)'
    1311
    1412build_all = ['user',
     
    3230
    3331def configure(conf):
    34     conf.env.VERSION = version
    3532    for b in building:
    3633        conf.recurse(b)
     
    5451        o.write(js.replace('@CATALOGUE', xml))
    5552
     53def pretty_day(day):
     54    if day == 3:
     55        s = 'rd'
     56    elif day == 11:
     57        s = 'th'
     58    elif day == 12:
     59        s = 'th'
     60    elif day == 13:
     61        s = 'th'
     62    elif day % 10 == 1:
     63        s = 'st'
     64    elif day % 10 == 2:
     65        s = 'nd'
     66    else:
     67        s = 'th'
     68    return str(day) + s
     69
    5670def build(ctx):
     71    #
     72    # Get date and version from Git
     73    #
     74    version = '5.0.0'
     75    if ctx.exec_command(['git', 'diff-index', '--quiet', 'HEAD']) == 0:
     76        modified = ''
     77    else:
     78        modified = '-modified'
     79    try:
     80        out = ctx.cmd_and_log(['git', 'log', '-1', '--format=%H,%cd', '--date=format:%e,%B,%Y'])
     81        f = out.strip('\n').split(',')
     82        version = version + '.' + f[0] + modified
     83        date = pretty_day(int(f[1])) + ' ' + f[2] + ' ' + f[3]
     84    except waflib.Build.Errors.WafError:
     85        date = 'unknown date'
     86    ctx.env.DATE = date
     87    ctx.env.RELEASE = version + ' (' + date + ')'
     88    ctx.env.VERSION = version
     89
    5790    #
    5891    # Generate any PlantUML images if enabled.
Note: See TracChangeset for help on using the changeset viewer.