source: SConstruct @ 193

Last change on this file since 193 was 191, checked in by tim, 15 years ago

updated scons build scripts to handle MinGW
added binaries for MinGW build dependencies

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