[60] | 1 | import sys |
---|
| 2 | import os |
---|
| 3 | |
---|
| 4 | cflags = '-std=gnu99 -pedantic -Wall -D_FILE_OFFSET_BITS=64' |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | latest_release='0.0.1' |
---|
| 8 | source_targets=('src-trunk', 'src-0.0.1',) |
---|
| 9 | all_targets = source_targets |
---|
| 10 | |
---|
| 11 | |
---|
| 12 | def parse_target(target): |
---|
| 13 | chunks = target.split('-') |
---|
| 14 | if len(chunks) != 2: |
---|
| 15 | return None |
---|
| 16 | return chunks |
---|
| 17 | |
---|
| 18 | def version2input(version): |
---|
| 19 | if version == 'trunk': |
---|
| 20 | return 'trunk/' |
---|
| 21 | else: |
---|
| 22 | return 'releases/%s/' % version |
---|
| 23 | |
---|
| 24 | |
---|
| 25 | export_cmds=''' |
---|
| 26 | rm -rf .export |
---|
| 27 | svn export --depth files https://bletchley.googlecode.com/svn/ .export |
---|
| 28 | svn export https://bletchley.googlecode.com/svn/%(path)s .export/%(path)s |
---|
| 29 | ''' |
---|
| 30 | |
---|
| 31 | version_cmds=''' |
---|
| 32 | echo 'BLETCHLEY_VERSION="%(version)s"' > .export/%(path)s/bletchley_version.py |
---|
| 33 | ''' |
---|
| 34 | |
---|
| 35 | svnversion_cmds=''' |
---|
| 36 | svn 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 | |
---|
| 41 | cleanup_cmds=''' |
---|
| 42 | rm -rf .export |
---|
| 43 | ''' |
---|
| 44 | |
---|
| 45 | source_cmds=''' |
---|
| 46 | mv %s .export/%s |
---|
| 47 | cd .export/%s && scons doc |
---|
| 48 | cd .export && tar cf %s.tar %s && gzip -9 %s.tar |
---|
| 49 | mv .export/%s.tar.gz . |
---|
| 50 | '''+cleanup_cmds |
---|
| 51 | |
---|
| 52 | |
---|
| 53 | def 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 | |
---|
| 67 | release_builder = Builder(generator = generate_cmds, |
---|
| 68 | suffix = '', |
---|
| 69 | src_suffix = '', |
---|
| 70 | prefix='') |
---|
| 71 | |
---|
| 72 | env = Environment() |
---|
| 73 | env['BUILDERS']['Release'] = release_builder |
---|
| 74 | |
---|
| 75 | if len(COMMAND_LINE_TARGETS) == 0: |
---|
| 76 | print('Acceptable targets: %s' % repr(all_targets)) |
---|
| 77 | |
---|
| 78 | for 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 | |
---|
| 96 | Default(None) |
---|