File: wscript

package info (click to toggle)
gtkimageview 1.6.4%2Bdfsg-2
  • links: PTS
  • area: main
  • in suites: buster
  • size: 3,644 kB
  • ctags: 2,147
  • sloc: python: 10,555; sh: 9,137; ansic: 6,858; makefile: 155; xml: 7
file content (157 lines) | stat: -rw-r--r-- 5,075 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#! /usr/bin/env python
# encoding: utf-8
import Logs
import Options
import os
import os.path
import pproc
import shutil
import tarfile

VERSION='1.6.4'
APPNAME='gtkimageview'

srcdir = '.'
blddir = 'build'

def copy_files(files, todir):
    for file in files:
        if os.path.isdir(file):
            continue
        dstdir = os.path.dirname(os.path.join(todir, file))
        if not os.path.exists(dstdir):
            os.mkdir(dstdir)
        shutil.copy2(file, dstdir)

def missing_files(files):
    return [f for f in files if not os.path.exists(f)]

def run_proc_logged(cmd):
    proc = pproc.Popen(cmd, shell = True)
    proc.communicate()
    if proc.returncode != 0:
        Logs.error('Running %s failed' % cmd)
    return proc.returncode

def dist():
    tmp_dir = APPNAME + '-' + VERSION
    archive = tmp_dir + '.tar.gz'

    if os.path.exists(tmp_dir):
        shutil.rmtree(tmp_dir)
    if os.path.exists(archive):
        os.remove(archive)
    os.mkdir(tmp_dir)

    Logs.info('Getting file list from Subversion...')
    proc = pproc.Popen('svn list -R', shell = True, stdout = pproc.PIPE)
    svn_files = proc.communicate()[0].split('\n')
    if proc.returncode != 0:
        Logs.error('Failed creating dist.')
        return

    Logs.info('Copying Subversion files...')
    # Filter out non-files.
    svn_files = [file for file in svn_files if os.path.isfile(file)]
    copy_files(svn_files, tmp_dir)

    # The junk that autotools needs.
    extra_dist = ['aclocal.m4',
                  'config.guess',
                  'config.sub',
                  'configure',
                  'configure.in',
                  'depcomp',
                  'gtk-doc.make',
                  'install-sh',
                  'ltmain.sh',
                  'missing',
                  'Makefile.in',
                  'docs/Makefile.in',
                  'docs/reference/Makefile.in',
                  'src/Makefile.in',
                  'src/gtkimageview-marshal.c',
                  'src/gtkimageview-marshal.h',
                  'src/gtkimageview-typebuiltins.c',
                  'src/gtkimageview-typebuiltins.h',
                  'tests/Makefile.in',
                  'tests/testlib/Makefile.in']

    # If any file is missing, autogen.sh needs to be run to regenerate
    # them.
    missing = missing_files(extra_dist)
    if missing:
        Logs.info('Regenerating autotools files (%s missing)...' %
                  ' '.join(missing))
        if run_proc_logged('./autogen.sh') != 0:
            return

    # If any file still is missing, then make has to be run
    # unfortunately, to regenerate it.
    missing = missing_files(extra_dist)
    if missing:
        Logs.info('Recompiling project (%s missing)...' %
                  ' '.join(missing))
        if run_proc_logged('make') != 0:
            return

    Logs.info('Copying non-versioned files...')
    copy_files(extra_dist, tmp_dir)

    Logs.info('Copying HTML documentation...')
    if not os.path.exists('build/default/src/html/index.html'):
        Logs.error('HTML docs not found. Please build docs before disting.')
        return
    shutil.copytree('build/default/src/html',
                    os.path.join(tmp_dir, 'docs/reference/html'))

    # Create the archive.
    tar = tarfile.open(archive, 'w:gz')
    tar.add(tmp_dir)
    tar.close()
    Logs.info('Your archive is ready -> %s' % archive)
    shutil.rmtree(tmp_dir)

def set_options(opt):
    opt.tool_options('compiler_cc')
    opt.tool_options('gnu_dirs')
    opt.tool_options('gtkdoc')
    buildopts = opt.add_option_group(
        'Build Configuration',
        'These settings control which extra targets to build. They only make sense with the build command.')
    buildopts.add_option('--demos',
                         action = 'store_true',
                         default = False,
                         help = 'Build demo programs')
    buildopts.add_option('--tests',
                         action = 'store_true',
                         default = False,
                         help = 'Build unit test programs')

def configure(conf):
    conf.check_tool('compiler_cc')
    conf.check_tool('gnome')
    conf.check_tool('misc')
    conf.check_cfg(package = 'gtk+-2.0',
                   uselib_store = 'GTK',
                   atleast_version = '2.6.0',
                   args = '--cflags --libs',
                   mandatory = True)
    conf.check_tool('gtkdoc', tooldir = '.')
    # Waf doesn't set the -g and -O2 flags automatically so add them
    # here.
    if not conf.env['CCFLAGS']:
        conf.env['CCFLAGS'] = ['-g', '-O2']
    flags = ['-std=c99', '-Wall', '-Werror', '-Wmissing-prototypes']
    conf.env.append_value('CCFLAGS', flags)

def build(bld):
    bld.env['PACKAGE_NAME'] = APPNAME
    bld.env['PACKAGE_VERSION'] = VERSION
    bld.add_subdirs('src')
    bld.add_subdirs('tests')

    # Build the gtkimageview.pc file.
    bld.new_task_gen('subst',
                     source = 'gtkimageview.pc.in',
                     install_path = '${LIBDIR}/pkgconfig')