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