source: SConstruct @ 138

Last change on this file since 138 was 60, checked in by tmorgan, 11 years ago

packaging build script

File size: 2.5 KB
RevLine 
[60]1import sys
2import os
3
4cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64'
5
6
7latest_release='0.0.1'
8source_targets=('src-trunk', 'src-0.0.1',)
9all_targets = source_targets
10
11
12def parse_target(target):
13    chunks = target.split('-')
14    if len(chunks) != 2:
15        return None
16    return chunks
17
18def version2input(version):
19    if version == 'trunk':
20        return 'trunk/'
21    else:
22        return 'releases/%s/' % version
23
24
25export_cmds='''
26rm -rf .export
27svn export --depth files https://bletchley.googlecode.com/svn/ .export
28svn export https://bletchley.googlecode.com/svn/%(path)s .export/%(path)s
29'''
30
31version_cmds='''
32echo 'BLETCHLEY_VERSION="%(version)s"' > .export/%(path)s/bletchley_version.py
33'''
34
35svnversion_cmds='''
36svn info https://bletchley.googlecode.com/svn/trunk/\
37  | grep "Last Changed Rev:" | cut -d' ' -f 4 \
38  | sed 's/^/BLETCHLEY_VERSION="%(latest_release)s.svn/' | sed 's/$/"/' > .export/%(path)s/bletchley_version.py
39'''
40
41cleanup_cmds='''
42rm -rf .export
43'''
44
45source_cmds='''
46mv %s .export/%s
47cd .export/%s && scons doc
48cd .export && tar cf %s.tar %s && gzip -9 %s.tar
49mv .export/%s.tar.gz .
50'''+cleanup_cmds
51
52
53def generate_cmds(source, target, env, for_signature):
54    ret_val = ''
55    input_prefix = str(source[0])+'/'
56
57    for t in target:
58        ttype,version = parse_target(str(t))
59        t_base = 'bletchley-%s-%s' % (ttype, version)
60
61        if ttype == 'src':
62            ret_val += source_cmds % (input_prefix, t_base, t_base, t_base,
63                                      t_base, t_base, t_base)
64    return ret_val
65
66
67release_builder = Builder(generator = generate_cmds,
68                          suffix = '',
69                          src_suffix = '',
70                          prefix='')
71
72env = Environment()
73env['BUILDERS']['Release'] = release_builder
74
75if len(COMMAND_LINE_TARGETS) == 0:
76    print('Acceptable targets: %s' % repr(all_targets))
77
78for target in COMMAND_LINE_TARGETS:
79    if target not in all_targets:
80        print('ERROR: cannot build "%s".  Acceptable targets: %s'
81              % (target, repr(all_targets)))
82        sys.exit(1)
83    AlwaysBuild(target)
84    ttype,version = parse_target(target)
85
86    params = {'path':version2input(version),
87              'version':version,
88              'latest_release':latest_release}
89    env.Execute(export_cmds % params)
90    if version == 'trunk':
91        print env.Execute(svnversion_cmds % params)
92    else:
93        env.Execute(version_cmds % params)
94    env.Release(target, Dir('.export/'+params['path']))
95
96Default(None)
Note: See TracBrowser for help on using the repository browser.