source: SConstruct @ 221

Last change on this file since 221 was 221, checked in by tim, 14 years ago

added a lot of documentation for pyregfi and a few more attributes

File size: 4.2 KB
Line 
1cflags = '-std=gnu99 -pedantic -Wall'
2
3libiconv_path='win32/libiconv/'
4libpthreads_path='win32/libpthreads/'
5libpthread_name='pthreadGC2'
6libtalloc_path='win32/libtalloc/'
7
8source_targets=('reglookup-src-trunk.tar.gz',)
9win32_targets=('reglookup-win32-trunk.zip',)
10doc_targets=('reglookup-doc-trunk.tar.gz',)
11
12def target2version(target):
13    return target.split('-')[2].split('.')[0]
14
15def version2input(version):
16    if version == 'trunk':
17        return 'trunk/'
18    else:
19        return 'releases/%s/' % version
20
21
22source_cmds='''
23rm -rf .release;
24svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/$SOURCE .release/%s;
25cd .release/%s && scons doc
26cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
27mv .release/%s.tar.gz . && rm -rf .release
28'''
29
30win32_cmds='''
31rm -rf .release && mkdir -p .release/%s
32cp %s/src/*.exe .release/%s
33cp win32/libiconv/bin/*.dll win32/libpthreads/bin/*.dll win32/libtalloc/bin/*.dll .release/%s
34cd .release && zip -r %s.zip %s
35mv .release/%s.zip . && rm -rf .release
36'''
37
38doc_cmds='''
39rm -rf .release;
40svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/ .release;
41cd .release && doxygen Doxyfile.regfi
42cd .release && doxygen Doxyfile.pyregfi
43mv .release/doc .release/%s
44cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
45mv .release/%s.tar.gz . && rm -rf .release
46'''
47
48def 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
110release_builder = Builder(generator = generate_cmds,
111                          suffix = '.tar.gz',
112                          src_suffix = '',
113                          prefix='reglookup-')
114
115
116env = Environment()
117env['BUILDERS']['Release'] = release_builder
118
119
120for target in COMMAND_LINE_TARGETS:
121    env.Release(target, Dir(version2input(target2version(target))))
122
123
124Default(None)
Note: See TracBrowser for help on using the repository browser.