Changeset 191 for SConstruct


Ignore:
Timestamp:
04/25/10 17:52:37 (15 years ago)
Author:
tim
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • SConstruct

    r189 r191  
     1cflags = '-std=gnu99 -pedantic -Wall'
    12
    2 build_cmds='''
     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='''
    321rm -rf .release;
    422svn export svn+ssh://sentinelchicken.org/home/projects/subversion/reglookup/$SOURCE .release/%s;
    5 #XXX: Can this be less of a hack?
    623cd .release/%s && scons doc
    724cd .release && tar cf %s.tar %s && gzip -9 %s.tar;
     
    926'''
    1027
    11 buildable_files=('reglookup-trunk.tar.gz',)
     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'''
    1235
    1336def generate_cmds(source, target, env, for_signature):
    1437    ret_val = ''
    1538    for t in target:
    16         if str(t) in buildable_files:
    17             t_base = str(t).split('.')[0]
    18             ret_val += build_cmds % (t_base,t_base,t_base,
    19                                      t_base,t_base,t_base)
     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
    2085        else:
    2186            return '#ERROR: cannot build "%s".  Acceptable targets: %s' % (t, repr(buildable_files))
     87       
     88    return ret_val
    2289
    23     return ret_val
    2490
    2591
     
    2995                          prefix='reglookup-')
    3096
     97
    3198env = Environment()
    3299env['BUILDERS']['Release'] = release_builder
    33100
    34101
    35 env.Release(Dir('trunk'))
    36 #env.Release('reglookup-0.13.0.tar.gz', Dir('releases/0.13.0'))
     102for target in source_targets:
     103    env.Release(target, Dir(version2input(target2version(target))))
     104
     105for target in win32_targets:
     106    env.Release(target, Dir(version2input(target2version(target))))
     107
    37108
    38109Default(None)
Note: See TracChangeset for help on using the changeset viewer.