[191] | 1 | cflags = '-std=gnu99 -pedantic -Wall'
|
---|
[189] | 2 |
|
---|
[191] | 3 | libiconv_path='win32/libiconv/'
|
---|
| 4 | libpthreads_path='win32/libpthreads/'
|
---|
| 5 | libpthread_name='pthreadGC2'
|
---|
| 6 |
|
---|
| 7 | source_targets=('reglookup-trunk.tar.gz',)
|
---|
| 8 | win32_targets=('reglookup-trunk-win32.zip',)
|
---|
| 9 |
|
---|
| 10 | def target2version(target):
|
---|
| 11 | return target.split('-')[1].split('.')[0]
|
---|
| 12 |
|
---|
| 13 | def version2input(version):
|
---|
| 14 | if version == 'trunk':
|
---|
| 15 | return 'trunk/'
|
---|
| 16 | else:
|
---|
| 17 | return 'releases/%s/' % version
|
---|
| 18 |
|
---|
| 19 |
|
---|
| 20 | source_cmds='''
|
---|
[187] | 21 | rm -rf .release;
|
---|
[189] | 22 | svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/$SOURCE .release/%s;
|
---|
| 23 | cd .release/%s && scons doc
|
---|
| 24 | cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
|
---|
| 25 | mv .release/%s.tar.gz . && rm -rf .release
|
---|
[187] | 26 | '''
|
---|
| 27 |
|
---|
[191] | 28 | win32_cmds='''
|
---|
| 29 | rm -rf .release && mkdir -p .release/%s
|
---|
| 30 | cp %s/src/*.exe .release/%s
|
---|
| 31 | cp win32/libiconv/bin/*.dll win32/libpthreads/bin/*.dll .release/%s
|
---|
| 32 | cd .release && zip -r %s.zip %s
|
---|
| 33 | mv .release/%s.zip . && rm -rf .release
|
---|
| 34 | '''
|
---|
[187] | 35 |
|
---|
[189] | 36 | def generate_cmds(source, target, env, for_signature):
|
---|
| 37 | ret_val = ''
|
---|
| 38 | for t in target:
|
---|
[191] | 39 | t = str(t)
|
---|
| 40 | t_base = t.split('.tar.gz')[0].split('.zip')[0]
|
---|
| 41 | if t in source_targets:
|
---|
| 42 | ret_val += source_cmds % (t_base,t_base,t_base,
|
---|
| 43 | t_base,t_base,t_base)
|
---|
| 44 | elif t in win32_targets:
|
---|
| 45 | version = target2version(t)
|
---|
| 46 | input_prefix = version2input(version)
|
---|
| 47 |
|
---|
| 48 | env['platform']='cygwin'
|
---|
| 49 | env['CC']='i586-mingw32msvc-cc'
|
---|
| 50 | env['AR']='i586-mingw32msvc-ar'
|
---|
| 51 | env['RANLIB']='i586-mingw32msvc-ranlib'
|
---|
| 52 |
|
---|
| 53 | env['CFLAGS']=cflags
|
---|
| 54 | env['CPPPATH']=[input_prefix+'include',
|
---|
| 55 | libiconv_path+'include',
|
---|
| 56 | libpthreads_path+'include']
|
---|
| 57 | env['LIBPATH']=[input_prefix+'lib',
|
---|
| 58 | libiconv_path+'lib',
|
---|
| 59 | libpthreads_path+'lib']
|
---|
| 60 | env['LIBS']=['m', libpthread_name, 'iconv', 'regfi']
|
---|
| 61 |
|
---|
| 62 |
|
---|
| 63 | # Libraries
|
---|
| 64 | lib_src = [input_prefix+'lib/regfi.c',
|
---|
| 65 | input_prefix+'lib/talloc.c',
|
---|
| 66 | input_prefix+'lib/winsec.c',
|
---|
| 67 | input_prefix+'lib/range_list.c',
|
---|
| 68 | input_prefix+'lib/lru_cache.c',
|
---|
| 69 | input_prefix+'lib/void_stack.c']
|
---|
| 70 | libregfi_static = env.Library(lib_src)
|
---|
| 71 |
|
---|
| 72 | extra_obj=['%s/lib/lib%s.a' % (libpthreads_path, libpthread_name),
|
---|
| 73 | libiconv_path+'/lib/libiconv.dll.a',
|
---|
| 74 | input_prefix+'lib/libregfi.a']
|
---|
| 75 |
|
---|
| 76 | # Executables
|
---|
| 77 | reglookup = env.Program(input_prefix+'src/reglookup.exe',
|
---|
| 78 | [input_prefix+'src/reglookup.c']+extra_obj)
|
---|
| 79 | reglookup_recover = env.Program(input_prefix+'src/reglookup-recover.exe',
|
---|
| 80 | [input_prefix+'src/reglookup-recover.c']+extra_obj)
|
---|
| 81 |
|
---|
| 82 | ret_val += win32_cmds % (t_base,input_prefix,
|
---|
| 83 | t_base,t_base,t_base,t_base,t_base)
|
---|
| 84 |
|
---|
[189] | 85 | else:
|
---|
| 86 | return '#ERROR: cannot build "%s". Acceptable targets: %s' % (t, repr(buildable_files))
|
---|
[191] | 87 |
|
---|
[189] | 88 | return ret_val
|
---|
[187] | 89 |
|
---|
[188] | 90 |
|
---|
[191] | 91 |
|
---|
[189] | 92 | release_builder = Builder(generator = generate_cmds,
|
---|
| 93 | suffix = '.tar.gz',
|
---|
| 94 | src_suffix = '',
|
---|
| 95 | prefix='reglookup-')
|
---|
[188] | 96 |
|
---|
[191] | 97 |
|
---|
[189] | 98 | env = Environment()
|
---|
| 99 | env['BUILDERS']['Release'] = release_builder
|
---|
[188] | 100 |
|
---|
[189] | 101 |
|
---|
[191] | 102 | for target in source_targets:
|
---|
| 103 | env.Release(target, Dir(version2input(target2version(target))))
|
---|
[189] | 104 |
|
---|
[191] | 105 | for target in win32_targets:
|
---|
| 106 | env.Release(target, Dir(version2input(target2version(target))))
|
---|
| 107 |
|
---|
| 108 |
|
---|
[187] | 109 | Default(None)
|
---|