Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/build-scripts/jhbuild/jhbuild/modtypes/gdbmodule.py
blob: a4894cd3809cede75077c7b58b08b0d1f2eac9e8 (plain)
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
# jhbuild - a build script for GNOME 1.x and 2.x
# Copyright (C) 2001-2004  James Henstridge
#
#   gdbmodule.py: module type definitions for the GNU Debugger
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

import os
import string

import base
from jhbuild.utils import cvs

class GDBCVSRoot(cvs.CVSRoot):
    '''A class to handle CVS update operations in the GDB CVS
    repository.'''

    def getcheckoutdir(self, module, checkoutdir=None):
        '''Override CVSRoot.getcheckoutdir to return GDB''s top-level
        directory, src.'''
        return os.path.join(self.localroot, 'src')

    def update(self, buildscript, module, revision=None, date=None,
               checkoutdir=None):
        '''Override CVSRoot.update to remove the -d option to cvs
        update.  When run in GDB''s top-level directory, src, cvs
        update -d will checkout all modules in the repository rather
        than simply updating gdb and its requirements.'''
        dir = self.getcheckoutdir(module, checkoutdir)
        if not os.path.exists(dir):
            return self.checkout(buildscript, module,
                                 revision, date, checkoutdir)

        os.chdir(dir)
        cmd = 'cvs -z3 -q -d %s update -P ' % self.cvsroot

        if revision:
            cmd += '-r %s ' % revision
        if date:
            cmd += '-D "%s" ' % date
        if not (revision or date):
            cmd = cmd + '-A '

        cmd += '.'

        return buildscript.execute(cmd, 'cvs')

class GDBModule(base.CVSModule):
    CVSRoot = GDBCVSRoot
    def __init__(self,
                 cvsmodule,
                 checkoutdir=None,
                 revision=None,
                 autogenargs=None,
                 makeargs=None,
                 dependencies=[],
                 suggests=[],
                 cvsroot=None,
                 supports_non_srcdir_builds=True):
        base.CVSModule.__init__(self,
                                cvsmodule,
                                checkoutdir=checkoutdir,
                                revision=revision,
                                autogenargs=autogenargs,
                                makeargs=makeargs,
                                dependencies=dependencies,
                                suggests=suggests,
                                cvsroot=cvsroot,
                                supports_non_srcdir_builds=supports_non_srcdir_builds)

    def get_srcdir(self, buildscript):
        '''Override base.CVSModule.get_srcdir to return GDB''s
        top-level directory, src.'''
        cvsroot = self.CVSRoot(self.cvsroot,
                               buildscript.config.checkoutroot)

        return cvsroot.getcheckoutdir(self.cvsmodule,
                                      self.checkoutdir)

    def do_configure(self, buildscript):
        '''Override base.CVSModule.do_configure to call configure
        rather than autogen.  Also, GDB''s configure script only
        accepts the --option=%s syntax; the build fails if --prefix %s
        is used.'''
        builddir = self.get_builddir(buildscript)
        if buildscript.config.buildroot and not os.path.exists(builddir):
            os.makedirs(builddir)
        os.chdir(builddir)
        buildscript.set_action('Configuring', self)
        if buildscript.config.buildroot and self.supports_non_srcdir_builds:
            cmd = self.get_srcdir(buildscript) + '/configure'
        else:
            cmd = './configure'
        cmd += ' --prefix=%s' % buildscript.config.prefix
        if buildscript.config.use_lib64:
            cmd += " --libdir='${exec_prefix}/lib64'"
        cmd += ' %s' % self.autogenargs
        if buildscript.config.makeclean:
            nextstate = self.STATE_CLEAN
        else:
            nextstate = self.STATE_BUILD
        if buildscript.execute(cmd) == 0:
            return (nextstate, None, None)
        else:
            return (nextstate, 'could not configure module',
                    [self.STATE_FORCE_CHECKOUT])

def parse_gdbmodule(node, config, uri, dependencies, suggests, cvsroot):
    return base.parse_cvsmodule(node, config, dependencies,
                                suggests, cvsroot, CVSModule=GDBModule)

base.register_module_type('gdbmodule', parse_gdbmodule)