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