1
# jhbuild - a build script for GNOME 1.x and 2.x
2
# Copyright (C) 2001-2006 James Henstridge
3
# Copyright (C) 2006-2007 Eric Anholt
5
# perl.py: perl module type definitions.
7
# This program is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 2 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program; if not, write to the Free Software
19
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
27
from jhbuild.errors import BuildStateError
28
from jhbuild.modtypes import \
29
Package, get_dependencies, get_branch, register_module_type
31
__all__ = [ 'MesaModule' ]
33
class MesaModule(Package):
34
"""Base type for building Mesa."""
37
STATE_CHECKOUT = 'checkout'
38
STATE_FORCE_CHECKOUT = 'force_checkout'
40
STATE_INSTALL = 'install'
42
def __init__(self, name, branch, makeargs='',
43
dependencies=[], after=[]):
44
Package.__init__(self, name, dependencies, after)
46
self.makeargs = makeargs
48
def get_srcdir(self, buildscript):
49
return self.branch.srcdir
51
def get_builddir(self, buildscript):
52
return self.get_srcdir(buildscript)
54
def get_revision(self):
55
return self.branch.branchname
57
def get_mesa_config(self):
58
uname = platform.uname();
59
if uname[0] == 'FreeBSD':
60
if uname[4] == 'i386':
61
config = 'freebsd-dri-x86'
62
elif uname[4] == 'amd64':
63
config = 'freebsd-dri-amd64'
65
config = 'freebsd-dri'
66
if uname[0] == 'Linux':
67
if uname[4] == 'i386':
68
config = 'linux-dri-x86'
69
elif uname[4] == 'x86_64':
70
config = 'linux-dri-x86_64'
75
def do_start(self, buildscript):
77
do_start.next_state = STATE_CHECKOUT
78
do_start.error_states = []
80
def skip_checkout(self, buildscript, last_state):
81
# skip the checkout stage if the nonetwork flag is set
82
return buildscript.config.nonetwork
84
def do_checkout(self, buildscript):
85
srcdir = self.get_srcdir(buildscript)
86
buildscript.set_action('Checking out', self)
87
self.branch.checkout(buildscript)
88
# did the checkout succeed?
89
if not os.path.exists(srcdir):
90
raise BuildStateError('source directory %s was not created'
92
do_checkout.next_state = STATE_BUILD
93
do_checkout.error_states = [STATE_FORCE_CHECKOUT]
95
def skip_force_checkout(self, buildscript, last_state):
98
def do_force_checkout(self, buildscript):
99
buildscript.set_action('Checking out', self)
100
self.branch.force_checkout(buildscript)
101
do_force_checkout.next_state = STATE_BUILD
102
do_force_checkout.error_states = [STATE_FORCE_CHECKOUT]
104
def skip_build(self, buildscript, last_state):
105
return buildscript.config.nobuild
107
def do_build(self, buildscript):
108
buildscript.set_action('Building', self)
109
builddir = self.get_builddir(buildscript)
110
make = os.environ.get('MAKE', 'make')
111
if (os.path.exists(builddir + '/configs/current')):
112
buildscript.execute([make], cwd=builddir)
114
buildscript.execute([make, self.get_mesa_config()], cwd=builddir)
115
do_build.next_state = STATE_INSTALL
116
do_build.error_states = [STATE_FORCE_CHECKOUT]
118
def skip_install(self, buildscript, last_state):
119
return buildscript.config.nobuild
121
def do_install(self, buildscript):
122
buildscript.set_action('Installing', self)
123
builddir = self.get_builddir(buildscript)
124
prefix = buildscript.config.prefix
126
buildscript.execute(['mkdir', '-p',
127
prefix + '/lib/dri'],
129
for x in glob.glob(builddir + '/lib/libGL*'):
130
buildscript.execute(['cp',
134
for x in glob.glob(builddir + '/lib/*_dri.so'):
135
buildscript.execute(['cp',
137
prefix + '/lib/dri'],
139
for x in glob.glob(builddir + '/include/GL/*.h'):
140
buildscript.execute(['cp',
142
prefix + '/include/GL'],
144
buildscript.packagedb.add(self.name, self.get_revision() or '')
145
do_install.next_state = Package.STATE_DONE
146
do_install.error_states = []
149
def parse_mesa(node, config, repositories, default_repo):
150
id = node.getAttribute('id')
152
if node.hasAttribute('makeargs'):
153
makeargs = node.getAttribute('makeargs')
155
# override revision tag if requested.
156
makeargs += ' ' + config.module_makeargs.get(id, config.makeargs)
158
dependencies, after = get_dependencies(node)
159
branch = get_branch(node, repositories, default_repo)
161
return MesaModule(id, branch, makeargs,
162
dependencies=dependencies, after=after)
163
register_module_type('mesa', parse_mesa)