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