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 | cd .release && doxygen Doxyfile.pyregfi |
---|
43 | mv .release/doc .release/%s |
---|
44 | cd .release && tar cf %s.tar %s && gzip -9 %s.tar; |
---|
45 | mv .release/%s.tar.gz . && rm -rf .release |
---|
46 | ''' |
---|
47 | |
---|
48 | def generate_cmds(source, target, env, for_signature): |
---|
49 | ret_val = '' |
---|
50 | for t in target: |
---|
51 | t = str(t) |
---|
52 | t_base = t.split('.tar.gz')[0].split('.zip')[0] |
---|
53 | if t in source_targets: |
---|
54 | ret_val += source_cmds % (t_base,t_base,t_base, |
---|
55 | t_base,t_base,t_base) |
---|
56 | elif t in win32_targets: |
---|
57 | version = target2version(t) |
---|
58 | input_prefix = version2input(version) |
---|
59 | |
---|
60 | env['platform']='cygwin' |
---|
61 | env['CC']='i586-mingw32msvc-cc' |
---|
62 | env['AR']='i586-mingw32msvc-ar' |
---|
63 | env['RANLIB']='i586-mingw32msvc-ranlib' |
---|
64 | |
---|
65 | env['CFLAGS']=cflags |
---|
66 | env['CPPPATH']=[input_prefix+'include', |
---|
67 | libiconv_path+'include', |
---|
68 | libpthreads_path+'include', |
---|
69 | libtalloc_path+'include'] |
---|
70 | env['LIBPATH']=[input_prefix+'lib', |
---|
71 | libiconv_path+'lib', |
---|
72 | libpthreads_path+'lib', |
---|
73 | libtalloc_path+'lib'] |
---|
74 | env['LIBS']=['m', libpthread_name, 'iconv', 'regfi', 'talloc'] |
---|
75 | |
---|
76 | |
---|
77 | # Libraries |
---|
78 | lib_src = [input_prefix+'lib/regfi.c', |
---|
79 | input_prefix+'lib/winsec.c', |
---|
80 | input_prefix+'lib/range_list.c', |
---|
81 | input_prefix+'lib/lru_cache.c', |
---|
82 | input_prefix+'lib/void_stack.c'] |
---|
83 | libregfi_static = env.Library(lib_src) |
---|
84 | |
---|
85 | extra_obj=['%s/lib/lib%s.a' % (libpthreads_path, libpthread_name), |
---|
86 | libiconv_path+'/lib/libiconv.dll.a', |
---|
87 | libtalloc_path+'/lib/libtalloc.dll.a', |
---|
88 | input_prefix+'lib/libregfi.a',] |
---|
89 | |
---|
90 | # Executables |
---|
91 | reglookup = env.Program(input_prefix+'src/reglookup.exe', |
---|
92 | [input_prefix+'src/reglookup.c']+extra_obj) |
---|
93 | reglookup_recover = env.Program(input_prefix+'src/reglookup-recover.exe', |
---|
94 | [input_prefix+'src/reglookup-recover.c']+extra_obj) |
---|
95 | |
---|
96 | ret_val += win32_cmds % (t_base,input_prefix, |
---|
97 | t_base,t_base,t_base,t_base,t_base) |
---|
98 | |
---|
99 | elif t in doc_targets: |
---|
100 | ret_val += doc_cmds % (t_base,t_base,t_base,t_base,t_base) |
---|
101 | |
---|
102 | else: |
---|
103 | return '#ERROR: cannot build "%s". Acceptable targets: %s'\ |
---|
104 | % (t, repr(source_targets+win32_targets+doc_targets)) |
---|
105 | |
---|
106 | return ret_val |
---|
107 | |
---|
108 | |
---|
109 | |
---|
110 | release_builder = Builder(generator = generate_cmds, |
---|
111 | suffix = '.tar.gz', |
---|
112 | src_suffix = '', |
---|
113 | prefix='reglookup-') |
---|
114 | |
---|
115 | |
---|
116 | env = Environment() |
---|
117 | env['BUILDERS']['Release'] = release_builder |
---|
118 | |
---|
119 | |
---|
120 | for target in COMMAND_LINE_TARGETS: |
---|
121 | env.Release(target, Dir(version2input(target2version(target)))) |
---|
122 | |
---|
123 | |
---|
124 | Default(None) |
---|