[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 |
|
---|
[209] | 8 | source_targets=('reglookup-src-trunk.tar.gz',)
|
---|
| 9 | win32_targets=('reglookup-win32-trunk.zip',)
|
---|
| 10 | doc_targets=('reglookup-doc-trunk.tar.gz',)
|
---|
[222] | 11 | all_targets = source_targets+win32_targets+doc_targets
|
---|
[191] | 12 |
|
---|
| 13 | def target2version(target):
|
---|
[222] | 14 | chunks = target.split('-')
|
---|
| 15 | if len(chunks) != 3:
|
---|
| 16 | return None
|
---|
| 17 | return chunks[2].split('.')[0]
|
---|
[191] | 18 |
|
---|
| 19 | def version2input(version):
|
---|
| 20 | if version == 'trunk':
|
---|
| 21 | return 'trunk/'
|
---|
| 22 | else:
|
---|
| 23 | return 'releases/%s/' % version
|
---|
| 24 |
|
---|
| 25 |
|
---|
| 26 | source_cmds='''
|
---|
[187] | 27 | rm -rf .release;
|
---|
[189] | 28 | svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/$SOURCE .release/%s;
|
---|
| 29 | cd .release/%s && scons doc
|
---|
| 30 | cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
|
---|
| 31 | mv .release/%s.tar.gz . && rm -rf .release
|
---|
[187] | 32 | '''
|
---|
| 33 |
|
---|
[191] | 34 | win32_cmds='''
|
---|
| 35 | rm -rf .release && mkdir -p .release/%s
|
---|
| 36 | cp %s/src/*.exe .release/%s
|
---|
[222] | 37 | cp win32/libiconv/bin/*.dll win32/libpthreads/bin/*.dll win32/libtalloc/bin/*.dll trunk/lib/*.dll .release/%s
|
---|
[191] | 38 | cd .release && zip -r %s.zip %s
|
---|
| 39 | mv .release/%s.zip . && rm -rf .release
|
---|
| 40 | '''
|
---|
[187] | 41 |
|
---|
[209] | 42 | doc_cmds='''
|
---|
| 43 | rm -rf .release;
|
---|
| 44 | svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/ .release;
|
---|
| 45 | cd .release && doxygen Doxyfile.regfi
|
---|
[221] | 46 | cd .release && doxygen Doxyfile.pyregfi
|
---|
[209] | 47 | mv .release/doc .release/%s
|
---|
| 48 | cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
|
---|
| 49 | mv .release/%s.tar.gz . && rm -rf .release
|
---|
| 50 | '''
|
---|
| 51 |
|
---|
[189] | 52 | def generate_cmds(source, target, env, for_signature):
|
---|
| 53 | ret_val = ''
|
---|
| 54 | for t in target:
|
---|
[191] | 55 | t = str(t)
|
---|
| 56 | t_base = t.split('.tar.gz')[0].split('.zip')[0]
|
---|
| 57 | if t in source_targets:
|
---|
| 58 | ret_val += source_cmds % (t_base,t_base,t_base,
|
---|
| 59 | t_base,t_base,t_base)
|
---|
| 60 | elif t in win32_targets:
|
---|
| 61 | version = target2version(t)
|
---|
| 62 | input_prefix = version2input(version)
|
---|
| 63 |
|
---|
| 64 | env['platform']='cygwin'
|
---|
| 65 | env['CC']='i586-mingw32msvc-cc'
|
---|
| 66 | env['AR']='i586-mingw32msvc-ar'
|
---|
| 67 | env['RANLIB']='i586-mingw32msvc-ranlib'
|
---|
| 68 |
|
---|
| 69 | env['CFLAGS']=cflags
|
---|
| 70 | env['CPPPATH']=[input_prefix+'include',
|
---|
| 71 | libiconv_path+'include',
|
---|
[195] | 72 | libpthreads_path+'include',
|
---|
| 73 | libtalloc_path+'include']
|
---|
[191] | 74 | env['LIBPATH']=[input_prefix+'lib',
|
---|
| 75 | libiconv_path+'lib',
|
---|
[195] | 76 | libpthreads_path+'lib',
|
---|
| 77 | libtalloc_path+'lib']
|
---|
| 78 | env['LIBS']=['m', libpthread_name, 'iconv', 'regfi', 'talloc']
|
---|
[222] | 79 |
|
---|
| 80 | # Third-party dependencies
|
---|
| 81 | extra_obj=['%s/lib/lib%s.a' % (libpthreads_path, libpthread_name),
|
---|
| 82 | libiconv_path+'/lib/libiconv.dll.a',
|
---|
| 83 | libtalloc_path+'/lib/libtalloc.dll.a']
|
---|
[191] | 84 |
|
---|
[222] | 85 | # Build libregfi.dll
|
---|
| 86 | # Core regfi source
|
---|
[191] | 87 | lib_src = [input_prefix+'lib/regfi.c',
|
---|
| 88 | input_prefix+'lib/winsec.c',
|
---|
| 89 | input_prefix+'lib/range_list.c',
|
---|
| 90 | input_prefix+'lib/lru_cache.c',
|
---|
| 91 | input_prefix+'lib/void_stack.c']
|
---|
[222] | 92 | regfi_o = env.Object(lib_src)
|
---|
[191] | 93 |
|
---|
[222] | 94 | regfi_obj = []
|
---|
| 95 | for s in lib_src:
|
---|
| 96 | regfi_obj.append(s[0:-1]+'o')
|
---|
[191] | 97 |
|
---|
[222] | 98 | env.Command(input_prefix+'lib/libregfi.o', regfi_o+extra_obj,
|
---|
| 99 | 'i586-mingw32msvc-dlltool --export-all-symbols'
|
---|
| 100 | +' --dllname libregfi.dll -e $TARGET'
|
---|
| 101 | +' -l %slib/libregfi.dll.a %s'
|
---|
| 102 | % (input_prefix, ' '.join(regfi_obj)))
|
---|
| 103 |
|
---|
| 104 | env.Command(input_prefix+'lib/libregfi.dll',
|
---|
| 105 | input_prefix+'lib/libregfi.o',
|
---|
| 106 | 'i586-mingw32msvc-gcc --shared -o $TARGET $SOURCE %s'
|
---|
| 107 | % ' '.join(regfi_obj+extra_obj))
|
---|
| 108 |
|
---|
[191] | 109 | # Executables
|
---|
| 110 | reglookup = env.Program(input_prefix+'src/reglookup.exe',
|
---|
| 111 | [input_prefix+'src/reglookup.c']+extra_obj)
|
---|
| 112 | reglookup_recover = env.Program(input_prefix+'src/reglookup-recover.exe',
|
---|
| 113 | [input_prefix+'src/reglookup-recover.c']+extra_obj)
|
---|
| 114 |
|
---|
| 115 | ret_val += win32_cmds % (t_base,input_prefix,
|
---|
| 116 | t_base,t_base,t_base,t_base,t_base)
|
---|
| 117 |
|
---|
[209] | 118 | elif t in doc_targets:
|
---|
| 119 | ret_val += doc_cmds % (t_base,t_base,t_base,t_base,t_base)
|
---|
[191] | 120 |
|
---|
[189] | 121 | return ret_val
|
---|
[187] | 122 |
|
---|
[188] | 123 |
|
---|
[191] | 124 |
|
---|
[189] | 125 | release_builder = Builder(generator = generate_cmds,
|
---|
| 126 | suffix = '.tar.gz',
|
---|
| 127 | src_suffix = '',
|
---|
| 128 | prefix='reglookup-')
|
---|
[188] | 129 |
|
---|
[191] | 130 |
|
---|
[189] | 131 | env = Environment()
|
---|
| 132 | env['BUILDERS']['Release'] = release_builder
|
---|
[188] | 133 |
|
---|
[222] | 134 | if len(COMMAND_LINE_TARGETS) == 0:
|
---|
| 135 | print('Acceptable targets: %s' % repr(all_targets))
|
---|
[189] | 136 |
|
---|
[195] | 137 | for target in COMMAND_LINE_TARGETS:
|
---|
[222] | 138 | AlwaysBuild(target)
|
---|
| 139 | if target not in all_targets:
|
---|
| 140 | print('ERROR: cannot build "%s". Acceptable targets: %s'
|
---|
| 141 | % (target, repr(all_targets)))
|
---|
| 142 | break
|
---|
[191] | 143 | env.Release(target, Dir(version2input(target2version(target))))
|
---|
[189] | 144 |
|
---|
[187] | 145 | Default(None)
|
---|